For my application for some functionalities, I need to use the camera, which is not required to the core functionality of the application, so I need to specify the it's optional to use camera. So in the manifest I declared the permission as follows:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
But when I try to grant permission through adb using the following command it gives an error:
pm grant my.app.package android.permission.CAMERA
gives the error:
Operation not allowed: java.lang.SecurityException: Can't change android.permission.CAMERA. It is required by the application
My device is a rooted one and it runs android 5.1.1(22). According to the ADB documentation, since the permission is declared as optional, I should be able to grant permission from adb as mentioned above. I have referenced this, this and this. But still I couldn't figure out a reason for why it's not working.
Thank you in advance for suggestions and recommendations.
First of all, let’s connect a phone on your computer and let’s see how many apps are installed:
>> ./adb shell pm list packages
You will get a list of package names:
[...]
com.google.android.GoogleCamera
[...]
Now we are going to get the list of all the permissions:
>> ./adb shell pm list permissions -d -g
[...]
group:android.permission-group.CAMERA
permission:android.permission.CAMERA
[...]
And here how to revoke the permission:
>> ./adb shell pm revoke com.google.android.GoogleCamera android.permission.CAMERA
and here how to grant it back:
>> ./adb shell pm grant com.google.android.GoogleCamera android.permission.CAMERA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With