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

Commit 7672f59b authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[CS] Remove CentralSurfaces from SystemActions.

The NOTIFICATIONS and QUICK_SETTINGS system actions should only be
enabled if the shade exists on the particular Android variant. This adds
a ShadeController#isShadeEnabled method, which is used to only set up
those system actions on the correct variants.

Bug: 277764509
Test: compiles
Change-Id: I614fdc8d782f94c10b6ce7ad953a9f712a5132a6
parent 566b1feb
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.ShadeViewController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.StatusBarWindowCallback;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.Assert;
@@ -186,7 +185,6 @@ public class SystemActions implements CoreStartable {
    private final DisplayTracker mDisplayTracker;
    private Locale mLocale;
    private final AccessibilityManager mA11yManager;
    private final Lazy<Optional<CentralSurfaces>> mCentralSurfacesOptionalLazy;
    private final NotificationShadeWindowController mNotificationShadeController;
    private final KeyguardStateController mKeyguardStateController;
    private final ShadeController mShadeController;
@@ -201,7 +199,6 @@ public class SystemActions implements CoreStartable {
            KeyguardStateController keyguardStateController,
            ShadeController shadeController,
            Lazy<ShadeViewController> shadeViewController,
            Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
            Optional<Recents> recentsOptional,
            DisplayTracker displayTracker) {
        mContext = context;
@@ -222,7 +219,6 @@ public class SystemActions implements CoreStartable {
                (keyguardShowing, keyguardOccluded, keyguardGoingAway, bouncerShowing, mDozing,
                        panelExpanded, isDreaming) ->
                        registerOrUnregisterDismissNotificationShadeAction();
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
    }

    @Override
@@ -310,8 +306,8 @@ public class SystemActions implements CoreStartable {
        mA11yManager.registerSystemAction(actionBack, SYSTEM_ACTION_ID_BACK);
        mA11yManager.registerSystemAction(actionHome, SYSTEM_ACTION_ID_HOME);
        mA11yManager.registerSystemAction(actionRecents, SYSTEM_ACTION_ID_RECENTS);
        if (mCentralSurfacesOptionalLazy.get().isPresent()) {
            // These two actions require the CentralSurfaces instance.
        if (mShadeController.isShadeEnabled()) {
            // These two actions require the shade to be enabled.
            mA11yManager.registerSystemAction(actionNotifications, SYSTEM_ACTION_ID_NOTIFICATIONS);
            mA11yManager.registerSystemAction(actionQuickSettings, SYSTEM_ACTION_ID_QUICK_SETTINGS);
        }
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
 * {@link com.android.systemui.keyguard.KeyguardViewMediator} and others.
 */
public interface ShadeController extends CoreStartable {
    /** True if the shade UI is enabled on this particular Android variant and false otherwise. */
    boolean isShadeEnabled();

    /** Make our window larger and the shade expanded */
    void instantExpandShade();
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import javax.inject.Inject
/** Empty implementation of ShadeController for variants of Android without shades. */
@SysUISingleton
open class ShadeControllerEmptyImpl @Inject constructor() : ShadeController {
    override fun isShadeEnabled() = false
    override fun start() {}
    override fun instantExpandShade() {}
    override fun instantCollapseShade() {}
+5 −0
Original line number Diff line number Diff line
@@ -113,6 +113,11 @@ public final class ShadeControllerImpl implements ShadeController {
        mAssistManagerLazy = assistManagerLazy;
    }

    @Override
    public boolean isShadeEnabled() {
        return true;
    }

    @Override
    public void instantExpandShade() {
        // Make our window larger and the panel expanded.
+0 −6
Original line number Diff line number Diff line
@@ -40,11 +40,8 @@ import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.ShadeViewController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.policy.KeyguardStateController;

import dagger.Lazy;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -70,8 +67,6 @@ public class SystemActionsTest extends SysuiTestCase {
    @Mock
    private ShadeViewController mShadeViewController;
    @Mock
    private Lazy<Optional<CentralSurfaces>> mCentralSurfacesOptionalLazy;
    @Mock
    private Optional<Recents> mRecentsOptional;
    @Mock
    private TelecomManager mTelecomManager;
@@ -93,7 +88,6 @@ public class SystemActionsTest extends SysuiTestCase {
                mKeyguardStateController,
                mShadeController,
                () -> mShadeViewController,
                mCentralSurfacesOptionalLazy,
                mRecentsOptional,
                mDisplayTracker);
    }