Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Build bootctl and enable installation to inactive slot on Pixel devices #5134

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 0 additions & 3 deletions app/src/main/java/com/topjohnwu/magisk/core/Const.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ object Const {
const val TMPDIR = "/dev/tmp"
const val MAGISK_LOG = "/cache/magisk.log"

// Versions
const val BOOTCTL_REVISION = "22.0"

// Misc
val USER_ID = Process.myUid() / 100000
val APP_IS_CANARY get() = Version.isCanary(BuildConfig.VERSION_CODE)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/com/topjohnwu/magisk/core/Info.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ object Info {
@JvmStatic val isFDE get() = crypto == "block"
@JvmField var ramdisk = false
@JvmField var hasGMS = true
@JvmField val isPixel = Build.BRAND == "google"
@JvmField val isEmulator =
getProperty("ro.kernel.qemu", "0") == "1" ||
getProperty("ro.boot.qemu", "0") == "1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,7 @@ abstract class MagiskInstallImpl protected constructor(
private fun flashBoot() = "direct_install $installDir $srcBoot".sh().isSuccess

private suspend fun postOTA(): Boolean {
try {
val bootctl = File.createTempFile("bootctl", null, context.cacheDir)
service.fetchBootctl().byteStream().writeTo(bootctl)
"post_ota $bootctl".sh()
} catch (e: IOException) {
console.add("! Unable to download bootctl")
Timber.e(e)
if (!"post_ota".sh().isSuccess) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ interface GithubPageServices {

interface JSDelivrServices {

@GET("$MAGISK_FILES@{$REVISION}/bootctl")
@Streaming
suspend fun fetchBootctl(@Path(REVISION) revision: String = Const.BOOTCTL_REVISION): ResponseBody

@GET("$MAGISK_MAIN@{$REVISION}/scripts/module_installer.sh")
@Streaming
suspend fun fetchInstaller(@Path(REVISION) revision: String): ResponseBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class NetworkService(
}

// Fetch files
suspend fun fetchBootctl() = wrap { jsd.fetchBootctl() }
suspend fun fetchInstaller() = wrap {
val sha = fetchMainVersion()
jsd.fetchInstaller(sha)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InstallViewModel(

val isRooted = Shell.rootAccess()
val skipOptions = Info.isEmulator || (Info.ramdisk && !Info.isFDE && Info.isSAR)
val noSecondSlot = !isRooted || Info.isPixel || Info.isVirtualAB || !Info.isAB || Info.isEmulator
val noSecondSlot = !isRooted || Info.isVirtualAB || !Info.isAB || Info.isEmulator

@get:Bindable
var step = if (skipOptions) 1 else 0
Expand Down
14 changes: 5 additions & 9 deletions app/src/main/res/raw/manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,15 @@ restore_imgs() {
}

post_ota() {
cd $NVBASE
cp -f $1 bootctl
rm -f $1
chmod 755 bootctl
cd $NVBASE/magisk
./bootctl hal-info || return
[ $(./bootctl get-current-slot) -eq 0 ] && SLOT_NUM=1 || SLOT_NUM=0
./bootctl set-active-boot-slot $SLOT_NUM
cat << EOF > post-fs-data.d/post_ota.sh
/data/adb/bootctl mark-boot-successful
rm -f /data/adb/bootctl
rm -f /data/adb/post-fs-data.d/post_ota.sh
cat << EOF > $NVBASE/post-fs-data.d/post_ota.sh
$NVBASE/magisk/bootctl mark-boot-successful
rm -f $NVBASE/post-fs-data.d/post_ota.sh
EOF
chmod 755 post-fs-data.d/post_ota.sh
chmod 755 $NVBASE/post-fs-data.d/post_ota.sh
cd /
}

Expand Down
3 changes: 3 additions & 0 deletions bootctl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
obj
/.cxx
29 changes: 29 additions & 0 deletions bootctl/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
id 'com.android.library'
}

android {
compileSdk 31
ndkVersion "23.0.7599858"

defaultConfig {
minSdk 30
targetSdk 31
ndk {
abiFilters 'arm64-v8a'
}
externalNativeBuild {
cmake {
cppFlags '-std=c++17'
arguments "-DANDROID_STL=none"
}
}
}

externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
version '3.18.1'
}
}
}
2 changes: 2 additions & 0 deletions bootctl/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.topjohnwu.magisk.bootctl" />
24 changes: 24 additions & 0 deletions bootctl/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.18.1)
project("bootctl")

add_subdirectory(android.hardware.boot@1.0)
add_subdirectory(android.hardware.boot@1.1)
add_subdirectory(android.hardware.boot@1.2)
add_subdirectory(android.hidl.base@1.0)
add_subdirectory(android.hidl.manager@1.0)
add_subdirectory(android.hidl.manager@1.1)
add_subdirectory(android.hidl.manager@1.2)
add_subdirectory(bootctl)
add_subdirectory(jsoncpp)
add_subdirectory(libbase)
add_subdirectory(libcutils)
add_subdirectory(libcxx)
add_subdirectory(libcxxabi)
add_subdirectory(libdl)
add_subdirectory(libhidl)
add_subdirectory(libhwbinder)
add_subdirectory(liblog)
add_subdirectory(libprocessgroup)
add_subdirectory(libsystem)
add_subdirectory(libutils)
add_subdirectory(libvndksupport)
Loading