Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
Fix multiusers conflicting
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Feb 12, 2018
1 parent bffa837 commit ae5277a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/com/topjohnwu/magisk/database/SuDatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,21 @@ public static SuDatabaseHelper getInstance(MagiskManager mm) {
try {
return new SuDatabaseHelper(mm);
} catch (Exception e) {
// Let's cleanup and try again
cleanup();
// Let's cleanup everything and try again
cleanup("*");
return new SuDatabaseHelper(mm);
}
}

public static void cleanup() {
cleanup(String.valueOf(Const.USER_ID));
}

public static void cleanup(String s) {
Shell.Sync.su(
"umount -l /data/user*/*/*/databases/su.db /sbin/.core/db-*/magisk.db",
"rm -rf /sbin/.core/db-*");
"umount -l /data/user*/*/*/databases/su.db",
"umount -l /sbin/.core/db-" + s + "/magisk.db",
"rm -rf /sbin/.core/db-" + s);
}

private SuDatabaseHelper(MagiskManager mm) {
Expand All @@ -68,7 +73,7 @@ private SuDatabaseHelper(MagiskManager mm) {

private SQLiteDatabase openDatabase(MagiskManager mm) {
String GLOBAL_DB = "/data/adb/magisk.db";
DB_FILE = new File(Utils.fmt("/sbin/.core/db-%s/magisk.db", mm.getPackageName()));
DB_FILE = new File(Utils.fmt("/sbin/.core/db-%d/magisk.db", Const.USER_ID));
Context de = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
? mm.createDeviceProtectedStorageContext() : mm;
if (!DB_FILE.exists()) {
Expand Down

0 comments on commit ae5277a

Please sign in to comment.