From 08e9a67e6cb4d995279e50189b2bf2a233354605 Mon Sep 17 00:00:00 2001 From: kruhc Date: Wed, 18 Sep 2019 22:52:47 +0200 Subject: [PATCH] requesting dangerous permissions at runtime as requested in Android 6.0+ --- .../org/microemu/android/MicroEmulator.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/externals/microemulator/microemu-android/src/org/microemu/android/MicroEmulator.java b/externals/microemulator/microemu-android/src/org/microemu/android/MicroEmulator.java index afe7095d..45a7ba1f 100644 --- a/externals/microemulator/microemu-android/src/org/microemu/android/MicroEmulator.java +++ b/externals/microemulator/microemu-android/src/org/microemu/android/MicroEmulator.java @@ -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); @@ -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");