Skip to content

Commit

Permalink
修复导入导出登录信息时的权限问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xausky committed Jan 12, 2020
1 parent 05859c9 commit 92b4778
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "cn.xausky.umm"
minSdkVersion 21
targetSdkVersion 23
versionCode 410
versionName "4.1.0"
versionCode 411
versionName "4.1.1"
ndk{
abiFilters "armeabi-v7a","x86"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static byte[] backupKuroGame(Context context) {
String accountsDatabaseFile = context.getDatabasePath("zz_sdk_db").getAbsolutePath();
String deviceIdFile = context.getFilesDir().getAbsolutePath() + "/shared_prefs/devicesyn.xml";
try {
unprotectFilesWithRoot(accountsDatabaseFile, deviceIdFile);
unprotectFilesWithRoot(accountsDatabaseFile + "*", deviceIdFile);
JSONObject root = new JSONObject();
StringBuilder builder = new StringBuilder();
try (SQLiteDatabase db = SQLiteDatabase.openDatabase(accountsDatabaseFile, null, SQLiteDatabase.OPEN_READONLY);
Expand All @@ -42,15 +42,15 @@ public static byte[] backupKuroGame(Context context) {
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
protectFilesWithRoot(accountsDatabaseFile, deviceIdFile);
protectFilesWithRoot(accountsDatabaseFile + "*", deviceIdFile);
}
}

public static void restoreKuroGame(Context context, byte[] data) {
String accountsDatabaseFile = context.getDatabasePath("zz_sdk_db").getAbsolutePath();
String deviceIdFile = context.getFilesDir().getAbsolutePath() + "/shared_prefs/devicesyn.xml";
try {
unprotectFilesWithRoot(accountsDatabaseFile, deviceIdFile);
unprotectFilesWithRoot(accountsDatabaseFile + "*", deviceIdFile);
JSONObject root = new JSONObject(new String(data));
String accounts = root.getString("accounts");
try (SQLiteDatabase db = SQLiteDatabase.openDatabase(accountsDatabaseFile, null, SQLiteDatabase.OPEN_READWRITE)) {
Expand All @@ -63,7 +63,7 @@ public static void restoreKuroGame(Context context, byte[] data) {
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
protectFilesWithRoot(accountsDatabaseFile, deviceIdFile);
protectFilesWithRoot(accountsDatabaseFile + "*", deviceIdFile);
}
}

Expand All @@ -86,6 +86,6 @@ private static void protectFilesWithRoot(String ...files){
builder.append(" ");
}
}
Shell.su("setenforce 1", "chmod 644 " + builder.toString()).exec();
Shell.su("setenforce 1", "chmod 600 " + builder.toString()).exec();
}
}

0 comments on commit 92b4778

Please sign in to comment.