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

Commit 6336ca47 authored by Evan Severson's avatar Evan Severson
Browse files

Update task manager ui information on dialog opening

A proper fix would be to have a listner for changes to
getBackgroundRestrictionExemptionReason(), but creating this listener
mechanism would be very difficult since the value is computed on demand
and there's a lot of signals that go into it.

This change works around by refreshing the ui information when the
dialog is opened. In theory we should also update the values when the
footer is shown but this will cause a lot of IPCs and with the current
policies the ui in the footer won't actually change as a result of the
exemption reason code changing.

Test: Change the battery restriction and validate UI has changed.
Fixes: 228306315
Change-Id: I61857df989ea6015c91dbd60db1d700a1dde266e
parent 2f58e1c3
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -229,6 +229,10 @@ class FgsManagerController @Inject constructor(
        synchronized(lock) {
            if (dialog == null) {

                runningServiceTokens.keys.forEach {
                    it.updateUiControl()
                }

                val dialog = SystemUIDialog(context)
                dialog.setTitle(R.string.fgs_manager_dialog_title)

@@ -397,10 +401,20 @@ class FgsManagerController @Inject constructor(
        val userId: Int,
        val packageName: String
    ) {
        val uiControl: UIControl by lazy {
            val uid = packageManager.getPackageUidAsUser(packageName, userId)
        val uid by lazy { packageManager.getPackageUidAsUser(packageName, userId) }

        private var uiControlInitialized = false
        var uiControl: UIControl = UIControl.NORMAL
            get() {
                if (!uiControlInitialized) {
                    updateUiControl()
                }
                return field
            }
            private set

            when (activityManager.getBackgroundRestrictionExemptionReason(uid)) {
        fun updateUiControl() {
            uiControl = when (activityManager.getBackgroundRestrictionExemptionReason(uid)) {
                PowerExemptionManager.REASON_SYSTEM_UID,
                PowerExemptionManager.REASON_DEVICE_DEMO_MODE -> UIControl.HIDE_ENTRY

@@ -413,6 +427,7 @@ class FgsManagerController @Inject constructor(
                PowerExemptionManager.REASON_SYSTEM_MODULE -> UIControl.HIDE_BUTTON
                else -> UIControl.NORMAL
            }
            uiControlInitialized = true
        }

        override fun equals(other: Any?): Boolean {