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

Commit 8f5e6f8b authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[CS] Make NPVC and QuickSettingsController singletons.

Most of this change is having ShadeController rely on the
ShadeViewController interface instead of on
NotificationPanelViewController directly, which required adding some
additional methods to ShadeViewController.

Bug: 277762009
Test: verified keyguard bottom area works with MIGRATE_INDICATION_AREA
flag off and on (verified indication text updates based on events,
updates based on font changes)
Test: verify shade works: displays notifs, notifs can be expanded,
notifs can be swiped away, shade reinflated on font change, etc.
Test: verify QS works: tiles display, tiles update based on taps, etc.

Test: atest CentralSurfacesImplTest ShadeControllerImplTest
NotificationPanelViewControllerTest

Change-Id: Ib2cb857374a094402898b5179ed9fb7b4e399035
parent eda7ede2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ constructor(
        // At startup, 2 views with the ID `R.id.keyguard_indication_area` will be available.
        // Disable one of them
        if (featureFlags.isEnabled(Flags.MIGRATE_INDICATION_AREA)) {
            legacyParent.requireViewById<View>(R.id.keyguard_indication_area).let {
            legacyParent.findViewById<View>(R.id.keyguard_indication_area)?.let {
                legacyParent.removeView(it)
            }
        } else {
+14 −23
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants;
import com.android.systemui.classifier.Classifier;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeLog;
@@ -208,7 +209,6 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarTouchableRegionManager;
import com.android.systemui.statusbar.phone.TapAgainViewController;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent;
import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragment;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardQsUserSwitchController;
@@ -238,7 +238,7 @@ import kotlin.Unit;

import kotlinx.coroutines.CoroutineDispatcher;

@CentralSurfacesComponent.CentralSurfacesScope
@SysUISingleton
public final class NotificationPanelViewController implements ShadeSurface, Dumpable {

    public static final String TAG = NotificationPanelView.class.getSimpleName();
@@ -1407,11 +1407,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        mKeyguardBottomArea = keyguardBottomArea;
    }

    void setOpenCloseListener(OpenCloseListener openCloseListener) {
    @Override
    public void setOpenCloseListener(OpenCloseListener openCloseListener) {
        mOpenCloseListener = openCloseListener;
    }

    void setTrackingStartedListener(TrackingStartedListener trackingStartedListener) {
    @Override
    public void setTrackingStartedListener(TrackingStartedListener trackingStartedListener) {
        mTrackingStartedListener = trackingStartedListener;
    }

@@ -3378,11 +3380,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        ViewGroupFadeHelper.reset(mView);
    }

    void addOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener listener) {
    @Override
    public void addOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener listener) {
        mView.getViewTreeObserver().addOnGlobalLayoutListener(listener);
    }

    void removeOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener listener) {
    @Override
    public void removeOnGlobalLayoutListener(ViewTreeObserver.OnGlobalLayoutListener listener) {
        mView.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
    }

@@ -3847,8 +3851,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        return !isFullyCollapsed() && !mTracking && !mClosing;
    }

    /** Collapses the shade instantly without animation. */
    void instantCollapse() {
    @Override
    public void instantCollapse() {
        abortAnimations();
        setExpandedFraction(0f);
        if (mExpanding) {
@@ -4021,8 +4025,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
        mFixedDuration = NO_FIXED_DURATION;
    }

    /** */
    boolean postToView(Runnable action) {
    @Override
    public boolean postToView(Runnable action) {
        return mView.post(action);
    }

@@ -5113,18 +5117,5 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump
            return super.performAccessibilityAction(host, action, args);
        }
    }

    /** Listens for when touch tracking begins. */
    interface TrackingStartedListener {
        void onTrackingStarted();
    }

    /** Listens for when shade begins opening of finishes closing. */
    interface OpenCloseListener {
        /** Called when the shade finishes closing. */
        void onClosingFinished();
        /** Called when the shade starts opening. */
        void onOpenStarted();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.classifier.Classifier;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.fragments.FragmentHostManager;
@@ -98,7 +99,6 @@ import com.android.systemui.statusbar.phone.LockscreenGestureLogger;
import com.android.systemui.statusbar.phone.ScrimController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.StatusBarTouchableRegionManager;
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent;
import com.android.systemui.statusbar.policy.CastController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.LargeScreenUtils;
@@ -113,7 +113,7 @@ import javax.inject.Inject;
/** Handles QuickSettings touch handling, expansion and animation state
 * TODO (b/264460656) make this dumpable
 */
@CentralSurfacesComponent.CentralSurfacesScope
@SysUISingleton
public class QuickSettingsController implements Dumpable {
    public static final String TAG = "QuickSettingsController";

+1 −2
Original line number Diff line number Diff line
@@ -165,8 +165,7 @@ public interface ShadeController {
            NotificationShadeWindowViewController notificationShadeWindowViewController);

    /** */
    void setNotificationPanelViewController(
            NotificationPanelViewController notificationPanelViewController);
    void setShadeViewController(ShadeViewController shadeViewController);

    /** Listens for shade visibility changes. */
    interface ShadeVisibilityListener {
+5 −5
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ public final class ShadeControllerImpl implements ShadeController {

    private boolean mExpandedVisible;

    private NotificationPanelViewController mNotificationPanelViewController;
    // TODO(b/237661616): Rename this variable to mShadeViewController.
    private ShadeViewController mNotificationPanelViewController;
    private NotificationPresenter mPresenter;
    private NotificationShadeWindowViewController mNotificationShadeWindowViewController;
    private ShadeVisibilityListener mShadeVisibilityListener;
@@ -426,12 +427,11 @@ public final class ShadeControllerImpl implements ShadeController {
    }

    @Override
    public void setNotificationPanelViewController(
            NotificationPanelViewController notificationPanelViewController) {
        mNotificationPanelViewController = notificationPanelViewController;
    public void setShadeViewController(ShadeViewController shadeViewController) {
        mNotificationPanelViewController = shadeViewController;
        mNotificationPanelViewController.setTrackingStartedListener(this::runPostCollapseRunnables);
        mNotificationPanelViewController.setOpenCloseListener(
                new NotificationPanelViewController.OpenCloseListener() {
                new OpenCloseListener() {
                    @Override
                    public void onClosingFinished() {
                        ShadeControllerImpl.this.onClosingFinished();
Loading