mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-29 12:52:34 +00:00
Update Android target, support "Runtime Permissions" in Android 6.0+ (Marshmallow).
Currently this is the absolute minimum required. Will later add a button to re-request the permission if it's lost, but at least we do that on application startup. Storage is the only permission we need that's not auto-granted.
This commit is contained in:
parent
99fe0981ee
commit
2d22088f38
@ -7,7 +7,7 @@
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="9"
|
||||
android:targetSdkVersion="22" />
|
||||
android:targetSdkVersion="23" />
|
||||
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
<uses-feature android:name="android.hardware.screen.landscape" android:required="false" />
|
||||
|
@ -11,4 +11,4 @@
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-22
|
||||
target=android-23
|
||||
|
@ -5,6 +5,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
@ -157,6 +158,30 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int REQUEST_CODE_STORAGE_PERMISSION = 1337;
|
||||
|
||||
@TargetApi(23)
|
||||
public void askForStoragePermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (this.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
NativeApp.sendMessage("permission_pending", "storage");
|
||||
this.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_CODE_STORAGE_PERMISSION);
|
||||
} else {
|
||||
NativeApp.sendMessage("permission_granted", "storage");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String permissions[], int[] grantResults) {
|
||||
if (requestCode == REQUEST_CODE_STORAGE_PERMISSION && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
NativeApp.sendMessage("permission_granted", "storage");
|
||||
} else {
|
||||
NativeApp.sendMessage("permission_denied", "storage");
|
||||
}
|
||||
}
|
||||
|
||||
public void setShortcutParam(String shortcutParam) {
|
||||
this.shortcutParam = ((shortcutParam == null) ? "" : shortcutParam);
|
||||
}
|
||||
@ -172,6 +197,9 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
||||
detectOptimalAudioSettings();
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
askForStoragePermission();
|
||||
}
|
||||
// Get system information
|
||||
ApplicationInfo appInfo = null;
|
||||
PackageManager packMgmr = getPackageManager();
|
||||
@ -907,6 +935,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
||||
} else if (command.equals("recreate")) {
|
||||
exitEGLRenderLoop();
|
||||
recreate();
|
||||
} else if (command.equals("ask_permission")) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user