mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2025-04-23 07:20:51 +00:00
Fix permission loop problem
This commit is contained in:
parent
50ba8ceec4
commit
cfccc0f37c
1 changed files with 7 additions and 22 deletions
|
@ -50,7 +50,7 @@ import static android.system.Os.setenv;
|
|||
private static final String TAG = "RTCWQuest";
|
||||
private static final String APPLICATION = "RTCWQuest";
|
||||
|
||||
private int permissionCount = 0;
|
||||
private boolean permissionsGranted = false;
|
||||
private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1;
|
||||
private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
|
||||
|
||||
|
@ -194,15 +194,8 @@ import static android.system.Os.setenv;
|
|||
GLES3JNIActivity.this,
|
||||
new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
||||
WRITE_EXTERNAL_STORAGE_PERMISSION_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
permissionCount++;
|
||||
}
|
||||
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
} else if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED){
|
||||
ActivityCompat.requestPermissions(
|
||||
GLES3JNIActivity.this,
|
||||
new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
|
||||
|
@ -210,10 +203,10 @@ import static android.system.Os.setenv;
|
|||
}
|
||||
else
|
||||
{
|
||||
permissionCount++;
|
||||
permissionsGranted = true;
|
||||
}
|
||||
|
||||
if (permissionCount == 2) {
|
||||
if (permissionsGranted) {
|
||||
// Permissions have already been granted.
|
||||
create();
|
||||
}
|
||||
|
@ -223,21 +216,13 @@ import static android.system.Os.setenv;
|
|||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) {
|
||||
if (requestCode == READ_EXTERNAL_STORAGE_PERMISSION_ID) {
|
||||
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
permissionCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (results.length > 0 && results[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_ID) {
|
||||
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
permissionCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (results.length > 0 && results[0] != PackageManager.PERMISSION_GRANTED) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue