[英]Android: Grant permissions through ADB
對於我的某些功能應用程序,我需要使用相機,這不是應用程序的核心功能所必需的,所以我需要指定它是可選的使用相機。 所以在清單中我聲明了如下權限:
<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"/>
但是當我嘗試使用以下命令通過adb授予權限時,它會出錯:
pm grant my.app.package android.permission.CAMERA
給出錯誤:
Operation not allowed: java.lang.SecurityException: Can't change android.permission.CAMERA. It is required by the application
我的設備是root用戶,它運行android 5.1.1(22)。 根據ADB 文檔 ,由於權限被聲明為可選,我應該能夠如上所述從adb授予權限。 我引用了這個 , 這個和這個 。 但我仍然無法弄清楚為什么它不起作用的原因。
提前感謝您的建議和建議。
首先,讓我們連接您計算機上的手機,讓我們看看安裝了多少個應用程序:
>> ./adb shell pm list packages
您將獲得包名列表:
[...]
com.google.android.GoogleCamera
[...]
現在我們將獲得所有權限的列表:
>> ./adb shell pm list permissions -d -g
[...]
group:android.permission-group.CAMERA
permission:android.permission.CAMERA
[...]
在這里如何撤銷權限:
>> ./adb shell pm revoke com.google.android.GoogleCamera android.permission.CAMERA
在這里如何授予它:
>> ./adb shell pm grant com.google.android.GoogleCamera android.permission.CAMERA
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.