summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-07-05 09:39:26 -0700
committerd34d <clark@cyngn.com>2016-07-05 09:39:26 -0700
commit2ab2c563b89f2b6b7d821d3a72b570b8060cd62c (patch)
tree95cb6faac58b1da639ecb73b6dde862e60edbecc
parent746ea9fa6544cc0b5d1855e2df55605fd734c4f6 (diff)
downloadpackages_apps_ThemeChooser-2ab2c563b89f2b6b7d821d3a72b570b8060cd62c.zip
packages_apps_ThemeChooser-2ab2c563b89f2b6b7d821d3a72b570b8060cd62c.tar.gz
packages_apps_ThemeChooser-2ab2c563b89f2b6b7d821d3a72b570b8060cd62c.tar.bz2
Check for system alert window permission
It is possible that the user disables theme chooser from being able to draw on top of other applications. If this happens theme chooser will crash due to a security exception. This patch checks that we still have the permission and if not, requests it from the user. Change-Id: Ic4fc12293d4fa2c544d2e54ed8279dc07d7493f6 TICKET: CYNGNOS-3141
-rw-r--r--src/com/cyngn/theme/chooser/ChooserActivity.java34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java
index b1f943f..d607eb6 100644
--- a/src/com/cyngn/theme/chooser/ChooserActivity.java
+++ b/src/com/cyngn/theme/chooser/ChooserActivity.java
@@ -28,6 +28,7 @@ import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
+import android.provider.Settings;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
@@ -112,6 +113,11 @@ public class ChooserActivity extends FragmentActivity
*/
public static final int REQUEST_PICK_LOCKSCREEN_IMAGE = 3;
+ /**
+ * Request code for enabling system alert window permission
+ */
+ private static final int REQUEST_SYSTEM_WINDOW_PERMISSION = 4;
+
private static final long ANIMATE_CONTENT_IN_SCALE_DURATION = 500;
private static final long ANIMATE_CONTENT_IN_ALPHA_DURATION = 750;
private static final long ANIMATE_CONTENT_IN_BLUR_DURATION = 250;
@@ -242,10 +248,11 @@ public class ChooserActivity extends FragmentActivity
new View.OnClickListener() {
@Override
public void onClick(View v) {
- PreferenceUtils.setShowPerAppThemeNewTag(ChooserActivity.this, false);
- Intent intent = new Intent(ChooserActivity.this, PerAppThemingWindow.class);
- startService(intent);
- finish();
+ if (Settings.canDrawOverlays(ChooserActivity.this)) {
+ launchAppThemer();
+ } else {
+ requestSystemWindowPermission();
+ }
}
});
@@ -771,8 +778,10 @@ public class ChooserActivity extends FragmentActivity
showSaveApplyButton();
}
}
- } else {
- super.onActivityResult(requestCode, resultCode, data);
+ } else if (requestCode == REQUEST_SYSTEM_WINDOW_PERMISSION) {
+ if (Settings.canDrawOverlays(this)) {
+ launchAppThemer();
+ }
}
}
@@ -1166,4 +1175,17 @@ public class ChooserActivity extends FragmentActivity
}
});
}
+
+ private void launchAppThemer() {
+ PreferenceUtils.setShowPerAppThemeNewTag(ChooserActivity.this, false);
+ Intent intent = new Intent(ChooserActivity.this, PerAppThemingWindow.class);
+ startService(intent);
+ finish();
+ }
+
+ private void requestSystemWindowPermission() {
+ Intent intent = new Intent (Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
+ Uri.parse("package:" + getPackageName()));
+ startActivityForResult(intent, REQUEST_SYSTEM_WINDOW_PERMISSION);
+ }
}