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
cf58545a
Commit
cf58545a
authored
Jul 04, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move shell code into scripts
parent
e86015ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
25 deletions
+34
-25
InstallMagisk.java
src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+15
-25
utils.sh
src/full/res/raw/utils.sh
+19
-0
No files found.
src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
cf58545a
...
...
@@ -104,7 +104,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
}
private
boolean
dumpBoot
()
{
console
.
add
(
"- Copying
boot image to "
+
mBoot
);
console
.
add
(
"- Copying
image locally"
);
// Copy boot image to local
try
(
InputStream
in
=
mm
.
getContentResolver
().
openInputStream
(
bootUri
);
OutputStream
out
=
new
FileOutputStream
(
mBoot
)
...
...
@@ -197,31 +197,28 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
ShellUtils
.
pump
(
in
,
out
);
out
.
close
();
}
Shell
.
Sync
.
su
(
"rm -f "
+
patched
);
console
.
add
(
""
);
console
.
add
(
"****************************
*****
"
);
console
.
add
(
" Patched
Boot I
mage is placed in "
);
console
.
add
(
"****************************"
);
console
.
add
(
" Patched
i
mage is placed in "
);
console
.
add
(
" "
+
dest
+
" "
);
console
.
add
(
"****************************
*****
"
);
console
.
add
(
"****************************"
);
break
;
case
SECOND_SLOT_MODE:
case
DIRECT_MODE:
String
binPath
=
mm
.
remoteMagiskVersionCode
>=
Const
.
MAGISK_VER
.
HIDDEN_PATH
?
"/data/adb/magisk"
:
"/data/magisk"
;
Shell
.
Sync
.
su
(
console
,
logs
,
Utils
.
fmt
(
"flash_boot_image %s %s; rm -f %s"
,
patched
,
mBoot
,
patched
),
Utils
.
fmt
(
"rm -rf %s/*; mkdir -p %s; chmod 700 /data/adb"
,
binPath
,
binPath
),
Utils
.
fmt
(
"cp -af %s/* %s; rm -rf %s"
,
installDir
,
binPath
,
installDir
),
mm
.
keepVerity
?
""
:
"patch_dtbo_image"
);
Shell
.
Sync
.
sh
(
console
,
logs
,
Utils
.
fmt
(
"direct_install %s %s %s"
,
patched
,
mBoot
,
installDir
));
if
(!
mm
.
keepVerity
)
Shell
.
Sync
.
sh
(
console
,
logs
,
"find_dtbo_image"
,
"patch_dtbo_image"
);
break
;
}
Shell
.
Sync
.
su
(
"rm -f "
+
patched
);
}
@Override
protected
Boolean
doInBackground
(
Void
...
voids
)
{
if
(
mode
==
FIX_ENV_MODE
)
{
installDir
=
new
File
(
"/data/adb/magisk"
);
Shell
.
Sync
.
sh
(
"rm -rf
"
+
installDir
+
"
/*"
);
Shell
.
Sync
.
sh
(
"rm -rf
/data/adb/magisk
/*"
);
}
else
{
installDir
=
new
File
(
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
?
...
...
@@ -239,11 +236,11 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
return
false
;
break
;
case
DIRECT_MODE:
console
.
add
(
"- Detecting
ramdisk/boo
t image"
);
console
.
add
(
"- Detecting
targe
t image"
);
mBoot
=
ShellUtils
.
fastCmd
(
"find_boot_image"
,
"echo \"$BOOTIMAGE\""
);
break
;
case
SECOND_SLOT_MODE:
console
.
add
(
"- Detecting
ramdisk/boo
t image"
);
console
.
add
(
"- Detecting
targe
t image"
);
char
slot
[]
=
ShellUtils
.
fastCmd
(
"echo $SLOT"
).
toCharArray
();
if
(
slot
[
1
]
==
'a'
)
slot
[
1
]
=
'b'
;
else
slot
[
1
]
=
'a'
;
...
...
@@ -253,11 +250,11 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
break
;
}
if
(
mBoot
==
null
)
{
console
.
add
(
"
- Unable to detect ramdisk/boo
t image"
);
console
.
add
(
"
! Unable to detect targe
t image"
);
return
false
;
}
console
.
add
(
"-
Use ramdisk/boo
t image: "
+
mBoot
);
console
.
add
(
"-
Targe
t image: "
+
mBoot
);
List
<
String
>
abis
=
Arrays
.
asList
(
Build
.
SUPPORTED_ABIS
);
String
arch
;
...
...
@@ -278,14 +275,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
try
{
extractFiles
(
arch
);
if
(
mode
==
FIX_ENV_MODE
)
{
Shell
.
Sync
.
sh
(
"cd "
+
installDir
,
"sh update-binary extract"
,
"rm -f update-binary magisk.apk"
,
"cd /"
,
"rm -rf /sbin/.core/busybox/*"
,
"/sbin/.core/mirror/bin/busybox --install -s /sbin/.core/busybox"
);
Shell
.
Sync
.
sh
(
"fix_env"
);
}
else
{
File
patched
=
patchBoot
();
if
(
patched
==
null
)
...
...
src/full/res/raw/utils.sh
View file @
cf58545a
...
...
@@ -44,6 +44,25 @@ env_check() {
return
0
}
fix_env
()
{
cd
/data/adb/magisk
sh update-binary extract
rm
-f
update-binary magisk.apk
cd
/
rm
-rf
/sbin/.core/busybox/
*
/sbin/.core/mirror/bin/busybox
--install
-s
/sbin/.core/busybox
}
direct_install
()
{
flash_boot_image
$1
$2
rm
-f
$1
rm
-rf
/data/adb/magisk/
*
2>/dev/null
mkdir
-p
/data/adb/magisk 2>/dev/null
chmod
700 /data/adb
cp
-f
$3
/
*
/data/adb/magisk
rm
-rf
$3
}
mm_patch_dtbo
()
{
if
$KEEPVERITY
;
then
echo false
...
...
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