summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-06-01 10:00:02 -0700
committerd34d <clark@cyngn.com>2016-06-01 10:00:02 -0700
commitdafec22595920e1e20bac329096dc098dd5ae364 (patch)
tree89f9b72d5ac395b3fc4356f6eb0ab75ac01f529d
parent488da61b690e8271d357720b9d8a2904b2e5bd58 (diff)
downloadandroid_packages_providers_ThemesProvider-dafec22595920e1e20bac329096dc098dd5ae364.tar.gz
android_packages_providers_ThemesProvider-dafec22595920e1e20bac329096dc098dd5ae364.tar.bz2
android_packages_providers_ThemesProvider-dafec22595920e1e20bac329096dc098dd5ae364.zip
Apply bandaid to ensure preview permissions are correct
There have been some bug reports indicating that the previews generated are not getting the correct permissions set, but reproducing this issue has been a lost battle. This patch attemtps to correct this scenario by scanning the preview directories and files and setting the correct permissions. Change-Id: I51e19375136f152ac62a11713d3db0a984a35f50 TICKET: CYNGNOS-2592
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesProvider.java1
-rw-r--r--src/org/cyanogenmod/themes/provider/util/PreviewUtils.java21
2 files changed, 22 insertions, 0 deletions
diff --git a/src/org/cyanogenmod/themes/provider/ThemesProvider.java b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
index f263881..61828fb 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesProvider.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
@@ -232,6 +232,7 @@ public class ThemesProvider extends ContentProvider {
*/
mHandler.post(new Runnable() {
public void run() {
+ PreviewUtils.ensureCorrectPreviewPermissions(getContext());
new VerifyInstalledThemesThread().start();
}
});
diff --git a/src/org/cyanogenmod/themes/provider/util/PreviewUtils.java b/src/org/cyanogenmod/themes/provider/util/PreviewUtils.java
index de86092..cda7683 100644
--- a/src/org/cyanogenmod/themes/provider/util/PreviewUtils.java
+++ b/src/org/cyanogenmod/themes/provider/util/PreviewUtils.java
@@ -15,6 +15,7 @@
*/
package org.cyanogenmod.themes.provider.util;
+import android.content.Context;
import android.graphics.Bitmap;
import android.os.FileUtils;
import android.util.Log;
@@ -46,6 +47,26 @@ public class PreviewUtils {
return baseDir + File.separator + PREVIEWS_DIR;
}
+ public static void ensureCorrectPreviewPermissions(Context context) {
+ File previewsDir = new File(getPreviewsDir(context.getFilesDir().getAbsolutePath()));
+ if (previewsDir.exists()) {
+ ensureCorrectPreviewPermissions(previewsDir);
+ }
+ }
+
+ private static void ensureCorrectPreviewPermissions(File file) {
+ int mode = 0;
+ if (file.isDirectory()) {
+ for (File f : file.listFiles()) {
+ ensureCorrectPreviewPermissions(f);
+ }
+ mode = FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IROTH | FileUtils.S_IXOTH;
+ } else {
+ mode = FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IROTH;
+ }
+ FileUtils.setPermissions(file, mode, -1, -1);
+ }
+
private static String saveCompressedImage(byte[] image, String baseDir, String pkgName,
String fileName) {
if (image == null) return null;