Skip to content

Commit be8d489

Browse files
committed
added arm64 versions of Hashtree Patcher, lptools, and magiskboot
1 parent ed5ec0c commit be8d489

File tree

12 files changed

+39
-30
lines changed

12 files changed

+39
-30
lines changed

app/build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId "com.github.capntrips.kernelflasher"
1313
minSdk 29
1414
targetSdk 34
15-
versionCode 16
16-
versionName "1.0.0-alpha16"
15+
versionCode 17
16+
versionName "1.0.0-alpha17"
1717

1818
javaCompileOptions {
1919
annotationProcessorOptions {
@@ -23,17 +23,23 @@ android {
2323
]
2424
}
2525
}
26-
26+
ndk {
27+
abiFilters = ['armeabi-v7a', 'arm64-v8a']
28+
}
2729
vectorDrawables {
2830
useSupportLibrary true
2931
}
3032
}
31-
3233
buildTypes {
3334
release {
3435
minifyEnabled false
3536
}
3637
}
38+
sourceSets {
39+
main {
40+
jniLibs.srcDirs = ['src/main/jniLibs']
41+
}
42+
}
3743
buildFeatures {
3844
aidl true
3945
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<application
88
android:allowBackup="true"
99
android:dataExtractionRules="@xml/data_extraction_rules"
10+
android:extractNativeLibs="true"
1011
android:fullBackupContent="@xml/backup_rules"
1112
android:icon="@mipmap/ic_launcher"
1213
android:label="@string/app_name"

app/src/main/assets/httools_static

-510 KB
Binary file not shown.

app/src/main/assets/lptools_static

-421 KB
Binary file not shown.

app/src/main/java/com/github/capntrips/kernelflasher/MainActivity.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.github.capntrips.kernelflasher
33
import android.animation.ObjectAnimator
44
import android.animation.PropertyValuesHolder
55
import android.content.ComponentName
6+
import android.content.Context
67
import android.content.Intent
78
import android.content.ServiceConnection
89
import android.os.Bundle
@@ -98,6 +99,19 @@ class MainActivity : ComponentActivity() {
9899
Shell.cmd("chmod +x $dest").exec()
99100
}
100101

102+
private fun copyNativeBinary(context: Context, filename: String) {
103+
val binary = File(context.applicationInfo.nativeLibraryDir, "lib$filename.so")
104+
println("binary: $binary")
105+
val dest = File(filesDir, filename)
106+
println("dest: $dest")
107+
binary.inputStream().use { inputStream ->
108+
dest.outputStream().use { outputStream ->
109+
inputStream.copyTo(outputStream)
110+
}
111+
}
112+
Shell.cmd("chmod +x $dest").exec()
113+
}
114+
101115
override fun onCreate(savedInstanceState: Bundle?) {
102116
WindowCompat.setDecorFitsSystemWindows(window, false)
103117
val splashScreen = installSplashScreen()
@@ -153,9 +167,9 @@ class MainActivity : ComponentActivity() {
153167
fun onAidlConnected(fileSystemManager: FileSystemManager) {
154168
try {
155169
Shell.cmd("cd $filesDir").exec()
156-
copyAsset("lptools_static")
157-
copyAsset("httools_static")
158-
copyAsset("magiskboot") // version: Magisk 25.2 stable release
170+
copyNativeBinary(this, "lptools_static") // v20220825
171+
copyNativeBinary(this, "httools_static") // v3.2.0
172+
copyNativeBinary(this, "magiskboot") // v25.2
159173
copyAsset("flash_ak3.sh")
160174
} catch (e: Exception) {
161175
Log.e(TAG, e.message, e)

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotViewModel.kt

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ class SlotViewModel(
6565
private var inInit = true
6666
private var _error: String? = null
6767

68-
@Suppress("PrivatePropertyName")
69-
private val STOCK_MAGISKBOOT = "/data/adb/magisk/magiskboot"
70-
private var magiskboot: String = STOCK_MAGISKBOOT
71-
7268
val sha1: String
7369
get() = _sha1!!
7470
val flashOutput: List<String>
@@ -91,11 +87,7 @@ class SlotViewModel(
9187
}
9288

9389
fun refresh(context: Context) {
94-
// init magiskboot
95-
if (!File(STOCK_MAGISKBOOT).exists()) {
96-
magiskboot = context.filesDir.absolutePath + File.separator + "magiskboot"
97-
}
98-
90+
val magiskboot = File(context.filesDir, "magiskboot")
9991
Shell.cmd("$magiskboot unpack $boot").exec()
10092

10193
val ramdisk = File(context.filesDir, "ramdisk.cpio")
@@ -116,23 +108,18 @@ class SlotViewModel(
116108
}
117109
}
118110

119-
val magiskboot = fileSystemManager.getFile(magiskboot)
120-
if (magiskboot.exists()) {
121-
if (ramdisk.exists()) {
122-
when (Shell.cmd("$magiskboot cpio ramdisk.cpio test").exec().code) {
123-
0 -> _sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
124-
1 -> _sha1 = Shell.cmd("$magiskboot cpio ramdisk.cpio sha1").exec().out.firstOrNull()
125-
else -> log(context, "Invalid ramdisk in boot.img", shouldThrow = true)
126-
}
127-
} else if (kernel.exists()) {
128-
_sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
129-
} else {
130-
log(context, "Invalid boot.img, no ramdisk or kernel found", shouldThrow = true)
111+
if (ramdisk.exists()) {
112+
when (Shell.cmd("$magiskboot cpio ramdisk.cpio test").exec().code) {
113+
0 -> _sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
114+
1 -> _sha1 = Shell.cmd("$magiskboot cpio ramdisk.cpio sha1").exec().out.firstOrNull()
115+
else -> log(context, "Invalid ramdisk in boot.img", shouldThrow = true)
131116
}
132-
Shell.cmd("$magiskboot cleanup").exec()
117+
} else if (kernel.exists()) {
118+
_sha1 = Shell.cmd("$magiskboot sha1 $boot").exec().out.firstOrNull()
133119
} else {
134-
log(context, "magiskboot is missing", shouldThrow = true)
120+
log(context, "Invalid boot.img, no ramdisk or kernel found", shouldThrow = true)
135121
}
122+
Shell.cmd("$magiskboot cleanup").exec()
136123

137124
PartitionUtil.AvailablePartitions.forEach { partitionName ->
138125
_backupPartitions[partitionName] = true
@@ -245,6 +232,7 @@ class SlotViewModel(
245232

246233
@Suppress("FunctionName", "SameParameterValue")
247234
private fun _getKernel(context: Context) {
235+
val magiskboot = File(context.filesDir, "magiskboot")
248236
Shell.cmd("$magiskboot unpack $boot").exec()
249237
val kernel = File(context.filesDir, "kernel")
250238
if (kernel.exists()) {
878 KB
Binary file not shown.
746 KB
Binary file not shown.
617 KB
Binary file not shown.
536 KB
Binary file not shown.

0 commit comments

Comments
 (0)