From e91f71c01b5265570c2e5d2bfff9967a1f9943f6 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 26 Jan 2014 10:04:16 +0100 Subject: [PATCH] Revert "Moved database back due to permission problems" This reverts commit 97b9f2a855dd083c226ef30f81f346eb9257ae88. Conflicts: CHANGELOG.md Refs #1160 --- CHANGELOG.md | 1 + src/biz/bokhorst/xprivacy/PrivacyService.java | 35 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) 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)