Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 420d62b8 authored by Hai Zhang's avatar Hai Zhang Committed by Android (Google) Code Review
Browse files

Merge "Fix NPEs in DevicePermissionPolicy." into main

parents f1e1be0f c78e8c3c
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -94,7 +94,9 @@ class DevicePermissionPolicy : SchemePolicy() {
        isSystemUpdated: Boolean
    ) {
        packageNames.forEachIndexed { _, packageName ->
            val packageState = newState.externalState.packageStates[packageName]!!
            // The package may still be removed even if it was once notified as installed.
            val packageState = newState.externalState.packageStates[packageName]
                ?: return@forEachIndexed
            trimPermissionStates(packageState.appId)
        }
    }
@@ -245,6 +247,13 @@ class DevicePermissionPolicy : SchemePolicy() {
        flagMask: Int,
        flagValues: Int
    ): Boolean {
        if (userId !in newState.userStates) {
            // Despite that we check UserManagerInternal.exists() in PermissionService, we may still
            // sometimes get race conditions between that check and the actual mutateState() call.
            // This should rarely happen but at least we should not crash.
            Slog.e(LOG_TAG, "Unable to update permission flags for missing user $userId")
            return false
        }
        val oldFlags =
            newState.userStates[userId]!!
                .appIdDevicePermissionFlags[appId]