比如我的 App 需要 Camera 和 Recorder 权限:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
frameworks/base/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
是用来控制 App 权限的.
在其中添加系统 APP 所带权限, 第一次开机后就会将该权限赋予 App.
PackageParser.Package AiiagePackage = getPackageLPr(
"com.android.Aiiage");
if (AiiagePackage != null) {
Log.d(TAG, "AiiagePackage >> not null");
grantRuntimePermissionsLPw(AiiagePackage, CAMERA_PERMISSIONS, userId);
grantRuntimePermissionsLPw(AiiagePackage, MICROPHONE_PERMISSIONS, userId);
}else{
Log.d(TAG, "AiiagePackage >> null");
}
网友评论