set permission GET_ACCOUNTS
required only upto android 5.1
#5863
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
App showed permission
Contact
which we never ask and the app do not even have the use of it. This PR aims to fix that.Fixes #4740
What changes did you make and why?
Issue:
We had
Contacts
permission showing in the permission settings our app. Though we don't ask it at runtime but still it is sensitive permission and could be concerning for user.We don't have this permission defined in the
manifest
but it still shows why? because android mapspermissions
to theirpermission-group
. So, every permission comes under a defined permission group. Now, in the settings page of applications android shows the permission by theirgroup's
name.We can check what permissions comes under a certain group using getPlatformPermissionsForGroup() . You can see below the permission we defined in our manifest
android.permission.GET_ACCOUNTS
was the reason we had thisContacts
group showing in settings.Solution:
We know the reason is this
android.permission.GET_ACCOUNTS
permission. Fortunately there's an easy fix. In the docs of this permission there's a noteSince, our
authenticator
implementation is only for our own defined account (wikimedia) so they share the same signature with the app itself. That means we have full control over an account (onwards Android 6) without the need for permission as long as signature is same.Permission is only required below Android 5.1. That is why I set the permission to be used on Android 5.1 and below. Now, we won't see
Contacts
permission in these versions because permission are only categorized by groups from Android 6 onwards.link
So, we see something like this on Android 5.1 and below.
Also, it should be noted that we were not asking permission at runtime anyways. This also shows that application runs fine without this permission. On Android 5.1 and below there was no concept of runtime permission but they were granted while installation so we didn't see any crashes due to permission not being granted. We can safely remove this permission onwards Android 6
Tests performed (required)
Tested: Login, Logout works fine.
Emulator (Android 5.1 & 5) (permission required)
Emulator (Android 7.1, 13, 14) (without permission)
Oneplus 9RT 5G (Android 14)