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
746a1d8d
Commit
746a1d8d
authored
Jul 20, 2019
by
topjohnwu
Committed by
John Wu
Jul 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Directly download to magisk.zip for flashing
parent
63c5e00d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
51 deletions
+17
-51
DownloadSubject.kt
...topjohnwu/magisk/model/entity/internal/DownloadSubject.kt
+5
-1
Patching.kt
...rc/main/java/com/topjohnwu/magisk/model/flash/Patching.kt
+1
-1
MagiskInstaller.java
...main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
+6
-49
EnvFixDialog.kt
...in/java/com/topjohnwu/magisk/view/dialogs/EnvFixDialog.kt
+5
-0
No files found.
app/src/main/java/com/topjohnwu/magisk/model/entity/internal/DownloadSubject.kt
View file @
746a1d8d
...
@@ -31,7 +31,11 @@ sealed class DownloadSubject : Parcelable {
...
@@ -31,7 +31,11 @@ sealed class DownloadSubject : Parcelable {
)
:
DownloadSubject
()
{
)
:
DownloadSubject
()
{
override
val
url
:
String
get
()
=
magisk
.
link
override
val
url
:
String
get
()
=
magisk
.
link
override
val
fileName
get
()
=
"Magisk-v${magisk.version}(${magisk.versionCode}).zip"
override
val
fileName
get
()
=
if
(
configuration
is
Configuration
.
Flash
)
"magisk.zip"
else
"Magisk-v${magisk.version}(${magisk.versionCode}).zip"
}
}
...
...
app/src/main/java/com/topjohnwu/magisk/model/flash/Patching.kt
View file @
746a1d8d
...
@@ -9,7 +9,7 @@ sealed class Patching(
...
@@ -9,7 +9,7 @@ sealed class Patching(
private
val
console
:
MutableList
<
String
>,
private
val
console
:
MutableList
<
String
>,
logs
:
MutableList
<
String
>,
logs
:
MutableList
<
String
>,
private
val
resultListener
:
FlashResultListener
private
val
resultListener
:
FlashResultListener
)
:
MagiskInstaller
(
console
,
logs
,
file
)
{
)
:
MagiskInstaller
(
console
,
logs
)
{
override
fun
onResult
(
success
:
Boolean
)
{
override
fun
onResult
(
success
:
Boolean
)
{
if
(
success
)
{
if
(
success
)
{
...
...
app/src/main/java/com/topjohnwu/magisk/tasks/MagiskInstaller.java
View file @
746a1d8d
...
@@ -4,11 +4,13 @@ import android.net.Uri;
...
@@ -4,11 +4,13 @@ import android.net.Uri;
import
android.os.Build
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
androidx.annotation.MainThread
;
import
androidx.annotation.WorkerThread
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Info
;
import
com.topjohnwu.magisk.Info
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.net.DownloadProgressListener
;
import
com.topjohnwu.net.Networking
;
import
com.topjohnwu.net.Networking
;
import
com.topjohnwu.signing.SignBoot
;
import
com.topjohnwu.signing.SignBoot
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
...
@@ -38,55 +40,28 @@ import java.util.List;
...
@@ -38,55 +40,28 @@ import java.util.List;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
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
{
public
abstract
class
MagiskInstaller
{
protected
String
srcBoot
;
protected
String
srcBoot
;
protected
File
destFile
;
protected
File
destFile
;
protected
File
installDir
;
protected
File
installDir
;
protected
File
zipFile
=
new
File
(
App
.
self
.
getCacheDir
(),
"magisk.zip"
);
@Nullable
private
final
Uri
preDownloadedFile
;
private
final
List
<
String
>
console
;
private
final
List
<
String
>
console
;
private
final
List
<
String
>
logs
;
private
final
List
<
String
>
logs
;
private
boolean
isTar
=
false
;
private
boolean
isTar
=
false
;
private
class
ProgressLog
implements
DownloadProgressListener
{
private
int
prev
=
-
1
;
private
int
location
;
@Override
public
void
onProgress
(
long
bytesDownloaded
,
long
totalBytes
)
{
if
(
prev
<
0
)
{
location
=
console
.
size
();
console
.
add
(
"... 0%"
);
}
int
curr
=
(
int
)
(
100
*
bytesDownloaded
/
totalBytes
);
if
(
prev
!=
curr
)
{
prev
=
curr
;
console
.
set
(
location
,
"... "
+
prev
+
"%"
);
}
}
}
protected
MagiskInstaller
()
{
protected
MagiskInstaller
()
{
console
=
NOPList
.
getInstance
();
console
=
NOPList
.
getInstance
();
logs
=
NOPList
.
getInstance
();
logs
=
NOPList
.
getInstance
();
preDownloadedFile
=
null
;
}
}
public
MagiskInstaller
(
List
<
String
>
out
,
List
<
String
>
err
,
@NonNull
Uri
magisk
)
{
public
MagiskInstaller
(
List
<
String
>
out
,
List
<
String
>
err
)
{
console
=
out
;
console
=
out
;
logs
=
err
;
logs
=
err
;
installDir
=
new
File
(
App
.
deContext
.
getFilesDir
().
getParent
(),
"install"
);
installDir
=
new
File
(
App
.
deContext
.
getFilesDir
().
getParent
(),
"install"
);
Shell
.
sh
(
"rm -rf "
+
installDir
).
exec
();
Shell
.
sh
(
"rm -rf "
+
installDir
).
exec
();
installDir
.
mkdirs
();
installDir
.
mkdirs
();
preDownloadedFile
=
magisk
;
}
}
protected
boolean
findImage
()
{
protected
boolean
findImage
()
{
...
@@ -128,27 +103,9 @@ public abstract class MagiskInstaller {
...
@@ -128,27 +103,9 @@ public abstract class MagiskInstaller {
console
.
add
(
"- Device platform: "
+
Build
.
CPU_ABI
);
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"
);
Networking
.
get
(
Info
.
remote
.
getMagisk
().
getLink
())
.
setDownloadProgressListener
(
new
ProgressLog
())
.
execForFile
(
zip
);
}
else
{
console
.
add
(
"- Existing zip found"
);
}
}
try
{
try
{
ZipInputStream
zi
=
new
ZipInputStream
(
new
BufferedInputStream
(
ZipInputStream
zi
=
new
ZipInputStream
(
new
BufferedInputStream
(
new
FileInputStream
(
zip
),
(
int
)
zip
.
length
()));
new
FileInputStream
(
zip
File
),
(
int
)
zipFile
.
length
()));
ZipEntry
ze
;
ZipEntry
ze
;
while
((
ze
=
zi
.
getNextEntry
())
!=
null
)
{
while
((
ze
=
zi
.
getNextEntry
())
!=
null
)
{
if
(
ze
.
isDirectory
())
if
(
ze
.
isDirectory
())
...
...
app/src/main/java/com/topjohnwu/magisk/view/dialogs/EnvFixDialog.kt
View file @
746a1d8d
...
@@ -3,11 +3,14 @@ package com.topjohnwu.magisk.view.dialogs
...
@@ -3,11 +3,14 @@ package com.topjohnwu.magisk.view.dialogs
import
android.app.Activity
import
android.app.Activity
import
android.app.ProgressDialog
import
android.app.ProgressDialog
import
android.widget.Toast
import
android.widget.Toast
import
com.topjohnwu.magisk.Info
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.tasks.MagiskInstaller
import
com.topjohnwu.magisk.tasks.MagiskInstaller
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.reboot
import
com.topjohnwu.magisk.utils.reboot
import
com.topjohnwu.net.Networking
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.ShellUtils
import
com.topjohnwu.superuser.internal.UiThreadHandler
import
com.topjohnwu.superuser.internal.UiThreadHandler
import
com.topjohnwu.superuser.io.SuFile
import
com.topjohnwu.superuser.io.SuFile
...
@@ -25,6 +28,8 @@ class EnvFixDialog(activity: Activity) : CustomAlertDialog(activity) {
...
@@ -25,6 +28,8 @@ class EnvFixDialog(activity: Activity) : CustomAlertDialog(activity) {
override
fun
operations
():
Boolean
{
override
fun
operations
():
Boolean
{
installDir
=
SuFile
(
"/data/adb/magisk"
)
installDir
=
SuFile
(
"/data/adb/magisk"
)
Shell
.
su
(
"rm -rf /data/adb/magisk/*"
).
exec
()
Shell
.
su
(
"rm -rf /data/adb/magisk/*"
).
exec
()
if
(!
ShellUtils
.
checkSum
(
"MD5"
,
zipFile
,
Info
.
remote
.
magisk
.
hash
))
Networking
.
get
(
Info
.
remote
.
magisk
.
link
).
execForFile
(
zipFile
)
return
extractZip
()
&&
Shell
.
su
(
"fix_env"
).
exec
().
isSuccess
return
extractZip
()
&&
Shell
.
su
(
"fix_env"
).
exec
().
isSuccess
}
}
...
...
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