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

Asking for permissions in a better way #9

Open
aaaaalbert opened this issue Feb 3, 2017 · 3 comments
Open

Asking for permissions in a better way #9

aaaaalbert opened this issue Feb 3, 2017 · 3 comments

Comments

@aaaaalbert
Copy link
Owner

SensibilityActivity currently tries to ask for all relevant permissions en bloc, but what happens on my Nexus 6 running Android 7.1.1 is that whenever the app gains focus, it asks for the next permission. Thus, to get everything agreed to, I have to change between apps about ten times.

However, maybe there isn't a better way to do this on Nougat. On previous Android versions, you could blanket-accept all of an app's permissions at install time...

@aaaaalbert
Copy link
Owner Author

ADB notes too that

02-03 14:39:46.728 21162 21162 W Activity: Can reqeust only one set of permissions at a time

@lukpueh
Copy link
Collaborator

lukpueh commented Feb 3, 2017

Blanket-accept does not work anymore since Android 6.0. You now have to ask for permissions at runtime.
I can't reproduce this 7.1.1. behavior on 6.0, where above referenced function iterates over all the dialogs without requiring to switch between apps.

@lukpueh
Copy link
Collaborator

lukpueh commented Feb 3, 2017

UPDATE:
I updated this comment because I missed some lines in the log. It makes more sense now.

I traced the permission check/request functions (using debug statements) and here is what happens:

D/SensibilityActivity: Entering onStart
D/SensibilityActivity: Calling checkRequestPermissions
D/SensibilityActivity: Entering checkRequestPermissions
# ... stripped permission check for permissions that have already been granted

D/SensibilityActivity: Checking permission android.permission.READ_PHONE_STATE
D/SensibilityActivity: Requesting permission android.permission.READ_PHONE_STATE
# .... stripped rest of permission requests that behave like  android.permission.READ_PHONE_STATE

# The activity lifecycle continues in `onStart` and then goes into `onResume` ...

# Then the Permission Request AlertDialog pops up on the UI and the log freezes
# I click YES, then the next Permission is requested, I click YES, then the next ... and so on

# Once I have clicked through all AlertDialogs, the log prints all
# debug statements from the `onRequestPermissionsResult` callback at once:

D/SensibilityActivity: Permission was requested by Sensibility
D/SensibilityActivity: Requested 1 permission(s)
D/SensibilityActivity: Received 1 permission request result(s)
D/SensibilityActivity: Permission granted by user
# ... stripped rest of permission request results

This log, SO and actually just the fact that requestPermissions has a callback function suggest that we are dealing with an asynchronous call. That alone is not necessarily a problem nor an answer to this issue.
Maybe the fact that the log only resumes after all AlertDialogs have been dismissed is an interesting insight? Maybe there is a race condition in the AlertDialog queue on 7.1.1?

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