PermissionsDispatcher: Xiaomi crash java.lang.SecurityException SYSTEM_ALERT_WINDOW

Crash on myMethodWithPermissionCheck() when use @NeedsPermission(Manifest.permission.SYSTEM_ALERT_WINDOW)

Library version : 3.3.1 with kapt processor Devices affected : Only Xiaomi Mi A1 Stacktrace:

Fatal Exception: java.lang.SecurityException: com.obscience.imamma from uid 10012 not allowed to perform SYSTEM_ALERT_WINDOW
       at android.app.AppOpsManager.noteOp(AppOpsManager.java:1837)
       at android.app.AppOpsManager.noteOp(AppOpsManager.java:1654)
       at android.support.v4.app.AppOpsManagerCompat.noteOp(AppOpsManagerCompat.java:106)
       at permissions.dispatcher.PermissionUtils.hasSelfPermissionForXiaomi(PermissionUtils.java:111)
       at permissions.dispatcher.PermissionUtils.hasSelfPermission(PermissionUtils.java:96)
       at permissions.dispatcher.PermissionUtils.hasSelfPermissions(PermissionUtils.java:76)
       at com.obscience.imamma.AbstractMainActivityPermissionsDispatcher.startBubbleServiceWithPermissionCheck(AbstractMainActivityPermissionsDispatcher.java:41)
       at com.obscience.imamma.AbstractMainActivity.startOrUpdateBubble(AbstractMainActivity.java:476)
       at com.obscience.imamma.AbstractMainActivity.onCreateMenu(AbstractMainActivity.java:466)
       at com.obscience.imamma.AbstractMainActivity$$Lambda$0.onClick(Unknown Source:4)
       at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:172)
       at android.app.ActivityThread.main(ActivityThread.java:6590)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

@hotchemi Finally I have updates, I tested with a clean application, the system overlay request and I found the behavior to replicate the crash on xiaomi mi a1 (now on Fabric i see same crash with redmi note 4 and android 6). The crash occurs only if you use the library, step to reproduce the crash:

  1. Activate the permission for the overlay through the app
  2. I open the app information (eg through the launcher) and revoke the permission for the overlay
  3. Return to the app and try to activate the permission again
  4. Crash
  5. Reopen app and retry to activate permission
  6. Crash
  7. Close app from recent
  8. Open and retry to activate permission
  9. Crash
  10. I install the same app with manual permissions, everything works
  11. I try in my Nexus 6P, everything works, both permission dispatcher and manual permissions

If you want I can put on my github the sample project I used, but it’s very simple, a button that requires overlay permissions

No problem, I’m trying to find a Xiaomi MI A1 to perform the test without using the library and check if the problem is in the library or device. I will give you updates on the problem as soon as possible