mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-04 19:10:47 -05:00
app: inject prebuilt bootctl into jniLibs
Download updated multi-arch prebuilt bootctl binaries built from Android 14 (android-14.0.0_r1) and package them into jniLibs alongside busybox instead of bundling a single binary in assets. The new bootctl binaries support AIDL Boot HAL implementations on Android 14+ (API 31+), fixing OTA slot switching issues on newer devices like Pixels. Update post-OTA install logic in the app and shell scripts to use the native bootctl executable from MAGISKBIN. Fixes #8824
This commit is contained in:
+2
-3
@@ -11,9 +11,8 @@
|
|||||||
*.bat text eol=crlf
|
*.bat text eol=crlf
|
||||||
|
|
||||||
# Denote all files that are truly binary and should not be modified.
|
# Denote all files that are truly binary and should not be modified.
|
||||||
tools/** binary
|
/tools/keys/** binary
|
||||||
tools/rustup-wrapper/** -binary
|
/tools/keys/futility binary
|
||||||
tools/elf-cleaner/** -binary
|
|
||||||
*.jar binary
|
*.jar binary
|
||||||
*.exe binary
|
*.exe binary
|
||||||
*.apk binary
|
*.apk binary
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ const val BUSYBOX_DOWNLOAD_URL =
|
|||||||
const val BUSYBOX_ZIP_CHECKSUM =
|
const val BUSYBOX_ZIP_CHECKSUM =
|
||||||
"b4d0551feabaf314e53c79316c980e8f66432e9fb91a69dbbf10a93564b40951"
|
"b4d0551feabaf314e53c79316c980e8f66432e9fb91a69dbbf10a93564b40951"
|
||||||
|
|
||||||
|
const val BOOTCTL_DOWNLOAD_URL =
|
||||||
|
"https://github.com/topjohnwu/magisk-files/releases/download/files/bootctl-android-14.0.0_r1.zip"
|
||||||
|
const val BOOTCTL_ZIP_CHECKSUM =
|
||||||
|
"2cf515aeb17259e88393a1322671ebab1968925864bc04ae57dad54e53ccf15b"
|
||||||
|
|
||||||
private abstract class SyncWithDir : Sync() {
|
private abstract class SyncWithDir : Sync() {
|
||||||
@get:OutputDirectory
|
@get:OutputDirectory
|
||||||
abstract val outputFolder: DirectoryProperty
|
abstract val outputFolder: DirectoryProperty
|
||||||
@@ -133,8 +138,10 @@ fun Project.setupCoreLib() {
|
|||||||
}
|
}
|
||||||
from(zipTree(downloadFile(BUSYBOX_DOWNLOAD_URL, BUSYBOX_ZIP_CHECKSUM)))
|
from(zipTree(downloadFile(BUSYBOX_DOWNLOAD_URL, BUSYBOX_ZIP_CHECKSUM)))
|
||||||
include(abiList.map { "$it/libbusybox.so" })
|
include(abiList.map { "$it/libbusybox.so" })
|
||||||
|
from(zipTree(downloadFile(BOOTCTL_DOWNLOAD_URL, BOOTCTL_ZIP_CHECKSUM)))
|
||||||
|
include(abiList.map { "$it/libbootctl.so" })
|
||||||
onlyIf {
|
onlyIf {
|
||||||
if (inputs.sourceFiles.files.size != abiList.size * 6)
|
if (inputs.sourceFiles.files.size != abiList.size * 7)
|
||||||
throw StopExecutionException("Please build binaries first! (./build.py binary)")
|
throw StopExecutionException("Please build binaries first! (./build.py binary)")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -169,7 +176,6 @@ fun Project.setupCoreLib() {
|
|||||||
include("util_functions.sh", "boot_patch.sh", "addon.d.sh",
|
include("util_functions.sh", "boot_patch.sh", "addon.d.sh",
|
||||||
"app_functions.sh", "uninstaller.sh", "module_installer.sh")
|
"app_functions.sh", "uninstaller.sh", "module_installer.sh")
|
||||||
}
|
}
|
||||||
from(rootFile("tools/bootctl"))
|
|
||||||
into("chromeos") {
|
into("chromeos") {
|
||||||
from(rootFile("tools/futility"))
|
from(rootFile("tools/futility"))
|
||||||
from(rootFile("tools/keys")) {
|
from(rootFile("tools/keys")) {
|
||||||
|
|||||||
@@ -502,16 +502,8 @@ abstract class MagiskInstallImpl protected constructor(
|
|||||||
|
|
||||||
private fun flashBoot() = "direct_install $installDir $srcBoot".sh().isSuccess
|
private fun flashBoot() = "direct_install $installDir $srcBoot".sh().isSuccess
|
||||||
|
|
||||||
private suspend fun postOTA(): Boolean {
|
private fun postOTA(): Boolean {
|
||||||
try {
|
"post_ota".sh()
|
||||||
val bootctl = File.createTempFile("bootctl", null, context.cacheDir)
|
|
||||||
context.assets.open("bootctl").writeTo(bootctl)
|
|
||||||
"post_ota $bootctl".sh()
|
|
||||||
} catch (e: IOException) {
|
|
||||||
console.add("! Unable to download bootctl")
|
|
||||||
Timber.e(e)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
console.add("*************************************************************")
|
console.add("*************************************************************")
|
||||||
console.add(" Next reboot will boot to second slot!")
|
console.add(" Next reboot will boot to second slot!")
|
||||||
|
|||||||
@@ -96,11 +96,10 @@ restore_imgs() {
|
|||||||
flash_image $BACKUPDIR/boot.img.gz $1
|
flash_image $BACKUPDIR/boot.img.gz $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# $1 = path to bootctl executable
|
|
||||||
post_ota() {
|
post_ota() {
|
||||||
cd /data/adb
|
cd /data/adb
|
||||||
cp -f $1 bootctl
|
cp -f $MAGISKBIN/bootctl bootctl
|
||||||
rm -f $1
|
rm -f $MAGISKBIN/bootctl
|
||||||
chmod 755 bootctl
|
chmod 755 bootctl
|
||||||
if ! ./bootctl hal-info; then
|
if ! ./bootctl hal-info; then
|
||||||
rm -f bootctl
|
rm -f bootctl
|
||||||
|
|||||||
Binary file not shown.
+44
-9
@@ -1,32 +1,67 @@
|
|||||||
# How to build the bootctl bundled within the Magisk app:
|
##################################################################################
|
||||||
|
# How to build the prebuilt bootctl executable:
|
||||||
#
|
#
|
||||||
# 1. Checkout and sync the AOSP tree:
|
# 1. Checkout and sync the AOSP tree with the tag android-14.0.0_r1:
|
||||||
# https://source.android.com/setup/build/downloading
|
# https://source.android.com/setup/build/downloading
|
||||||
# 2. Build for arm64:
|
# 2. Apply patches:
|
||||||
# lunch aosp_arm64-eng
|
# `patch -p1 -d system/extras -i bootctl.patch`
|
||||||
# 3. Apply patches:
|
# 3. Build for arm, arm64, x86, and x86_64:
|
||||||
# cd system/extras; patch -p1 < bootctl.patch
|
# `lunch aosp_<abi>-eng`
|
||||||
# 4. Build the executable:
|
# 4. Build the executable:
|
||||||
# m bootctl
|
# `m bootctl`
|
||||||
|
#
|
||||||
|
# Despite built from the Android 14 branch, the executable is usable on API 31+.
|
||||||
|
##################################################################################
|
||||||
|
|
||||||
diff --git a/bootctl/Android.bp b/bootctl/Android.bp
|
diff --git a/bootctl/Android.bp b/bootctl/Android.bp
|
||||||
index f63871cf..8a551bbe 100644
|
index 106ff863..0e139989 100644
|
||||||
--- a/bootctl/Android.bp
|
--- a/bootctl/Android.bp
|
||||||
+++ b/bootctl/Android.bp
|
+++ b/bootctl/Android.bp
|
||||||
@@ -26,11 +26,15 @@ cc_binary {
|
@@ -26,13 +26,23 @@ cc_binary {
|
||||||
"-Werror",
|
"-Werror",
|
||||||
],
|
],
|
||||||
|
|
||||||
- shared_libs: [
|
- shared_libs: [
|
||||||
|
+ ldflags: [
|
||||||
|
+ "-Wl,-z,max-page-size=16384",
|
||||||
|
+ ],
|
||||||
|
+
|
||||||
+ static_libs: [
|
+ static_libs: [
|
||||||
"android.hardware.boot@1.0",
|
"android.hardware.boot@1.0",
|
||||||
"android.hardware.boot@1.1",
|
"android.hardware.boot@1.1",
|
||||||
"android.hardware.boot@1.2",
|
"android.hardware.boot@1.2",
|
||||||
|
"android.hardware.boot-V1-ndk",
|
||||||
|
"libboot_control_client",
|
||||||
+ ],
|
+ ],
|
||||||
+ shared_libs: [
|
+ shared_libs: [
|
||||||
"libhidlbase",
|
"libhidlbase",
|
||||||
"libutils",
|
"libutils",
|
||||||
|
+ "libbase",
|
||||||
+ "libcutils",
|
+ "libcutils",
|
||||||
+ "liblog",
|
+ "liblog",
|
||||||
|
+ "libbinder_ndk",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
diff --git a/bootctl/bootctl.cpp b/bootctl/bootctl.cpp
|
||||||
|
index 1bf91815..e9c2d7bb 100644
|
||||||
|
--- a/bootctl/bootctl.cpp
|
||||||
|
+++ b/bootctl/bootctl.cpp
|
||||||
|
@@ -174,7 +174,9 @@ static int do_set_snapshot_merge_status(BootControlClient* module, BootControlVe
|
||||||
|
return handle_return(ret, "Failed to set snapshot merge status: %s\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
-std::ostream& operator<<(std::ostream& os, MergeStatus state) {
|
||||||
|
+std::ostream& operator<<(std::ostream& os, MergeStatus state);
|
||||||
|
+#if 0
|
||||||
|
+{
|
||||||
|
switch (state) {
|
||||||
|
case MergeStatus::CANCELLED:
|
||||||
|
return os << "cancelled";
|
||||||
|
@@ -190,6 +192,7 @@ std::ostream& operator<<(std::ostream& os, MergeStatus state) {
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
static int do_get_snapshot_merge_status(BootControlClient* module) {
|
||||||
|
MergeStatus ret = module->getSnapshotMergeStatus();
|
||||||
|
|||||||
Reference in New Issue
Block a user