READ_PHONE_STATE permission seems to be actively rejected in Android 11 - android

I have an application with following permissions in Manifest:
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I manually enabled all permissions through Settings in an Android 11 mobile. However, if I use ActivityCompat.checkSelfPermission(this,(Manifest.permission.READ_PHONE_STATE)) to check if READ_PHONE_STATE permission has been granted, the result is always PERMISSION_DENIED.
I then used ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.READ_PHONE_STATE), 102), which simply calls onRequestPermissionsResult with grant result PERMISSION_DENIED immediately.
I reproduced this on two Android 11 devices (one physical, one emulator), and I tried changing the package name, uninstalling and reinstalling the app etc.

I figured out what went wrong. One of the libraries I was including had this:
Library's Manifest
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
android:maxSdkVersion="29" />
and even though I defined this permission in my app manifest, the maxSdkVersion got into my app.
The solution is to remove the maxSdkVersion property in your app:
App's Manifest
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
tools:remove="android:maxSdkVersion" />

Related

location permission missing (code 3) - Android 12

I am working for an application which uses BLE technology for pairing and IOT device and uses precises location to perform some specific task related to application requirements
Now, on Android 12 some device (I tested on SAMSUNG SM-M21)
it ended up in error
location permission missing (code 3)
whereas in another device like Realme, Mi it works fine as expected
After referring to the article
https://developer.android.com/guide/topics/connectivity/bluetooth/permissions
I already added these permission in the Manifest
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
I am already requesting permission at runtime from user
If any more information is needed, please let me know. I will update the question accordingly.
I solved it by adding this to manifest
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation" />
and at code level added a condition which add extra permission runtime only for Android 12 and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
//requesting permission only for Android 12 and above
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.BLUETOOTH_ADVERTISE,
}
Note: other permissions also as normally requested

App not using sensitive permissions but cant release

I tried every thing, i deleted any apks in beta and alpha . i dont have any sensitive permissions in my app , here are my requested permissions in manifest:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" />
and when uploading a new release it says i'm using sensitive permissions that wasnt declared, it shows the below permissions :
3 differentiating:
android.permission.ACCESS_WIFI_STATE,
android.permission.FOREGROUND_SERVICE,
com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE
11 common:
android.permission.ACCESS_COARSE_LOCATION,
android.permission.ACCESS_FINE_LOCATION,
android.permission.ACCESS_NETWORK_STATE, android.permission.INTERNET,
android.permission.READ_EXTERNAL_STORAGE, android.permission.WAKE_LOCK,
android.permission.WRITE_EXTERNAL_STORAGE, com.android.vending.BILLING,
com.google.android.c2dm.permission.RECEIVE,
com.google.android.providers.gsf.permission.READ_GSERVICES,
com.quantyam.controllcenter.Sokan.permission.C2D_MESSAGE
I used to have sensitive apps request like 3 releases ago and the last two times I uploaded i never had this issue
I now fixed the issue , and here is how :
First go to Create release then Add from Library , then I picked up a version from my app where it uses SMS & Call permissions . then it showed me the declaration form which i filled and clicked review.
Then clicked on previous and uploaded new version and it worked perfectly

Which permissions do I need to call requestPermission() - Android

I'm setting up some permissions in my AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
I request the permission on runtime for all of those permissions.
But somehow the permission REQUEST_INSTALL_PACKAGES does not need to call requestPermission(). If I try to call it anyway, the popup never appears.
Is there a list of permissions i need to call at runtime?
My current android version is 8.0.0.
Thanks
Depends on type of permission you are requesting for. There are two kind of permissions in Android: Normal and Dangerous Permissions
If there are dangerous, you must request for it at runtime for API level 23 and above.
For more info you should read following documentation: https://developer.android.com/guide/topics/permissions/requesting.html#normal-dangerous

Android: Why is android.permission.ACCESS_WIFI_STATE automatically added to my signed apk build?

My app uses a couple of permission:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
and:
android:permission="com.google.android.c2dm.permission.SEND">
Yesterday I uploaded a new version to google play and somehow the
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
has been added and thus users won't get an auto update of my app but have to give permission first. I don't want this permission added to my project, but I have no idea how to remove it since pre-build it's not requested in my code anywhere.
Does anyone have some advice?
I was able to remove the permission by adding:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
tools:node="remove"/>
Also #Arnav: I wasn't using any functionality of the library that needed this permission so removing caused no issues.
The library projects as dependency needs to be used as this require that permission. You have enabled the manifestmerger property true in project properties () because of which this issue may occurs.
This permission can be removed as follow:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
tools:node="remove"/>

android.permission.WRITE_SETTINGS error

I'm trying to modify some settings on my phone through the app but I keep getting
this error:
java.lang.SecurityException: Permission denial: writing to settings requires android.permission.WRITE_SETTINGS
I have added this permission to my manifest but the error still remains.
Here is a snippet from my manifest:
<uses-permission
android:name="android.permission.MEDIA_CONTENT_CONTROL"
android:maxSdkVersion="11" />
<uses-permission
android:name="android.permission.CHANGE_CONFIGURATION"
android:maxSdkVersion="11" />
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
android:maxSdkVersion="11" />
<uses-permission
android:name="android.permission.WRITE_SETTINGS"
android:maxSdkVersion="11" />
What is the problem here?
try like:
<uses-permission
android:name="android.permission.MEDIA_CONTENT_CONTROL"/>
<uses-permission
android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission
android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-sdk
android:maxSdkVersion="11"
android:minSdkVersion="7"
android:targetSdkVersion="9" />
Note: It is not good to use android:maxSdkVersion in manifest. You can remove it.
Android doc says,
android:maxSdkVersion The highest API level at which this permission should be granted to your app. Setting this attribute is
useful if the permission your app requires is no longer needed
beginning at a certain API level.
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
This way, beginning with API level 19, the system will no longer grant
your app the WRITE_EXTERNAL_STORAGE permission.
In which SDK version do you run this code?
For Android version 11 & below, permission will be granted as per your code.
If you do not want to limit the permission with respect to particular sdk versions, remove the maxSdkVersion attribute.

Categories

Resources