AOSP 权限的默认授予
环境Android 8.1
Android的权限等级分为normal,dangerous,signature,signatureOrSystem
normal是在AndroidManifest中声明即可获取的低风险权限;
dangerous是需要在获取时提示用户的高风险权限,也就是Runtime权限;
signature是request权限的app和声明权限的app签名一致的时候才能自动获去的权限,也叫签名权限/特许权限;
signatureOrSystem在api 23 废弃。
运行时权限
运行时权限的默认授予工作由DefaultPermissionGrantPolicy类的grantDefaultPermissions完成。 调用的时机有2个:
void onNewUserCreated(final int userId){
mDefaultPermissionPolicy.grantDefaultPermissions(userId);
// If permission review for legacy apps is required, we represent
// dagerous permissions for such apps as always granted runtime
// permissions to keep per user flag state whether review is needed.
// Hence, if a new user is added we have to propagate dangerous
// permission grants for these legacy apps.
if (mPermissionReviewRequired) {
updatePermissionsLPw(null, null, UPDATE_PERMISSIONS_ALL
| UPDATE_PERMISSIONS_REPLACE_ALL);
}
}
复制代码
2.systemReady的时候
@Override
public void systemReady(){
enforceSystemOrRoot(“Only the system can claim the system is ready”);
mSystemReady = true;
……
// If