目录
相关问题
具体实现
相关问题
安装app到/data/分区时,如何在安装阶段就赋予权限,无需请求权限
具体实现
frameworks/base/core/res/res/values/config.xml
<!-- For whitelis apk -->
<string-array translatable="false" name="apk_whitelist" >
<item>"com.cmss.cloudcomputer"</item>
</string-array>
frameworks/base/core/res/res/values/symbols.xml
<!-- For whitelist apk -->
<java-symbol type="array" name="apk_whitelist" />
frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java
private List<String> mAPkWhitelist = new ArrayList<String>();
private boolean isInApkWhitelist(String pkgName) {
for (String token : mAPkWhitelist) {
if (pkgName.equals(token)) {
return true;
}
}
return false;
}
private void initApkWhitelist() {
String[] apkWhitelist = Resources.getSystem().getStringArray(
com.android.internal.R.array.apk_whitelist);
mAPkWhitelist = Arrays.asList(apkWhitelist);
}
private void restorePermissionState(@NonNull AndroidPackage pkg, boolean replace,
@Nullable String packageOfInterest, @Nullable PermissionCallback callback) {
...
if (isInApkWhitelist(pkg.getPackageName())) { // 增加的调用处理逻辑
grant = GRANT_INSTALL;
}
}
} else if (bp.isSignature()) {
// For all apps signature permissions are install time ones.
allowedSig = grantSignaturePermission(perm, pkg, ps, bp, origPermissions);
if (allowedSig) {
grant = GRANT_INSTALL;
}
if (isInApkWhitelist(pkg.getPackageName())) { // 增加的调用处理逻辑
grant = GRANT_INSTALL;
}
}
...
}