@@ -67,6 +67,9 @@ class SlotViewModel(
67
67
private var inInit = true
68
68
private var _error : String? = null
69
69
70
+ private val STOCK_MAGISKBOOT = " /data/adb/magisk/magiskboot"
71
+ private var magiskboot: String = STOCK_MAGISKBOOT
72
+
70
73
val sha1: String
71
74
get() = _sha1 !!
72
75
val flashOutput: List <String >
@@ -89,7 +92,12 @@ class SlotViewModel(
89
92
}
90
93
91
94
fun refresh (context : Context ) {
92
- Shell .cmd(" /data/adb/magisk/magiskboot unpack $boot " ).exec()
95
+ // init magiskboot
96
+ if (! File (STOCK_MAGISKBOOT ).exists()) {
97
+ magiskboot = context.filesDir.absolutePath + File .separator + " magiskboot"
98
+ }
99
+
100
+ Shell .cmd(" $magiskboot unpack $boot " ).exec()
93
101
94
102
val ramdisk = File (context.filesDir, " ramdisk.cpio" )
95
103
@@ -108,18 +116,18 @@ class SlotViewModel(
108
116
}
109
117
}
110
118
111
- val magiskboot = fileSystemManager.getFile(" /data/adb/magisk/ magiskboot" )
119
+ val magiskboot = fileSystemManager.getFile(magiskboot)
112
120
if (magiskboot.exists()) {
113
121
if (ramdisk.exists()) {
114
- when (Shell .cmd(" /data/adb/magisk/ magiskboot cpio ramdisk.cpio test" ).exec().code) {
115
- 0 -> _sha1 = Shell .cmd(" /data/adb/magisk/ magiskboot sha1 $boot " ).exec().out .firstOrNull()
116
- 1 -> _sha1 = Shell .cmd(" /data/adb/magisk/ magiskboot cpio ramdisk.cpio sha1" ).exec().out .firstOrNull()
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()
117
125
else -> log(context, " Invalid boot.img" , shouldThrow = true )
118
126
}
119
127
} else {
120
128
log(context, " Invalid boot.img" , shouldThrow = true )
121
129
}
122
- Shell .cmd(" /data/adb/magisk/ magiskboot cleanup" ).exec()
130
+ Shell .cmd(" $ magiskboot cleanup" ).exec()
123
131
} else {
124
132
log(context, " magiskboot is missing" , shouldThrow = true )
125
133
}
@@ -238,15 +246,15 @@ class SlotViewModel(
238
246
239
247
@Suppress(" FunctionName" , " SameParameterValue" )
240
248
private fun _getKernel (context : Context ) {
241
- Shell .cmd(" /data/adb/magisk/ magiskboot unpack $boot " ).exec()
249
+ Shell .cmd(" $ magiskboot unpack $boot " ).exec()
242
250
val kernel = File (context.filesDir, " kernel" )
243
251
if (kernel.exists()) {
244
252
val result = Shell .cmd(" strings kernel | grep -E -m1 'Linux version.*#' | cut -d\\ -f3-" ).exec().out
245
253
if (result.isNotEmpty()) {
246
254
kernelVersion = result[0 ].replace(""" \(.+\)""" .toRegex(), " " ).replace(""" \s+""" .toRegex(), " " )
247
255
}
248
256
}
249
- Shell .cmd(" /data/adb/magisk/ magiskboot cleanup" ).exec()
257
+ Shell .cmd(" $ magiskboot cleanup" ).exec()
250
258
}
251
259
252
260
fun getKernel (context : Context ) {
0 commit comments