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

Commit 92d6a8bf authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Add test for permission controller dump code

- Only test very basic stuff for now. Still this make sure that dumping
  in general works

- This adds a new test suite for out of prcoess permission controller
  tests. This is for tests that are not CTS, need to interact with the
  system (i.e. not mocking) and should not run in the permission
  controller process.

Fixed two issues:
- Do not nest lifecycles in AutoRevokeStateLiveData
- Do not re-register for package changed when live data is not active in
  LightPkgInfoLD and PermStateLD

Test: atest PermissionControllerOutOfProcessTest
Bug: 151252163
Fixes: 11484369
Change-Id: Ifdd7ddcfde0a03145663f88bb9c9c19dbf3da649
parent 9eb10803
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -36,6 +36,13 @@ filegroup {
    srcs: [
        "src/**/*.java",
        "src/**/*.kt",
        ":permissioncontroller-protos",
    ],
}

filegroup {
    name: "permissioncontroller-protos",
    srcs: [
        "src/**/*.proto",
    ],
}
+10 −4
Original line number Diff line number Diff line
@@ -59,11 +59,17 @@ class AutoRevokeStateLiveData private constructor(
    }

    override suspend fun loadDataAndPostValue(job: Job) {
        val uid = packageLiveData.value?.uid
        if (uid == null && packageLiveData.isInitialized) {
        if (!packageLiveData.isInitialized) {
            return
        }
        if (packageLiveData.value == null) {
            postValue(null)
            return
        } else if (uid == null) {
        }

        val uid = packageLiveData.value?.uid
        if (uid == null) {
            postValue(null)
            return
        }

@@ -81,7 +87,7 @@ class AutoRevokeStateLiveData private constructor(
            return
        }

        val revocable = !isPackageAutoRevokeExempt(app, packageLiveData.getInitializedValue())
        val revocable = !isPackageAutoRevokeExempt(app, packageLiveData.value!!)
        val autoRevokeState = mutableListOf<String>()
        permStateLiveDatas.forEach { (groupName, liveData) ->
            val default = liveData.value?.any { (_, permState) ->
+8 −4
Original line number Diff line number Diff line
@@ -69,11 +69,15 @@ class LightPackageInfoLiveData private constructor(
        newValue?.let { packageInfo ->
            if (packageInfo.uid != uid) {
                uid = packageInfo.uid

                // registeredUid == null means the live data is not active
                if (registeredUid != null) {
                    PermissionListenerMultiplexer.addOrReplaceCallback(registeredUid,
                            packageInfo.uid, this)
                    registeredUid = uid
                }
            }
        }
        super.setValue(newValue)
    }

+3 −2
Original line number Diff line number Diff line
@@ -113,7 +113,8 @@ class PermStateLiveData private constructor(
            return
        }
        uid = packageInfo.uid
        if (uid != registeredUid) {
        // registeredUid == null means the live data is not active
        if (uid != registeredUid && registeredUid != null) {
            PermissionListenerMultiplexer.addOrReplaceCallback(
                registeredUid, packageInfo.uid, this)
            registeredUid = uid
+8 −0
Original line number Diff line number Diff line
@@ -24,6 +24,14 @@
                    "exclude-annotation": "androidx.test.filters.FlakyTest"
                }
            ]
        },
        {
            "name": "PermissionControllerOutOfProcessTests",
            "options": [
                {
                    "include-filter": "com.android.permissioncontroller.tests.outofprocess.DumpTest"
                }
            ]
        }
    ],
    "presubmit-devicepolicy": [
Loading