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
07140d33
Commit
07140d33
authored
Jul 20, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bring back installing to second slot after OTA on A/B devices
parent
4ffc3884
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
11 deletions
+49
-11
InstallMagisk.java
.../full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
+29
-7
ShowUI.java
app/src/full/java/com/topjohnwu/magisk/utils/ShowUI.java
+5
-0
bootctl
app/src/full/res/raw/bootctl
+0
-0
utils.sh
app/src/full/res/raw/utils.sh
+15
-4
No files found.
app/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java
View file @
07140d33
...
@@ -17,7 +17,9 @@ import com.topjohnwu.magisk.utils.Utils;
...
@@ -17,7 +17,9 @@ import com.topjohnwu.magisk.utils.Utils;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.magisk.utils.ZipUtils
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.ShellUtils
;
import
com.topjohnwu.superuser.io.SuFile
;
import
com.topjohnwu.superuser.io.SuFileInputStream
;
import
com.topjohnwu.superuser.io.SuFileInputStream
;
import
com.topjohnwu.superuser.io.SuFileOutputStream
;
import
com.topjohnwu.utils.SignBoot
;
import
com.topjohnwu.utils.SignBoot
;
import
org.kamranzafar.jtar.TarInputStream
;
import
org.kamranzafar.jtar.TarInputStream
;
...
@@ -214,6 +216,20 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -214,6 +216,20 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
}
}
}
}
private
void
postOTA
()
{
SuFile
bootctl
=
new
SuFile
(
Const
.
MAGISK_PATH
+
"/.core/bootctl"
);
try
(
InputStream
in
=
mm
.
getResources
().
openRawResource
(
R
.
raw
.
bootctl
);
OutputStream
out
=
new
SuFileOutputStream
(
bootctl
))
{
ShellUtils
.
pump
(
in
,
out
);
Shell
.
Sync
.
su
(
"post_ota "
+
bootctl
.
getParent
());
console
.
add
(
"***************************************"
);
console
.
add
(
" Next reboot will boot to second slot!"
);
console
.
add
(
"***************************************"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@Override
@Override
protected
Boolean
doInBackground
(
Void
...
voids
)
{
protected
Boolean
doInBackground
(
Void
...
voids
)
{
if
(
mode
==
FIX_ENV_MODE
)
{
if
(
mode
==
FIX_ENV_MODE
)
{
...
@@ -240,13 +256,16 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -240,13 +256,16 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
mBoot
=
ShellUtils
.
fastCmd
(
"find_boot_image"
,
"echo \"$BOOTIMAGE\""
);
mBoot
=
ShellUtils
.
fastCmd
(
"find_boot_image"
,
"echo \"$BOOTIMAGE\""
);
break
;
break
;
case
SECOND_SLOT_MODE:
case
SECOND_SLOT_MODE:
String
slot
=
ShellUtils
.
fastCmd
(
"echo $SLOT"
);
String
target
=
(
TextUtils
.
equals
(
slot
,
"_a"
)
?
"_b"
:
"_a"
);
console
.
add
(
"- Target slot: "
+
target
);
console
.
add
(
"- Detecting target image"
);
console
.
add
(
"- Detecting target image"
);
char
slot
[]
=
ShellUtils
.
fastCmd
(
"echo $SLOT"
).
toCharArray
();
mBoot
=
ShellUtils
.
fastCmd
(
if
(
slot
[
1
]
==
'a'
)
slot
[
1
]
=
'b'
;
"SLOT="
+
target
,
else
slot
[
1
]
=
'a'
;
"find_boot_image"
,
mBoot
=
ShellUtils
.
fastCmd
(
"SLOT="
+
String
.
valueOf
(
slot
)
,
"SLOT="
+
slot
,
"
find_boot_image"
,
"echo \"$BOOTIMAGE\""
);
"
echo \"$BOOTIMAGE\""
Shell
.
Async
.
su
(
"mount_partitions"
);
);
break
;
break
;
case
FIX_ENV_MODE:
case
FIX_ENV_MODE:
mBoot
=
""
;
mBoot
=
""
;
...
@@ -257,7 +276,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -257,7 +276,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
return
false
;
return
false
;
}
}
console
.
add
(
"- Target image: "
+
mBoot
);
if
(
mode
==
DIRECT_MODE
||
mode
==
SECOND_SLOT_MODE
)
console
.
add
(
"- Target image: "
+
mBoot
);
List
<
String
>
abis
=
Arrays
.
asList
(
Build
.
SUPPORTED_ABIS
);
List
<
String
>
abis
=
Arrays
.
asList
(
Build
.
SUPPORTED_ABIS
);
String
arch
;
String
arch
;
...
@@ -284,6 +304,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
...
@@ -284,6 +304,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
if
(
patched
==
null
)
if
(
patched
==
null
)
return
false
;
return
false
;
outputBoot
(
patched
);
outputBoot
(
patched
);
if
(
mode
==
SECOND_SLOT_MODE
)
postOTA
();
console
.
add
(
"- All done!"
);
console
.
add
(
"- All done!"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
app/src/full/java/com/topjohnwu/magisk/utils/ShowUI.java
View file @
07140d33
...
@@ -26,6 +26,7 @@ import com.topjohnwu.magisk.receivers.DownloadReceiver;
...
@@ -26,6 +26,7 @@ import com.topjohnwu.magisk.receivers.DownloadReceiver;
import
com.topjohnwu.magisk.receivers.ManagerUpdate
;
import
com.topjohnwu.magisk.receivers.ManagerUpdate
;
import
com.topjohnwu.magisk.receivers.RebootReceiver
;
import
com.topjohnwu.magisk.receivers.RebootReceiver
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.Shell
;
import
com.topjohnwu.superuser.ShellUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -134,6 +135,10 @@ public class ShowUI {
...
@@ -134,6 +135,10 @@ public class ShowUI {
if
(
Shell
.
rootAccess
())
{
if
(
Shell
.
rootAccess
())
{
options
.
add
(
mm
.
getString
(
R
.
string
.
direct_install
));
options
.
add
(
mm
.
getString
(
R
.
string
.
direct_install
));
}
}
String
s
=
ShellUtils
.
fastCmd
(
"grep_prop ro.build.ab_update"
);
if
(
s
!=
null
&&
Boolean
.
parseBoolean
(
s
))
{
options
.
add
(
mm
.
getString
(
R
.
string
.
install_second_slot
));
}
new
AlertDialog
.
Builder
(
activity
)
new
AlertDialog
.
Builder
(
activity
)
.
setTitle
(
R
.
string
.
select_method
)
.
setTitle
(
R
.
string
.
select_method
)
.
setItems
(
.
setItems
(
...
...
app/src/full/res/raw/bootctl
0 → 100644
View file @
07140d33
File added
app/src/full/res/raw/utils.sh
View file @
07140d33
...
@@ -73,11 +73,11 @@ mm_patch_dtbo() {
...
@@ -73,11 +73,11 @@ mm_patch_dtbo() {
}
}
restore_imgs
()
{
restore_imgs
()
{
SHA1
=
`
cat
/.backup/.sha1
`
local
SHA1
=
`
cat
/.backup/.sha1
`
[
-z
$SHA1
]
&&
SHA1
=
`
grep_prop
#STOCKSHA1`
[
-z
$SHA1
]
&&
local
SHA1
=
`
grep_prop
#STOCKSHA1`
[
-z
$SHA1
]
&&
return
1
[
-z
$SHA1
]
&&
return
1
STOCKBOOT
=
/data/stock_boot_
${
SHA1
}
.img.gz
local
STOCKBOOT
=
/data/stock_boot_
${
SHA1
}
.img.gz
STOCKDTBO
=
/data/stock_dtbo.img.gz
local
STOCKDTBO
=
/data/stock_dtbo.img.gz
[
-f
$STOCKBOOT
]
||
return
1
[
-f
$STOCKBOOT
]
||
return
1
find_boot_image
find_boot_image
...
@@ -93,3 +93,14 @@ restore_imgs() {
...
@@ -93,3 +93,14 @@ restore_imgs() {
fi
fi
return
1
return
1
}
}
post_ota
()
{
cd
$1
chmod
755 bootctl
./bootctl hal-info
||
return
[
`
./bootctl get-current-slot
`
-eq
0
]
&&
SLOT_NUM
=
1
||
SLOT_NUM
=
0
./bootctl set-active-boot-slot
$SLOT_NUM
echo
'${0%/*}/../bootctl mark-boot-successful;rm -f ${0%/*}/../bootctl $0'
>
post-fs-data.d/post_ota.sh
chmod
755 post-fs-data.d/post_ota.sh
cd
/
}
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