Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
requesting dangerous permissions at runtime as requested in Android 6.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
kruhc committed Sep 18, 2019
1 parent 7dc4a13 commit 08e9a67
Showing 1 changed file with 16 additions and 5 deletions.
Expand Up @@ -131,17 +131,15 @@ public void write(int oneByte) throws IOException {
Logger.info("use fullscreen? " + windowFullscreen);
windowLandscape = settings.getBoolean("landscape", false);
Logger.info("force landscape? " + windowLandscape);

if (windowLandscape) {
this.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
if (windowFullscreen) {
this.getWindow().setFlags(
android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,
android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN
);
}

if (windowLandscape) {
this.setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
hasPermanentMenuKey = AndroidRuntimeMethods.hasPermanentMenuKey(this);
Logger.info("hasPermanentMenuKey? " + hasPermanentMenuKey);

Expand Down Expand Up @@ -169,6 +167,19 @@ public void write(int oneByte) throws IOException {
Logger.info("actionBar = " + actionBar);
}

if (android.os.Build.VERSION.SDK_INT >= 23) { // 6.0+
final String READ_EXTERNAL_STORAGE = "android.permission.READ_EXTERNAL_STORAGE";
final String WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE";
final String ACCESS_FINE_LOCATION = "android.permission.ACCESS_FINE_LOCATION";
Logger.info("re-acquire dangerous permissions (6.0+)");
requestPermissions(
new String[] {
READ_EXTERNAL_STORAGE,
WRITE_EXTERNAL_STORAGE,
ACCESS_FINE_LOCATION
}, 112); // 112 is request code... wtf
}

java.util.List params = new ArrayList();
params.add("--usesystemclassloader");
params.add("--quit");
Expand Down

0 comments on commit 08e9a67

Please sign in to comment.