Skip to content

Commit ff97125

Browse files
author
bmax
committed
1. fix os error when install module
2. fix uninstall androidpatch will lose all root config
1 parent af04cbb commit ff97125

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

app/src/main/java/me/bmax/apatch/APatchApp.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import androidx.lifecycle.MutableLiveData
99
import coil.Coil
1010
import coil.ImageLoader
1111
import com.topjohnwu.superuser.CallbackList
12+
import com.topjohnwu.superuser.Shell
13+
import com.topjohnwu.superuser.internal.MainShell
1214
import me.bmax.apatch.util.*
1315
import me.zhanghai.android.appiconloader.coil.AppIconFetcher
1416
import me.zhanghai.android.appiconloader.coil.AppIconKeyer
@@ -86,7 +88,9 @@ class APApplication : Application() {
8688
val cmds = arrayOf(
8789
"rm -f $APD_PATH",
8890
"rm -f $KPATCH_PATH",
89-
"rm -rf $APATCH_FOLDER",
91+
"rm -rf $APATCH_BIN_FOLDER",
92+
"rm -rf $APATCH_LOG_FOLDER",
93+
"rm -rf $APATCH_VERSION_PATH",
9094
)
9195

9296
val shell = getRootShell()
@@ -139,12 +143,15 @@ class APApplication : Application() {
139143
"echo ${Version.getManagerVersion().second} > $APATCH_VERSION_PATH",
140144
"restorecon -R $APATCH_FOLDER",
141145

142-
"$KPATCH_PATH $superKey android_user init",
146+
"${nativeDir}/libmagiskpolicy.so --magisk --live",
143147
)
144148

145149
val shell = getRootShell()
146150
shell.newJob().add(*cmds).to(logCallback, logCallback).exec()
147151

152+
// clear shell cache
153+
APatchCli.refresh()
154+
148155
Log.d(TAG, "APatch installed...")
149156
_apStateLiveData.postValue(State.ANDROIDPATCH_INSTALLED)
150157
}
@@ -155,6 +162,7 @@ class APApplication : Application() {
155162
Log.d(TAG, "mark reboot ${result.code}")
156163
}
157164

165+
158166
var superKey: String = ""
159167
set(value) {
160168
field = value

app/src/main/java/me/bmax/apatch/util/APatchCli.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ fun createRootShell(): Shell {
3535
}
3636

3737
object APatchCli {
38-
val SHELL: Shell = createRootShell()
38+
var SHELL: Shell = createRootShell()
39+
fun refresh() {
40+
SHELL.close()
41+
SHELL = createRootShell()
42+
}
3943
}
4044

4145
fun getRootShell(): Shell {

0 commit comments

Comments
 (0)