Skip generating missing permission state for unknown permissions.

Fixes the NullPointerException. Unknown permissions was skipped in
restorePermissionState() when handling changing regarding platform
permissions, so it's safe to skip it when generating missing
(platform) permission state as well.

Test: Flash a recent build without this fix
Test: Install an app which uses an unknown permission
Test: Manually remove app entry in runtime-permissions.xml with root
Test: Reboot device and confirm system server crash and stacktrace
Test: Flash a build with this fix, without clearing data
Test: Confirm system boots, log shows missing permission state was
Test: generated for the app and unknown permission was skipped
Bug: 158860316
Change-Id: Idfc9b5bf6c69772d41ccf781b84a4d101ed1277d
This commit is contained in:
Hai Zhang
2020-06-16 13:28:48 -07:00
parent 9ac716fc8b
commit d8ba685748

View File

@@ -2509,6 +2509,9 @@ public class PermissionManagerService extends IPermissionManager.Stub {
for (String permissionName : requestedPermissions) {
BasePermission permission = mSettings.getPermission(permissionName);
if (permission == null) {
continue;
}
if (Objects.equals(permission.getSourcePackageName(), PLATFORM_PACKAGE_NAME)
&& permission.isRuntime() && !permission.isRemoved()) {
if (permission.isHardOrSoftRestricted()