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
c562cbc2
Commit
c562cbc2
authored
Sep 26, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update zip and magisk installation
parent
3fbbb086
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
22 deletions
+17
-22
FlashZip.java
app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java
+12
-16
InstallMagisk.java
.../main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+4
-5
RestoreStockBoot.java
...in/java/com/topjohnwu/magisk/asyncs/RestoreStockBoot.java
+1
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/asyncs/FlashZip.java
View file @
c562cbc2
...
...
@@ -10,6 +10,8 @@ import com.topjohnwu.magisk.utils.AdaptiveList;
import
com.topjohnwu.magisk.utils.Utils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedOutputStream
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
...
...
@@ -21,27 +23,19 @@ import java.util.List;
public
class
FlashZip
extends
ParallelTask
<
Void
,
Void
,
Integer
>
{
private
Uri
mUri
;
private
File
mCachedFile
,
mScriptFile
,
mCheckFile
;
private
String
mFilename
;
private
File
mCachedFile
;
private
AdaptiveList
<
String
>
mList
;
public
FlashZip
(
Activity
context
,
Uri
uri
,
AdaptiveList
<
String
>
list
)
{
super
(
context
);
mUri
=
uri
;
mList
=
list
;
mCachedFile
=
new
File
(
context
.
getCacheDir
(),
"install.zip"
);
mScriptFile
=
new
File
(
context
.
getCacheDir
(),
"/META-INF/com/google/android/update-binary"
);
mCheckFile
=
new
File
(
mScriptFile
.
getParent
(),
"updater-script"
);
// Try to get the filename ourselves
mFilename
=
Utils
.
getNameFromUri
(
context
,
mUri
);
}
private
boolean
unzipAndCheck
()
throws
Exception
{
ZipUtils
.
unzip
(
mCachedFile
,
mCachedFile
.
getParentFile
(),
"META-INF/com/google/android"
,
fals
e
);
List
<
String
>
ret
=
Utils
.
readFile
(
getShell
(),
mCheckFile
.
getPath
());
ZipUtils
.
unzip
(
mCachedFile
,
mCachedFile
.
getParentFile
(),
"META-INF/com/google/android"
,
tru
e
);
List
<
String
>
ret
=
Utils
.
readFile
(
getShell
(),
new
File
(
mCachedFile
.
getParentFile
(),
"updater-script"
)
.
getPath
());
return
Utils
.
isValidShellResponse
(
ret
)
&&
ret
.
get
(
0
).
contains
(
"#MAGISK"
);
}
...
...
@@ -66,12 +60,13 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
mCachedFile
.
delete
();
try
(
InputStream
in
=
mm
.
getContentResolver
().
openInputStream
(
mUri
);
OutputStream
out
=
new
FileOutputStream
(
mCachedFile
)
OutputStream
out
=
new
BufferedOutputStream
(
new
FileOutputStream
(
mCachedFile
)
)
)
{
if
(
in
==
null
)
throw
new
FileNotFoundException
();
byte
buffer
[]
=
new
byte
[
1024
];
InputStream
buf
=
new
BufferedInputStream
(
in
);
byte
buffer
[]
=
new
byte
[
4096
];
int
length
;
while
((
length
=
in
.
read
(
buffer
))
>
0
)
while
((
length
=
buf
.
read
(
buffer
))
>
0
)
out
.
write
(
buffer
,
0
,
length
);
}
catch
(
FileNotFoundException
e
)
{
mList
.
add
(
"! Invalid Uri"
);
...
...
@@ -81,9 +76,10 @@ public class FlashZip extends ParallelTask<Void, Void, Integer> {
throw
e
;
}
if
(!
unzipAndCheck
())
return
0
;
mList
.
add
(
"- Installing "
+
mFilename
);
mList
.
add
(
"- Installing "
+
Utils
.
getNameFromUri
(
mm
,
mUri
)
);
getShell
().
su
(
mList
,
"BOOTMODE=true sh "
+
mScriptFile
+
" dummy 1 "
+
mCachedFile
+
"cd "
+
mCachedFile
.
getParent
(),
"BOOTMODE=true sh update-binary dummy 1 "
+
mCachedFile
+
" && echo 'Success!' || echo 'Failed!'"
);
if
(
TextUtils
.
equals
(
mList
.
get
(
mList
.
size
()
-
1
),
"Success!"
))
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
c562cbc2
...
...
@@ -114,8 +114,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
boot
=
new
File
(
install
,
"boot.img"
);
// Copy boot image to local
try
(
InputStream
in
=
mm
.
getContentResolver
().
openInputStream
(
mBootImg
);
OutputStream
out
=
new
FileOutputStream
(
boot
)
InputStream
in
=
mm
.
getContentResolver
().
openInputStream
(
mBootImg
);
OutputStream
out
=
new
FileOutputStream
(
boot
)
)
{
InputStream
source
;
if
(
in
==
null
)
throw
new
FileNotFoundException
();
...
...
@@ -131,7 +131,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
source
=
tar
;
}
else
{
// Direct copy raw image
source
=
in
;
source
=
new
BufferedInputStream
(
in
)
;
}
byte
buffer
[]
=
new
byte
[
1024
];
int
length
;
...
...
@@ -204,8 +204,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
break
;
case
DIRECT_MODE:
// Direct flash boot image
getShell
().
su_raw
(
"cat "
+
patched_boot
+
" /dev/zero | dd of="
+
mBootLocation
+
" bs=4096"
);
mList
.
add
(
"Flashing patched boot to "
+
mBootLocation
);
getShell
().
su
(
mList
,
"flash_boot_image "
+
patched_boot
+
" "
+
mBootLocation
);
break
;
default
:
return
false
;
...
...
app/src/main/java/com/topjohnwu/magisk/asyncs/RestoreStockBoot.java
View file @
c562cbc2
...
...
@@ -25,7 +25,7 @@ public class RestoreStockBoot extends ParallelTask<Void, Void, Boolean> {
String
stock_boot
=
"/data/stock_boot_"
+
ret
.
get
(
0
).
substring
(
ret
.
get
(
0
).
indexOf
(
'='
)
+
1
)
+
".img.gz"
;
if
(!
Utils
.
itemExist
(
getShell
(),
stock_boot
))
return
false
;
getShell
().
su_raw
(
"
gzip -d < "
+
stock_boot
+
" | cat - /dev/zero | dd of="
+
mBoot
+
" bs=4096"
);
getShell
().
su_raw
(
"
flash_boot_image "
+
stock_boot
+
" "
+
mBoot
);
return
true
;
}
...
...
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