Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
6a0f6ab3
Commit
6a0f6ab3
authored
Jul 10, 2019
by
Viktor De Pasquale
Committed by
John Wu
Jul 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated magisk installer so it uses predownloaded file
parent
88a39483
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
23 deletions
+59
-23
Patching.kt
...rc/main/java/com/topjohnwu/magisk/model/flash/Patching.kt
+8
-4
InstallerHelper.kt
...c/main/java/com/topjohnwu/magisk/tasks/InstallerHelper.kt
+18
-0
MagiskInstaller.java
...main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
+27
-13
FlashViewModel.kt
...main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt
+6
-6
No files found.
app/src/main/java/com/topjohnwu/magisk/model/flash/Patching.kt
View file @
6a0f6ab3
...
...
@@ -5,10 +5,11 @@ import com.topjohnwu.magisk.tasks.MagiskInstaller
import
com.topjohnwu.superuser.Shell
sealed
class
Patching
(
file
:
Uri
,
private
val
console
:
MutableList
<
String
>,
logs
:
MutableList
<
String
>,
private
val
resultListener
:
FlashResultListener
)
:
MagiskInstaller
(
console
,
logs
)
{
)
:
MagiskInstaller
(
console
,
logs
,
file
)
{
override
fun
onResult
(
success
:
Boolean
)
{
if
(
success
)
{
...
...
@@ -21,29 +22,32 @@ sealed class Patching(
}
class
File
(
file
:
Uri
,
private
val
uri
:
Uri
,
console
:
MutableList
<
String
>,
logs
:
MutableList
<
String
>,
resultListener
:
FlashResultListener
)
:
Patching
(
console
,
logs
,
resultListener
)
{
)
:
Patching
(
file
,
console
,
logs
,
resultListener
)
{
override
fun
operations
()
=
extractZip
()
&&
handleFile
(
uri
)
&&
patchBoot
()
&&
storeBoot
()
}
class
SecondSlot
(
file
:
Uri
,
console
:
MutableList
<
String
>,
logs
:
MutableList
<
String
>,
resultListener
:
FlashResultListener
)
:
Patching
(
console
,
logs
,
resultListener
)
{
)
:
Patching
(
file
,
console
,
logs
,
resultListener
)
{
override
fun
operations
()
=
findSecondaryImage
()
&&
extractZip
()
&&
patchBoot
()
&&
flashBoot
()
&&
postOTA
()
}
class
Direct
(
file
:
Uri
,
console
:
MutableList
<
String
>,
logs
:
MutableList
<
String
>,
resultListener
:
FlashResultListener
)
:
Patching
(
console
,
logs
,
resultListener
)
{
)
:
Patching
(
file
,
console
,
logs
,
resultListener
)
{
override
fun
operations
()
=
findImage
()
&&
extractZip
()
&&
patchBoot
()
&&
flashBoot
()
}
...
...
app/src/main/java/com/topjohnwu/magisk/tasks/InstallerHelper.kt
0 → 100644
View file @
6a0f6ab3
package
com.topjohnwu.magisk.tasks
import
android.content.Context
import
android.net.Uri
import
com.topjohnwu.magisk.utils.get
import
com.topjohnwu.magisk.utils.readUri
import
java.io.File
object
InstallerHelper
{
@JvmStatic
fun
copyFileTo
(
uri
:
Uri
,
zip
:
File
)
{
zip
.
deleteRecursively
()
get
<
Context
>().
readUri
(
uri
).
use
{
input
->
zip
.
outputStream
().
use
{
out
->
input
.
copyTo
(
out
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
View file @
6a0f6ab3
...
...
@@ -4,9 +4,6 @@ import android.net.Uri;
import
android.os.Build
;
import
android.text.TextUtils
;
import
androidx.annotation.MainThread
;
import
androidx.annotation.WorkerThread
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Info
;
...
...
@@ -41,13 +38,21 @@ import java.util.List;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
import
androidx.annotation.MainThread
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.WorkerThread
;
public
abstract
class
MagiskInstaller
{
protected
String
srcBoot
;
protected
File
destFile
;
protected
File
installDir
;
private
List
<
String
>
console
,
logs
;
@Nullable
private
final
Uri
preDownloadedFile
;
private
final
List
<
String
>
console
;
private
final
List
<
String
>
logs
;
private
boolean
isTar
=
false
;
private
class
ProgressLog
implements
DownloadProgressListener
{
...
...
@@ -72,14 +77,16 @@ public abstract class MagiskInstaller {
protected
MagiskInstaller
()
{
console
=
NOPList
.
getInstance
();
logs
=
NOPList
.
getInstance
();
preDownloadedFile
=
null
;
}
public
MagiskInstaller
(
List
<
String
>
out
,
List
<
String
>
err
)
{
public
MagiskInstaller
(
List
<
String
>
out
,
List
<
String
>
err
,
@NonNull
Uri
magisk
)
{
console
=
out
;
logs
=
err
;
installDir
=
new
File
(
App
.
deContext
.
getFilesDir
().
getParent
(),
"install"
);
Shell
.
sh
(
"rm -rf "
+
installDir
).
exec
();
installDir
.
mkdirs
();
preDownloadedFile
=
magisk
;
}
protected
boolean
findImage
()
{
...
...
@@ -94,7 +101,7 @@ public abstract class MagiskInstaller {
protected
boolean
findSecondaryImage
()
{
String
slot
=
ShellUtils
.
fastCmd
(
"echo $SLOT"
);
String
target
=
(
TextUtils
.
equals
(
slot
,
"_a"
)
?
"_b"
:
"_a"
)
;
String
target
=
TextUtils
.
equals
(
slot
,
"_a"
)
?
"_b"
:
"_a"
;
console
.
add
(
"- Target slot: "
+
target
);
srcBoot
=
ShellUtils
.
fastCmd
(
"SLOT="
+
target
,
...
...
@@ -122,6 +129,12 @@ public abstract class MagiskInstaller {
console
.
add
(
"- Device platform: "
+
Build
.
CPU_ABI
);
File
zip
=
new
File
(
App
.
self
.
getCacheDir
(),
"magisk.zip"
);
if
(
preDownloadedFile
!=
null
)
{
console
.
add
(
"- Using already downloaded file"
);
InstallerHelper
.
copyFileTo
(
preDownloadedFile
,
zip
);
}
else
{
console
.
add
(
"- Using legacy download method"
);
if
(!
ShellUtils
.
checkSum
(
"MD5"
,
zip
,
Info
.
remote
.
getMagisk
().
getHash
()))
{
console
.
add
(
"- Downloading zip"
);
...
...
@@ -131,6 +144,7 @@ public abstract class MagiskInstaller {
}
else
{
console
.
add
(
"- Existing zip found"
);
}
}
try
{
ZipInputStream
zi
=
new
ZipInputStream
(
new
BufferedInputStream
(
...
...
@@ -151,7 +165,7 @@ public abstract class MagiskInstaller {
name
=
ze
.
getName
();
if
(
name
==
null
)
continue
;
File
dest
=
(
installDir
instanceof
SuFile
)
?
File
dest
=
installDir
instanceof
SuFile
?
new
SuFile
(
installDir
,
name
)
:
new
File
(
installDir
,
name
);
dest
.
getParentFile
().
mkdirs
();
...
...
app/src/main/java/com/topjohnwu/magisk/ui/flash/FlashViewModel.kt
View file @
6a0f6ab3
...
...
@@ -28,7 +28,7 @@ import java.util.*
class
FlashViewModel
(
action
:
String
,
file
:
Uri
,
installer
:
Uri
,
uri
:
Uri
,
private
val
resources
:
Resources
)
:
MagiskViewModel
(),
FlashResultListener
{
...
...
@@ -55,19 +55,19 @@ class FlashViewModel(
when
(
action
)
{
Const
.
Value
.
FLASH_ZIP
->
Flashing
.
Install
(
uri
,
outItems
,
logItems
,
this
)
.
Install
(
installer
,
outItems
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
UNINSTALL
->
Flashing
.
Uninstall
(
uri
,
outItems
,
logItems
,
this
)
.
Uninstall
(
installer
,
outItems
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
FLASH_MAGISK
->
Patching
.
Direct
(
outItems
,
logItems
,
this
)
.
Direct
(
installer
,
outItems
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
FLASH_INACTIVE_SLOT
->
Patching
.
SecondSlot
(
outItems
,
logItems
,
this
)
.
SecondSlot
(
installer
,
outItems
,
logItems
,
this
)
.
exec
()
Const
.
Value
.
PATCH_FILE
->
Patching
.
File
(
uri
,
outItems
,
logItems
,
this
)
.
File
(
installer
,
uri
,
outItems
,
logItems
,
this
)
.
exec
()
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment