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

Commit cd81b370 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[CS] Remove CentralSurfaces from ScreenPinningRequest.

Instead, call NavigationBarController directly. (NavBarController is
injected lazily to avoid a cycle NavBarController ->
OverviewProxyService -> ScreenPinningRequest -> NavBarController. This
is at least better than injecting CentralSurfaces lazily :) )

Bug: 277764509
Test: pin app -> verify screen pinning request UI looks correct, draws 3
button nav in white icons

Change-Id: Ia17eac4c020ed0d19a90681386ed3e7bfca73327
parent 25f99902
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -57,15 +57,14 @@ import com.android.systemui.CoreStartable;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.navigationbar.NavigationBarController;
import com.android.systemui.navigationbar.NavigationBarView;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.util.leak.RotationUtils;

import java.util.ArrayList;
import java.util.Optional;

import javax.inject.Inject;

@@ -77,8 +76,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
    private static final String TAG = "ScreenPinningRequest";

    private final Context mContext;
    private final Lazy<Optional<CentralSurfaces>> mCentralSurfacesOptionalLazy;

    private final Lazy<NavigationBarController> mNavigationBarControllerLazy;
    private final AccessibilityManager mAccessibilityService;
    private final WindowManager mWindowManager;
    private final BroadcastDispatcher mBroadcastDispatcher;
@@ -101,12 +99,12 @@ public class ScreenPinningRequest implements View.OnClickListener,
    @Inject
    public ScreenPinningRequest(
            Context context,
            Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
            NavigationModeController navigationModeController,
            Lazy<NavigationBarController> navigationBarControllerLazy,
            BroadcastDispatcher broadcastDispatcher,
            UserTracker userTracker) {
        mContext = context;
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
        mNavigationBarControllerLazy = navigationBarControllerLazy;
        mAccessibilityService = (AccessibilityManager)
                mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
        mWindowManager = (WindowManager)
@@ -289,15 +287,14 @@ public class ScreenPinningRequest implements View.OnClickListener,
                        .setVisibility(View.INVISIBLE);
            }

            final Optional<CentralSurfaces> centralSurfacesOptional =
                    mCentralSurfacesOptionalLazy.get();
            boolean recentsVisible =
                    centralSurfacesOptional.map(CentralSurfaces::isOverviewEnabled).orElse(false);
            int displayId = mContext.getDisplayId();
            boolean overviewEnabled =
                    mNavigationBarControllerLazy.get().isOverviewEnabled(displayId);
            boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled();
            int descriptionStringResId;
            if (QuickStepContract.isGesturalMode(mNavBarMode)) {
                descriptionStringResId = R.string.screen_pinning_description_gestural;
            } else if (recentsVisible) {
            } else if (overviewEnabled) {
                mLayout.findViewById(R.id.screen_pinning_recents_group).setVisibility(VISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg_light).setVisibility(INVISIBLE);
                mLayout.findViewById(R.id.screen_pinning_home_bg).setVisibility(INVISIBLE);
@@ -314,7 +311,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
            }

            NavigationBarView navigationBarView =
                    centralSurfacesOptional.map(CentralSurfaces::getNavigationBarView).orElse(null);
                    mNavigationBarControllerLazy.get().getNavigationBarView(displayId);
            if (navigationBarView != null) {
                ((ImageView) mLayout.findViewById(R.id.screen_pinning_back_icon))
                        .setImageDrawable(navigationBarView.getBackDrawable());
+0 −2
Original line number Diff line number Diff line
@@ -263,8 +263,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {
    // TODO: Figure out way to remove these.
    NavigationBarView getNavigationBarView();

    boolean isOverviewEnabled();

    void setBouncerShowing(boolean bouncerShowing);

    boolean isScreenFullyOff();
+0 −1
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ abstract class CentralSurfacesEmptyImpl : CentralSurfaces {
        cancelAction: Runnable?,
    ) {}
    override fun getNavigationBarView(): NavigationBarView? = null
    override fun isOverviewEnabled() = false
    override fun setBouncerShowing(bouncerShowing: Boolean) {}
    override fun isScreenFullyOff() = false
    override fun getEmergencyActionIntent(): Intent? = null
+0 −5
Original line number Diff line number Diff line
@@ -2536,11 +2536,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        return mNavigationBarController.getNavigationBarView(mDisplayId);
    }

    @Override
    public boolean isOverviewEnabled() {
        return mNavigationBarController.isOverviewEnabled(mDisplayId);
    }

    /**
     * Propagation of the bouncer state, indicating that it's fully visible.
     */