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

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

Merge "Cork PackageInfo cache for onStorageVolumeMounted() and onUserCreated()."

parents 4bf15518 71eeae18
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -2009,8 +2009,10 @@ class PermissionService(
    }

    override fun onUserCreated(userId: Int) {
        withCorkedPackageInfoCache {
            service.onUserAdded(userId)
        }
    }

    override fun onUserRemoved(userId: Int) {
        service.onUserRemoved(userId)
@@ -2024,8 +2026,10 @@ class PermissionService(
            packageNames = storageVolumePackageNames.remove(volumeUuid) ?: emptyList()
            mountedStorageVolumes += volumeUuid
        }
        withCorkedPackageInfoCache {
            service.onStorageVolumeMounted(volumeUuid, packageNames, fingerprintChanged)
        }
    }

    override fun onPackageAdded(
        packageState: PackageState,
@@ -2120,6 +2124,15 @@ class PermissionService(
        }
    }

    private inline fun <T> withCorkedPackageInfoCache(block: () -> T): T {
        PackageManager.corkPackageInfoCache()
        try {
            return block()
        } finally {
            PackageManager.uncorkPackageInfoCache()
        }
    }

    /**
     * Check whether a UID is root or system UID.
     */