-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[container-gen] Custom Android permissions configuration for native components #606
Conversation
return PackageManager.PERMISSION_GRANTED; | ||
} | ||
|
||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add @RequiresApi(api = Build.VERSION_CODES.M) to avoid lint warning
|
||
@Override | ||
public int checkPermission(String permission, int pid, int uid) { | ||
return PackageManager.PERMISSION_GRANTED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is supposed to return PERMISSION_GRANTED
or PERMISSION_DENIED
based on if the permission is allowed for a particular pid/uid. Overriding with permission granted may have an inverse effect for the feature ?.
@Override | ||
public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) { | ||
mPermissionListener = listener; | ||
ActivityCompat.requestPermissions(this, permissions, requestCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call mReactActivityDelegate. requestPermissions() as the delegate now extends the ReactActivityDelegate.
|
||
@Override | ||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||
mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please call mReactActivityDelegate. onRequestPermissionsResult() as the delegate now extends the ReactActivityDelegate.
@@ -111,4 +117,25 @@ public boolean onKeyUp(int keyCode, KeyEvent event) { | |||
public void onBackKey() { | |||
finish(); | |||
} | |||
|
|||
@Override | |||
public int checkPermission(String permission, int pid, int uid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be okay to remove this method as it's returning default int value (there is no logic involved)
} | ||
|
||
@Override | ||
public int checkSelfPermission(String permission) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be okay to remove this method as it's returning default int value (there is no logic involved)
@Igor1201 thanks for turning the PR, we were planning to implement the |
@krunalsshah Nice to know we're in sync! :) |
Looks good |
Some third-party native components should have custom Android permissions (eg.
android.permission.CAMERA
) on the container's AndroidManifest.xml, so it should be configurable.Also, it's good practice to implement react-native's
PermissionAwareActivity
so on newer versions of Android, the user will be prompted to accept it on runtime.