diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a9a979c..9e2836245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Test and beta releases will have experimental functions enabled by default. **Next release** * Updated German translation +* Moved database back again due to permission problems ([issue](https://github.com/M66B/XPrivacy/issues/1160)) [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/src/biz/bokhorst/xprivacy/PrivacyService.java b/src/biz/bokhorst/xprivacy/PrivacyService.java index f3a7a7912..1daf0f991 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyService.java +++ b/src/biz/bokhorst/xprivacy/PrivacyService.java @@ -761,33 +761,32 @@ private static int getXUid() { } private static File getDbFile() { - return new File(Environment.getDataDirectory() + File.separator + "xprivacy" + File.separator + "xprivacy.db"); + return new File(Environment.getDataDirectory() + File.separator + "data" + File.separator + + PrivacyService.class.getPackage().getName() + File.separator + "xprivacy.db"); } public static void setupDatebase() { // This is run from Zygote with root permissions try { - // Create base folder - getDbFile().getParentFile().mkdirs(); - - // Move existing database - File source = new File(Environment.getDataDirectory() + File.separator + "data" + File.separator - + PrivacyService.class.getPackage().getName() + File.separator + "xprivacy.db"); - File target = new File(getDbFile().getParentFile() + File.separator + "xprivacy.db"); - source.renameTo(target); - source = new File(source + "-journal"); - target = new File(target + "-journal"); - source.renameTo(target); - - // Create database, if needed - getDatabase(); - - // Set database folder permission + // Move database from experimental location + File folder = new File(Environment.getDataDirectory() + File.separator + "xprivacy"); + if (folder.exists()) { + File[] files = folder.listFiles(); + if (files != null) + for (File file : files) { + File target = new File(getDbFile().getParentFile() + File.separator + file.getName()); + Util.log(null, Log.WARN, "Moving " + file + " to " + target); + file.renameTo(target); + } + folder.delete(); + } + + // Set application folder permission // Owner: rwx (untouched) // Group: rwx (set to system) // World: --- File dbFile = getDbFile(); - Util.setPermission(dbFile.getParentFile().getAbsolutePath(), 0770, -1, PrivacyManager.cAndroidUid); + Util.setPermission(dbFile.getParentFile().getAbsolutePath(), 0771, -1, PrivacyManager.cAndroidUid); // Set database file permissions // Owner: rwx (untouched)