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

Commit 0424ab14 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Set default for controls as enabled.

From this CL onwards, the default for controls is enabled (still not a
Setting).

The controls section in power menu and the new layout will only be used
if there's at least one app that can provide controls.

Test: manual
Bug: 149992619
Change-Id: I4e78735d642d24fe0080a0f0f4cbc58ffa2d5a94
parent 7b27da1d
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ class ControlsControllerImpl @Inject constructor (
        internal const val CONTROLS_AVAILABLE = "systemui.controls_available"
        internal val URI = Settings.Secure.getUriFor(CONTROLS_AVAILABLE)
        private const val USER_CHANGE_RETRY_DELAY = 500L // ms
        private const val DEFAULT_ENABLED = 1
    }

    // Map of map: ComponentName -> (String -> ControlInfo).
@@ -79,7 +80,8 @@ class ControlsControllerImpl @Inject constructor (

    private val contentResolver: ContentResolver
        get() = context.contentResolver
    override var available = Settings.Secure.getInt(contentResolver, CONTROLS_AVAILABLE, 0) != 0
    override var available = Settings.Secure.getInt(
            contentResolver, CONTROLS_AVAILABLE, DEFAULT_ENABLED) != 0
        private set

    private var currentUser = context.user
@@ -104,7 +106,7 @@ class ControlsControllerImpl @Inject constructor (
                userContext.filesDir, ControlsFavoritePersistenceWrapper.FILE_NAME)
        persistenceWrapper.changeFile(fileName)
        available = Settings.Secure.getIntForUser(contentResolver, CONTROLS_AVAILABLE,
                /* default */ 0, newUser.identifier) != 0
                /* default */ DEFAULT_ENABLED, newUser.identifier) != 0
        synchronized(currentFavorites) {
            currentFavorites.clear()
        }
@@ -140,7 +142,7 @@ class ControlsControllerImpl @Inject constructor (
                return
            }
            available = Settings.Secure.getIntForUser(contentResolver, CONTROLS_AVAILABLE,
                    /* default */ 0, currentUserId) != 0
                    /* default */ DEFAULT_ENABLED, currentUserId) != 0
            synchronized(currentFavorites) {
                currentFavorites.clear()
            }
+10 −2
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import com.android.systemui.MultiListLayout;
import com.android.systemui.MultiListLayout.MultiListAdapter;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.controls.management.ControlsListingController;
import com.android.systemui.controls.ui.ControlsUiController;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
@@ -189,6 +190,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
    private ControlsUiController mControlsUiController;
    private final IWindowManager mIWindowManager;
    private final Executor mBackgroundExecutor;
    private final ControlsListingController mControlsListingController;
    private boolean mAnyControlsProviders = false;

    /**
     * @param context everything needs a context :(
@@ -208,7 +211,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            IStatusBarService statusBarService,
            NotificationShadeWindowController notificationShadeWindowController,
            ControlsUiController controlsUiController, IWindowManager iWindowManager,
            @Background Executor backgroundExecutor) {
            @Background Executor backgroundExecutor,
            ControlsListingController controlsListingController) {
        mContext = new ContextThemeWrapper(context, com.android.systemui.R.style.qs_theme);
        mWindowManagerFuncs = windowManagerFuncs;
        mAudioManager = audioManager;
@@ -232,6 +236,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
        mControlsUiController = controlsUiController;
        mIWindowManager = iWindowManager;
        mBackgroundExecutor = backgroundExecutor;
        mControlsListingController = controlsListingController;

        // receive broadcasts
        IntentFilter filter = new IntentFilter();
@@ -268,6 +273,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
                }
            }
        });

        mControlsListingController.addCallback(list -> mAnyControlsProviders = !list.isEmpty());
    }

    /**
@@ -1914,6 +1921,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,

    private boolean shouldShowControls() {
        return mKeyguardStateController.isUnlocked()
                && mControlsUiController.getAvailable();
                && mControlsUiController.getAvailable()
                && mAnyControlsProviders;
    }
}