Skip to content
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

TestDPC app is not responding and eventually crashes when the notifications permission is not granted #227

Open
michal-murin opened this issue Oct 1, 2024 · 1 comment

Comments

@michal-murin
Copy link

michal-murin commented Oct 1, 2024

Hello. We use it when we don't want to use a real UEM. I've just installed the TestDPC app from the Google Play:

  • version 9.0.12
  • device Google Pixel 7
  • OS Android 15 Beta (AP31.240517.031)

STRs:

  1. Sign in with a Google account so you can download the app from Google Play
  2. Download and install the TestDPC app
  3. Remove the Google account so the device owner can be set
  4. Set the device owner using this adb command
adb shell dpm set-device-owner "com.afwsamples.testdpc/.DeviceAdminReceiver"
  1. Sign the Google account back - this step may be optional, but we do it
  2. Start the TestDPC app
  3. Do not grant the notifications permission when prompted - I'm prompted twice - declined both
  4. Try to work with the app - the UI is frozen, it doesn't react, except for scrolling. The logcat in Android Studio is flooded with a repeating pattern of logs and the app eventually crashes.
  5. Try to start the app again - the same behaviour.

Part of the filtered logs for com.afwsamples.testdpc:

Transition requested (#3189): android.os.BinderProxy@6447e64 TransitionRequestInfo { type = OPEN, triggerTask = TaskInfo{userId=0 taskId=39 displayId=0 isRunning=true baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.afwsamples.testdpc/.PolicyManagementActivity } baseActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} topActivity=ComponentInfo{com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} origActivity=null realActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} numActivities=2 lastActiveTime=1817345 supportsMultiWindow=true resizeMode=1 isResizeable=true minWidth=-1 minHeight=-1 defaultMinSize=220 token=WCT{android.window.IWindowContainerToken$Stub$Proxy@f0478cd} topActivityType=1 pictureInPictureParams=null shouldDockBigOverlays=false launchIntoPipHostTaskId=-1 lastParentTaskIdBeforePip=-1 displayCutoutSafeInsets=Rect(0, 136 - 0, 0) topActivityInfo=ActivityInfo{d441582 com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} launchCookies=[] positionInParent=Point(0, 0) parentTaskId=-1 isFocused=true isVisible=true isVisibleRequested=true isSleeping=false locusId=null displayAreaFeatureId=1 isTopActivityTransparent=true appCompatTaskInfo=AppCompatTaskInfo { topActivityInSizeCompat=false topActivityEligibleForLetterboxEducation= falseisLetterboxEducationEnabled= false isLetterboxDoubleTapEnabled= false topActivityEligibleForUserAspectRatioButton= false topActivityBoundsLetterboxed= false isFromLetterboxDoubleTap= false topActivityLetterboxVerticalPosition= -1 topActivityLetterboxHorizontalPosition= -1 topActivityLetterboxWidth=1080 topActivityLetterboxHeight=2400 isUserFullscreenOverrideEnabled=false isSystemFullscreenOverrideEnabled=false cameraCompatTaskInfo=CameraCompatTaskInfo { cameraCompatControlState=hidden freeformCameraCompatMode=inactive}}}, pipTask = null, remoteTransition = null, displayChange = null, flags = 0, debugId = 3189 }
com.afwsamples.testdpc:19fc985: onRequestHide at ORIGIN_SERVER reason HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR fromUser false
com.afwsamples.testdpc:19fc985: onCancelled at PHASE_SERVER_SHOULD_HIDE
GoogleInputMethodService.onStartInput():1937 onStartInput(EditorInfo{EditorInfo{packageName=com.afwsamples.testdpc, inputType=0, inputTypeString=NULL, enableLearning=false, autoCorrection=false, autoComplete=false, imeOptions=0, privateImeOptions=null, actionName=UNSPECIFIED, actionLabel=null, initialSelStart=-1, initialSelEnd=-1, initialCapsMode=0, label=null, fieldId=0, fieldName=null, extras=null, hintText=null, hintLocales=[]}}, false)
App-specific configuration not found for packageName: com.afwsamples.testdpc and userId: 0
Sent Transition (#3189) createdAt=10-01 12:12:33.207 via request=TransitionRequestInfo { type = OPEN, triggerTask = TaskInfo{userId=0 taskId=39 displayId=0 isRunning=true baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.afwsamples.testdpc/.PolicyManagementActivity } baseActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} topActivity=ComponentInfo{com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} origActivity=null realActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} numActivities=2 lastActiveTime=1817345 supportsMultiWindow=true resizeMode=1 isResizeable=true minWidth=-1 minHeight=-1 defaultMinSize=220 token=WCT{RemoteToken{e920af4 Task{285608a #39 type=standard A=10297:com.afwsamples.testdpc}}} topActivityType=1 pictureInPictureParams=null shouldDockBigOverlays=false launchIntoPipHostTaskId=-1 lastParentTaskIdBeforePip=-1 displayCutoutSafeInsets=Rect(0, 136 - 0, 0) topActivityInfo=ActivityInfo{2482a04 com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} launchCookies=[] positionInParent=Point(0, 0) parentTaskId=-1 isFocused=true isVisible=true isVisibleRequested=true isSleeping=false locusId=null displayAreaFeatureId=1 isTopActivityTransparent=true appCompatTaskInfo=AppCompatTaskInfo { topActivityInSizeCompat=false topActivityEligibleForLetterboxEducation= falseisLetterboxEducationEnabled= false isLetterboxDoubleTapEnabled= false topActivityEligibleForUserAspectRatioButton= false topActivityBoundsLetterboxed= false isFromLetterboxDoubleTap= false topActivityLetterboxVerticalPosition= -1 topActivityLetterboxHorizontalPosition= -1 topActivityLetterboxWidth=1080 topActivityLetterboxHeight=2400 isUserFullscreenOverrideEnabled=false isSystemFullscreenOverrideEnabled=false cameraCompatTaskInfo=CameraCompatTaskInfo { cameraCompatControlState=hidden freeformCameraCompatMode=inactive}}}, pipTask = null, remoteTransition = null, displayChange = null, flags = 0, debugId = 3189 }
Permission grant result requestId=-1343711486182311052 callingUid=10297 callingPackage=com.afwsamples.testdpc permission=android.permission.POST_NOTIFICATIONS isImplicit=false result=2 isPermissionRationaleShown=falseisPackageRestrictedByEnhancedConfirmation=true
Transition requested (#3191): android.os.BinderProxy@dad2da TransitionRequestInfo { type = OPEN, triggerTask = TaskInfo{userId=0 taskId=39 displayId=0 isRunning=true baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.afwsamples.testdpc/.PolicyManagementActivity } baseActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} topActivity=ComponentInfo{com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} origActivity=null realActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} numActivities=2 lastActiveTime=1817413 supportsMultiWindow=true resizeMode=1 isResizeable=true minWidth=-1 minHeight=-1 defaultMinSize=220 token=WCT{android.window.IWindowContainerToken$Stub$Proxy@806630b} topActivityType=1 pictureInPictureParams=null shouldDockBigOverlays=false launchIntoPipHostTaskId=-1 lastParentTaskIdBeforePip=-1 displayCutoutSafeInsets=Rect(0, 136 - 0, 0) topActivityInfo=ActivityInfo{267b5e8 com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} launchCookies=[] positionInParent=Point(0, 0) parentTaskId=-1 isFocused=true isVisible=true isVisibleRequested=true isSleeping=false locusId=null displayAreaFeatureId=1 isTopActivityTransparent=true appCompatTaskInfo=AppCompatTaskInfo { topActivityInSizeCompat=false topActivityEligibleForLetterboxEducation= falseisLetterboxEducationEnabled= false isLetterboxDoubleTapEnabled= false topActivityEligibleForUserAspectRatioButton= false topActivityBoundsLetterboxed= false isFromLetterboxDoubleTap= false topActivityLetterboxVerticalPosition= -1 topActivityLetterboxHorizontalPosition= -1 topActivityLetterboxWidth=1080 topActivityLetterboxHeight=2400 isUserFullscreenOverrideEnabled=false isSystemFullscreenOverrideEnabled=false cameraCompatTaskInfo=CameraCompatTaskInfo { cameraCompatControlState=hidden freeformCameraCompatMode=inactive}}}, pipTask = null, remoteTransition = null, displayChange = null, flags = 0, debugId = 3191 }
com.afwsamples.testdpc:ca7c4814: onRequestHide at ORIGIN_SERVER reason HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR fromUser false
com.afwsamples.testdpc:ca7c4814: onCancelled at PHASE_SERVER_SHOULD_HIDE
GoogleInputMethodService.onStartInput():1937 onStartInput(EditorInfo{EditorInfo{packageName=com.afwsamples.testdpc, inputType=0, inputTypeString=NULL, enableLearning=false, autoCorrection=false, autoComplete=false, imeOptions=0, privateImeOptions=null, actionName=UNSPECIFIED, actionLabel=null, initialSelStart=-1, initialSelEnd=-1, initialCapsMode=0, label=null, fieldId=0, fieldName=null, extras=null, hintText=null, hintLocales=[]}}, false)
App-specific configuration not found for packageName: com.afwsamples.testdpc and userId: 0
Sent Transition (#3191) createdAt=10-01 12:12:33.275 via request=TransitionRequestInfo { type = OPEN, triggerTask = TaskInfo{userId=0 taskId=39 displayId=0 isRunning=true baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.afwsamples.testdpc/.PolicyManagementActivity } baseActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} topActivity=ComponentInfo{com.google.android.permissioncontroller/com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} origActivity=null realActivity=ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity} numActivities=2 lastActiveTime=1817413 supportsMultiWindow=true resizeMode=1 isResizeable=true minWidth=-1 minHeight=-1 defaultMinSize=220 token=WCT{RemoteToken{e920af4 Task{285608a #39 type=standard A=10297:com.afwsamples.testdpc}}} topActivityType=1 pictureInPictureParams=null shouldDockBigOverlays=false launchIntoPipHostTaskId=-1 lastParentTaskIdBeforePip=-1 displayCutoutSafeInsets=Rect(0, 136 - 0, 0) topActivityInfo=ActivityInfo{26250fb com.android.permissioncontroller.permission.ui.GrantPermissionsActivity} launchCookies=[] positionInParent=Point(0, 0) parentTaskId=-1 isFocused=true isVisible=true isVisibleRequested=true isSleeping=false locusId=null displayAreaFeatureId=1 isTopActivityTransparent=true appCompatTaskInfo=AppCompatTaskInfo { topActivityInSizeCompat=false topActivityEligibleForLetterboxEducation= falseisLetterboxEducationEnabled= false isLetterboxDoubleTapEnabled= false topActivityEligibleForUserAspectRatioButton= false topActivityBoundsLetterboxed= false isFromLetterboxDoubleTap= false topActivityLetterboxVerticalPosition= -1 topActivityLetterboxHorizontalPosition= -1 topActivityLetterboxWidth=1080 topActivityLetterboxHeight=2400 isUserFullscreenOverrideEnabled=false isSystemFullscreenOverrideEnabled=false cameraCompatTaskInfo=CameraCompatTaskInfo { cameraCompatControlState=hidden freeformCameraCompatMode=inactive}}}, pipTask = null, remoteTransition = null, displayChange = null, flags = 0, debugId = 3191 }
Permission grant result requestId=-6704129847348223229 callingUid=10297 callingPackage=com.afwsamples.testdpc permission=android.permission.POST_NOTIFICATIONS isImplicit=false result=2 isPermissionRationaleShown=falseisPackageRestrictedByEnhancedConfirmation=true

The notifications permission is mentioned. Granting the permission in the Settings -> Apps -> etc. makes the app working again :)

@techsouravganguly
Copy link

Hello Michal and @pfmaggi ,

This issue is arising because, in the latest Android version, if you reject dangerous permissions twice, the app won't be able to request them again or show the dialog for permission requests. However, the GrantPermissionsActivity still tries to create its activity, but no screen appears.

As POST_NOTIFICATIONS has protection level: dangerous
https://developer.android.com/reference/android/Manifest.permission#POST_NOTIFICATIONS

I have reproduced the issue and came to conclusion that it is caused by askNotificationPermission in PolicyManagementActivity.

If you look closely, the askNotificationPermission is still in onResume, and it should only be called once. But after analyzing the logs, I realized that when we call askNotificationPermission, the PolicyManagementActivity loses focus (i.e., it stops). It then tries to create the GrantPermissionsActivity for the permission request, but since the permission has been rejected twice, it fails. This causes the flow to return to PolicyManagementActivity, and as it regains focus, it calls onResume again, leading to another call to askNotificationPermission. This results in an infinite loop, which causes the app to lag.

To summarize, the flow looks like this:
PolicyManagementActivity.onResume -> askNotificationPermission -> PolicyManagementActivity loses focus (onPause is called) -> GrantPermissionsActivity comes into focus (but shows nothing and destroys itself) -> PolicyManagementActivity regains focus and calls PolicyManagementActivity.onResume, and the cycle repeats indefinitely.

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants