Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Background to the Problem:
Code due to this is happening:
ActivityCompat.requestpermissions() -> Activity.requestPermissions() in the end the below fuction is called to start permission controller activity.
frameworks/base/core/java/android/app/Activity.java
................
*/
@FlaggedApi(Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED)
public final void requestPermissions(@NonNull String[] permissions, int requestCode,
int deviceId) {
if (requestCode < 0) {
throw new IllegalArgumentException("requestCode should be >= 0");
}
if (mHasCurrentPermissionsRequest) {
Log.w(TAG, "Can request only one set of permissions at a time");
// Dispatch the callback with empty arrays which means a cancellation.
onRequestPermissionsResult(requestCode, new String[0], new int[0], deviceId);
return;
}
if (!getAttributionSource().getRenouncedPermissions().isEmpty()) {
final int permissionCount = permissions.length;
for (int i = 0; i < permissionCount; i++) {
if (getAttributionSource().getRenouncedPermissions().contains(permissions[i])) {
throw new IllegalArgumentException("Cannot request renounced permission: "
+ permissions[i]);
}
}
}
PackageManager packageManager = getDeviceId() == deviceId ? getPackageManager()
: createDeviceContext(deviceId).getPackageManager();
final Intent intent = packageManager.buildRequestPermissionsIntent(permissions);
startActivityForResult(REQUEST_PERMISSIONS_WHO_PREFIX, intent, requestCode, null);
mHasCurrentPermissionsRequest = true;
}
.............................
As our flow move to PremissionController activity so our current App activity gets in background which call its onstop and when the result come from permissionController then again the onresume of our App will be called which led to infinite loop and led the app to jank infinitely.
i think this is not corrrect bheviour for app developer since there would no dialog will apear as permissionController doesn't show any dialog for dangrous permission after denying permission two times by the user.
Solution:
before starting the activity for permissioncontroller it can be check it dangrous permission and denied by the user two times the flow should end there only and flow should not go to PermissionController.
Though it is solvable with some code changes in the App, but it would be very difficult for any app developer to understand why there app doesn't work in this case senrio.
Logs:
10-07 18:28:40.261 1000 1356 1595 I input_focus: [Focus request 8f1e455 com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity,reason=UpdateInputWindows]
10-07 18:28:40.267 1000 1356 2942 I wm_pause_activity: [0,223282327,com.afwsamples.testdpc/.PolicyManagementActivity,userLeaving=true,resumeTopActivity]
10-07 18:28:40.269 10325 19736 19736 I wm_on_resume_called: [223282327,com.afwsamples.testdpc.PolicyManagementActivity,RESUME_ACTIVITY,10]
10-07 18:28:40.272 1000 1356 1745 I input_focus: [Focus entering 8f1e455 com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity (server),reason=setFocusedWindow]
10-07 18:28:40.276 10325 19736 19736 I wm_on_top_resumed_gained_called: [223282327,com.afwsamples.testdpc.PolicyManagementActivity,topWhenResuming]
10-07 18:28:40.277 10325 19736 19736 I wm_on_top_resumed_lost_called: [223282327,com.afwsamples.testdpc.PolicyManagementActivity,topStateChangedWhenResumed]
10-07 18:28:40.277 10325 19736 19736 I wm_on_paused_called: [223282327,com.afwsamples.testdpc.PolicyManagementActivity,performPause,0]
10-07 18:28:40.279 1000 1356 4195 I wm_restart_activity: [0,101325849,53,com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity]
10-07 18:28:40.280 1000 1356 4195 I wm_set_resumed_activity: [0,com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity,minimalResumeActivityLocked - onActivityStateChanged]