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

Commit 02a0f98d authored by Nate Myren's avatar Nate Myren Committed by Android (Google) Code Review
Browse files

Merge "Convert onUpgradeLocked to LiveData"

parents 07e684f5 32461739
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ object ForegroundPermNamesLiveData : SmartUpdateMediatorLiveData<Map<String, Lis

    // Since the value will be static, initialize the value upon creating the LiveData.
    init {
        updateIfActive()
        onUpdate()
    }

    override fun onUpdate() {
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ abstract class SmartAsyncMediatorLiveData<T> : SmartUpdateMediatorLiveData<T>()
            return
        }

        GlobalScope.launch(Dispatchers.Default) {
        GlobalScope.launch(Dispatchers.IO) {
            currentJob = coroutineContext[Job]
            loadDataAndPostValue(currentJob!!)
        }
+0 −1
Original line number Diff line number Diff line
@@ -109,7 +109,6 @@ abstract class SmartUpdateMediatorLiveData<T> : MediatorLiveData<T>(),
        if (DEBUG_UPDATES) {
            Log.i(LOG_TAG, "updateIfActive ${javaClass.simpleName} ${shortStackTrace()}")
        }
        ensureMainThread()
        onUpdate()
    }

+2 −3
Original line number Diff line number Diff line
@@ -58,9 +58,8 @@ class UserPackageInfosLiveData private constructor(
        if (job.isCancelled) {
            return
        }
        var packageInfos = app.applicationContext.packageManager
            .getInstalledPackagesAsUser(GET_PERMISSIONS or MATCH_ALL,
                user.identifier)
        val packageInfos = app.applicationContext.packageManager
            .getInstalledPackagesAsUser(GET_PERMISSIONS or MATCH_ALL, user.identifier)
        postValue(packageInfos.map { packageInfo -> LightPackageInfo(packageInfo) })
    }

+27 −11
Original line number Diff line number Diff line
@@ -41,6 +41,17 @@ data class LightAppPermGroup(
) {
    constructor(pI: LightPackageInfo, pGI: LightPermGroupInfo, perms: Map<String, LightPermission>):
        this(pI, pGI, perms, false, null)

    /**
     * The package name of this group
     */
    val packageName = packageInfo.packageName

    /**
     * The permission group name of this group
     */
    val permGroupName = permGroupInfo.name

    /**
     * The current userHandle of this AppPermGroup.
     */
@@ -124,32 +135,37 @@ data class LightAppPermGroup(
        private val specialLocationGrant: Boolean?
    ) {
        /**
         * Whether any of this App Permission Group's foreground permissions are fixed by policy
         * Whether any of this App Permission SubGroup's permissions are granted
         */
        val isPolicyFixed = permissions.any { it.value.isPolicyFixed }
        val isGranted = specialLocationGrant ?: permissions.any { it.value.isGrantedIncludingAppOp }

        /**
         * Whether this App Permission Group's permissions are fixed by the system
         * Whether any of this App Permission SubGroup's permissions are granted by default
         */
        val isSystemFixed = permissions.any { it.value.isSystemFixed }
        val isGrantedByDefault = permissions.any { it.value.isGrantedByDefault }

        /**
         * Whether this App Permission Group's permissions are fixed by the user
         * Whether any of this App Permission Subgroup's foreground permissions are fixed by policy
         */
        val isUserFixed = permissions.any { it.value.isUserFixed }
        val isPolicyFixed = permissions.any { it.value.isPolicyFixed }

        /**
         * Whether any of this App Permission SubGroup's permissions are granted
         * Whether any of this App Permission Subgroup's permissions are fixed by the system
         */
        val isGranted = specialLocationGrant ?: permissions.any { it.value.isGrantedIncludingAppOp }
        val isSystemFixed = permissions.any { it.value.isSystemFixed }

        /**
         * Whether any of this App Permission SubGroup's permissions are granted by default
         * Whether any of this App Permission Subgroup's permissions are fixed by the user
         */
        val isGrantedByDefault = permissions.any { it.value.isGrantedByDefault }
        val isUserFixed = permissions.any { it.value.isUserFixed }

        /**
         * Whether any of this App Permission Subgroup's permissions are set by the user
         */
        val isUserSet = permissions.any { it.value.isUserSet }

        /**
         * Whether any of this App Permission SubGroup's permissions are granted by their role
         * Whether any of this App Permission Subgroup's permissions are set by the role of this app
         */
        val isGrantedByRole = permissions.any { it.value.isGrantedByRole }
    }
Loading