Skip to content

Commit

Permalink
Bugfix for a potential IllegalArgumentException when asking for permi…
Browse files Browse the repository at this point in the history
…ssions that are not declared in AndroidManifest
  • Loading branch information
yasirkula committed Apr 28, 2020
1 parent c19a719 commit e152b51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions .github/JAR Source/RuntimePermissionsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,20 @@ public void onRequestPermissionsResult( int requestCode, String[] permissions, i
else
resolvedPermissionCount++;

if( grantResults[i] == PackageManager.PERMISSION_GRANTED )
permissionsResult.set( permissionIndex, 1 );
else if( !shouldShowRequestPermissionRationale( permission ) )
try
{
if( grantResults[i] == PackageManager.PERMISSION_GRANTED )
permissionsResult.set( permissionIndex, 1 );
else if( !shouldShowRequestPermissionRationale( permission ) ) // This can cause IllegalArgumentException for undocumented permissions
permissionsResult.set( permissionIndex, 0 );
else
permissionsResult.set( permissionIndex, 2 );
}
catch( Exception e )
{
Log.e( "Unity", "Exception:", e );
permissionsResult.set( permissionIndex, 0 );
else
permissionsResult.set( permissionIndex, 2 );
}
}

if( resolvedPermissionCount != m_permissions.length )
Expand Down
Binary file modified Plugins/AndroidRuntimePermissions/Android/RuntimePermissions.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.yasirkula.androidruntimepermissions",
"displayName": "Android Runtime Permissions",
"version": "1.1.0",
"version": "1.1.3",
"description": "This plugin helps you query/request runtime permissions synchronously on Android M and later. It also works on older Android versions and detects whether a requested permission is declared in AndroidManifest or not."
}

0 comments on commit e152b51

Please sign in to comment.