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

Commit 94582d7a authored by Yi-an Chen's avatar Yi-an Chen
Browse files

Handle privileged permission allowlist and isModule

Bug: 263504888
Test: Build
Change-Id: Id0bc2e7b2402d67a67d9e722ba76067cbff89bcd
parent fb0ae75c
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -211,6 +211,12 @@ class AccessCheckingService(context: Context) : SystemService(context) {
        }
    }

    internal fun onSystemReady() {
        mutateState {
            with(policy) { onSystemReady() }
        }
    }

    private val PackageManagerLocal.allPackageStates:
        Pair<Map<String, PackageState>, Map<String, PackageState>>
        get() = withUnfilteredSnapshot().use { it.packageStates to it.disabledSystemPackageStates }
+9 −0
Original line number Diff line number Diff line
@@ -255,6 +255,13 @@ class AccessPolicy private constructor(
        }
    }

    fun MutateStateScope.onSystemReady() {
        newState.systemState.isSystemReady = true
        forEachSchemePolicy {
            with(it) { onSystemReady() }
        }
    }

    fun BinaryXmlPullParser.parseSystemState(state: AccessState) {
        forEachTag {
            when (tagName) {
@@ -362,6 +369,8 @@ abstract class SchemePolicy {

    open fun MutateStateScope.onPackageUninstalled(packageName: String, appId: Int, userId: Int) {}

    open fun MutateStateScope.onSystemReady() {}

    open fun BinaryXmlPullParser.parseSystemState(state: AccessState) {}

    open fun BinaryXmlSerializer.serializeSystemState(state: AccessState) {}
+4 −0
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ class SystemState private constructor(
    var privilegedPermissionAllowlistPackages: IndexedListSet<String>,
    var permissionAllowlist: PermissionAllowlist,
    var implicitToSourcePermissions: IndexedMap<String, IndexedListSet<String>>,
    var isSystemReady: Boolean,
    // TODO: Get and watch the state for deviceAndProfileOwners
    // Mapping from user ID to package name.
    var deviceAndProfileOwners: IntMap<String>,
    val permissionGroups: IndexedMap<String, PermissionGroupInfo>,
@@ -67,6 +69,7 @@ class SystemState private constructor(
        IndexedListSet(),
        PermissionAllowlist(),
        IndexedMap(),
        false,
        IntMap(),
        IndexedMap(),
        IndexedMap(),
@@ -85,6 +88,7 @@ class SystemState private constructor(
            privilegedPermissionAllowlistPackages,
            permissionAllowlist,
            implicitToSourcePermissions,
            isSystemReady,
            deviceAndProfileOwners,
            permissionGroups.copy { it },
            permissionTrees.copy { it },
+3 −0
Original line number Diff line number Diff line
@@ -91,6 +91,9 @@ data class Permission(
    inline val isKnownSigner: Boolean
        get() = protectionFlags.hasBits(PermissionInfo.PROTECTION_FLAG_KNOWN_SIGNER)

    inline val isModule: Boolean
        get() = protectionFlags.hasBits(PermissionInfo.PROTECTION_FLAG_MODULE)

    inline val isOem: Boolean
        get() = protectionFlags.hasBits(PermissionInfo.PROTECTION_FLAG_OEM)

+1 −1
Original line number Diff line number Diff line
@@ -1709,7 +1709,7 @@ class PermissionService(
    }

    override fun onSystemReady() {
        // TODO STOPSHIP privappPermissionsViolationsfix check
        service.onSystemReady()
        permissionControllerManager = PermissionControllerManager(
            context, PermissionThread.getHandler()
        )
Loading