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

Commit 63331729 authored by Dave Mankoff's avatar Dave Mankoff
Browse files

Remove last call to Dep.get from NavigationBarView

Removes the last call to Dependency#get from NavigationBarView. A few
more calls were added in the process, but they will be easier to deal
with in future cls.

Bug: 218354102
Test: manual && atest SystemUITests
Change-Id: I0b6b3837d9f1cfd11f0cdb4089fb51ecf79b467b
Merged-In: I0b6b3837d9f1cfd11f0cdb4089fb51ecf79b467b
parent c2f81557
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -92,9 +92,18 @@ public class RegionSamplingHelper implements View.OnAttachStateChangeListener,
        }
    };

    /**
     * @deprecated Pass a main executor.
     */
    public RegionSamplingHelper(View sampledView, SamplingCallback samplingCallback,
            Executor backgroundExecutor) {
        this(sampledView, samplingCallback, sampledView.getContext().getMainExecutor(),
                backgroundExecutor);
    }

    public RegionSamplingHelper(View sampledView, SamplingCallback samplingCallback,
            Executor mainExecutor, Executor backgroundExecutor) {
        this(sampledView, samplingCallback, mainExecutor,
                backgroundExecutor, new SysuiCompositionSamplingListener());
    }

+126 −12
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARE
import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode;
import static com.android.systemui.statusbar.phone.CentralSurfaces.DEBUG_WINDOW_STATE;
import static com.android.systemui.statusbar.phone.CentralSurfaces.dumpBarTransitions;
import static com.android.systemui.util.Utils.isGesturalModeOnDefaultDisplay;

import android.annotation.IdRes;
import android.app.ActivityTaskManager;
@@ -68,6 +69,7 @@ import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
@@ -115,6 +117,7 @@ import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.DisplayId;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.model.SysUiState;
@@ -130,6 +133,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.Recents;
import com.android.systemui.settings.UserContextProvider;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import com.android.systemui.shared.recents.utilities.Utilities;
import com.android.systemui.shared.rotation.RotationButton;
import com.android.systemui.shared.rotation.RotationButtonController;
@@ -159,6 +163,7 @@ import java.io.PrintWriter;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

import javax.inject.Inject;
@@ -212,6 +217,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
    private final NotificationShadeDepthController mNotificationShadeDepthController;
    private final OnComputeInternalInsetsListener mOnComputeInternalInsetsListener;
    private final UserContextProvider mUserContextProvider;
    private final RegionSamplingHelper mRegionSamplingHelper;
    private final int mNavColorSampleMargin;
    private NavigationBarFrame mFrame;

    private @WindowVisibleState int mNavigationBarWindowState = WINDOW_STATE_SHOWING;
@@ -273,6 +280,16 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
    private boolean mShowOrientedHandleForImmersiveMode;
    private final DeadZone mDeadZone;
    private boolean mImeVisible;
    private final Rect mSamplingBounds = new Rect();

    /**
     * When quickswitching between apps of different orientations, we draw a secondary home handle
     * in the position of the first app's orientation. This rect represents the region of that
     * home handle so we can apply the correct light/dark luma on that.
     * @see {@link NavigationBar#mOrientationHandle}
     */
    @android.annotation.Nullable
    private Rect mOrientedHandleSamplingRegion;

    @com.android.internal.annotations.VisibleForTesting
    public enum NavBarActionEvent implements UiEventLogger.UiEventEnum {
@@ -483,7 +500,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
                        return;
                    }
                    mHasBlurs = hasBlurs;
                    mView.setWindowHasBlurs(hasBlurs);
                    mRegionSamplingHelper.setWindowHasBlurs(hasBlurs);
                }
            };

@@ -512,6 +529,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            NotificationRemoteInputManager notificationRemoteInputManager,
            NotificationShadeDepthController notificationShadeDepthController,
            @Main Handler mainHandler,
            @Main Executor mainExecutor,
            @Background Executor bgExecutor,
            UiEventLogger uiEventLogger,
            NavBarHelper navBarHelper,
            LightBarController mainLightBarController,
@@ -564,6 +583,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        mInputMethodManager = inputMethodManager;
        mUserContextProvider = userContextProvider;

        mNavColorSampleMargin = getResources()
                .getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin);

        mOnComputeInternalInsetsListener = info -> {
            // When the nav bar is in 2-button or 3-button mode, or when IME is visible in fully
            // gestural mode, the entire nav bar should be touchable.
@@ -586,6 +608,29 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
                    false /* inScreen */, false /* useNearestRegion */));
        };

        mRegionSamplingHelper = new RegionSamplingHelper(mView,
                new RegionSamplingHelper.SamplingCallback() {
                    @Override
                    public void onRegionDarknessChanged(boolean isRegionDark) {
                        getBarTransitions().getLightTransitionsController().setIconsDark(
                                !isRegionDark, true /* animate */);
                    }

                    @Override
                    public Rect getSampledRegion(View sampledView) {
                        if (mOrientedHandleSamplingRegion != null) {
                            return mOrientedHandleSamplingRegion;
                        }

                        return calculateSamplingRect();
                    }

                    @Override
                    public boolean isSamplingEnabled() {
                        return isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode);
                    }
                }, mainExecutor, bgExecutor);

        mView.setEdgeBackGestureHandler(mEdgeBackGestureHandler);
        mNavBarMode = mNavigationModeController.addListener(mModeChangedListener);
    }
@@ -600,8 +645,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        // It should also has corresponding cleanup in onViewDetached.
        mView.setBarTransitions(mNavigationBarTransitions);
        mView.setTouchHandler(mTouchHandler);
        mView.setNavBarMode(mNavBarMode);
        setNavBarMode(mNavBarMode);
        mEdgeBackGestureHandler.setStateChangeCallback(mView::updateStates);
        mNavigationBarTransitions.addListener(this::onBarTransition);
        mView.updateRotationButton();

        mView.setVisibility(
@@ -674,9 +720,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            getBarTransitions().getLightTransitionsController().restoreState(mSavedState);
        }
        setNavigationIconHints(mNavigationIconHints);
        mView.setWindowVisible(isNavBarWindowVisible());
        setWindowVisible(isNavBarWindowVisible());
        mView.setBehavior(mBehavior);
        mView.setNavBarMode(mNavBarMode);
        setNavBarMode(mNavBarMode);
        mView.setUpdateActiveTouchRegionsCallback(
                () -> mOverviewProxyService.onActiveNavBarRegionChanges(
                        getButtonLocations(
@@ -838,7 +884,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
                    mOrientationHandle.mapRectFromViewToScreenCoords(boundsOnScreen, true);
                    Rect boundsRounded = new Rect();
                    boundsOnScreen.roundOut(boundsRounded);
                    mView.setOrientedHandleSamplingRegion(boundsRounded);
                    setOrientedHandleSamplingRegion(boundsRounded);
                };
        mOrientationHandle.getViewTreeObserver().addOnGlobalLayoutListener(
                mOrientationHandleGlobalLayoutListener);
@@ -899,7 +945,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            mOrientationHandle.setVisibility(View.GONE);
        }
        mView.setVisibility(View.VISIBLE);
        mView.setOrientedHandleSamplingRegion(null);
        setOrientedHandleSamplingRegion(null);
    }

    private void reconfigureHomeLongClick() {
@@ -937,7 +983,10 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        pw.println("  mTransientShownFromGestureOnSystemBar="
                + mTransientShownFromGestureOnSystemBar);
        dumpBarTransitions(pw, "mNavigationBarView", getBarTransitions());

        pw.println("  mOrientedHandleSamplingRegion: " + mOrientedHandleSamplingRegion);
        mView.dump(pw);
        mRegionSamplingHelper.dump(pw);
    }

    // ----- CommandQueue Callbacks -----
@@ -973,7 +1022,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
                orientSecondaryHomeHandle();
            }
            if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state));
            mView.setWindowVisible(isNavBarWindowVisible());
            setWindowVisible(isNavBarWindowVisible());
        }
    }

@@ -1474,6 +1523,11 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        }
    }

    private void setWindowVisible(boolean visible) {
        mRegionSamplingHelper.setWindowVisible(visible);
        mView.setWindowVisible(visible);
    }

    /** Sets {@link AutoHideController} to the navigation bar. */
    private void setAutoHideController(AutoHideController autoHideController) {
        mAutoHideController = autoHideController;
@@ -1641,7 +1695,15 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            if (Intent.ACTION_SCREEN_OFF.equals(action)
                    || Intent.ACTION_SCREEN_ON.equals(action)) {
                notifyNavigationBarScreenOn();
                mView.onScreenStateChanged(Intent.ACTION_SCREEN_ON.equals(action));
                boolean isScreenOn = Intent.ACTION_SCREEN_ON.equals(action);
                mView.onScreenStateChanged(isScreenOn);
                if (isScreenOn) {
                    if (isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode)) {
                        mRegionSamplingHelper.start(mSamplingBounds);
                    }
                } else {
                    mRegionSamplingHelper.stop();
                }
            }
            if (Intent.ACTION_USER_SWITCHED.equals(action)) {
                // The accessibility settings may be different for the new user
@@ -1750,6 +1812,60 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
        region.op(bounds, Region.Op.UNION);
    }

    void setOrientedHandleSamplingRegion(Rect orientedHandleSamplingRegion) {
        mOrientedHandleSamplingRegion = orientedHandleSamplingRegion;
        mRegionSamplingHelper.updateSamplingRect();
    }

    private Rect calculateSamplingRect() {
        mSamplingBounds.setEmpty();
        // TODO: Extend this to 2/3 button layout as well
        View view = mView.getHomeHandle().getCurrentView();

        if (view != null) {
            int[] pos = new int[2];
            view.getLocationOnScreen(pos);
            Point displaySize = new Point();
            view.getContext().getDisplay().getRealSize(displaySize);
            final Rect samplingBounds = new Rect(pos[0] - mNavColorSampleMargin,
                    displaySize.y - mView.getNavBarHeight(),
                    pos[0] + view.getWidth() + mNavColorSampleMargin,
                    displaySize.y);
            mSamplingBounds.set(samplingBounds);
        }

        return mSamplingBounds;
    }

    void setNavigationBarLumaSamplingEnabled(boolean enable) {
        if (enable) {
            mRegionSamplingHelper.start(mSamplingBounds);
        } else {
            mRegionSamplingHelper.stop();
        }
    }

    private void setNavBarMode(int mode) {
        mView.setNavBarMode(mode, mNavigationModeController.getImeDrawsImeNavBar());
        if (isGesturalMode(mode)) {
            mRegionSamplingHelper.start(mSamplingBounds);
        } else {
            mRegionSamplingHelper.stop();
        }
    }

    void onBarTransition(int newMode) {
        if (newMode == MODE_OPAQUE) {
            // If the nav bar background is opaque, stop auto tinting since we know the icons are
            // showing over a dark background
            mRegionSamplingHelper.stop();
            getBarTransitions().getLightTransitionsController().setIconsDark(
                    false /* dark */, true /* animate */);
        } else {
            mRegionSamplingHelper.start(mSamplingBounds);
        }
    }

    private final ModeChangedListener mModeChangedListener = new ModeChangedListener() {
        @Override
        public void onNavigationModeChanged(int mode) {
@@ -1766,11 +1882,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
            if (!canShowSecondaryHandle()) {
                resetSecondaryHandle();
            }
            if (mView != null) {
                mView.setNavBarMode(mode);
            setNavBarMode(mode);
            mView.setShouldShowSwipeUpUi(mOverviewProxyService.shouldShowSwipeUpUI());
        }
        }
    };

    private final Gefingerpoken mTouchHandler = new Gefingerpoken() {
+8 −4
Original line number Diff line number Diff line
@@ -244,9 +244,9 @@ public class NavigationBarController implements

    @Override
    public void setNavigationBarLumaSamplingEnabled(int displayId, boolean enable) {
        final NavigationBarView navigationBarView = getNavigationBarView(displayId);
        if (navigationBarView != null) {
            navigationBarView.setNavigationBarLumaSamplingEnabled(enable);
        final NavigationBar navigationBar = getNavigationBar(displayId);
        if (navigationBar != null) {
            navigationBar.setNavigationBarLumaSamplingEnabled(enable);
        }
    }

@@ -404,10 +404,14 @@ public class NavigationBarController implements
     *         {@code null} if no navigation bar on that display.
     */
    public @Nullable NavigationBarView getNavigationBarView(int displayId) {
        NavigationBar navBar = mNavigationBars.get(displayId);
        NavigationBar navBar = getNavigationBar(displayId);
        return (navBar == null) ? null : navBar.getView();
    }

    private @Nullable NavigationBar getNavigationBar(int displayId) {
        return mNavigationBars.get(displayId);
    }

    public void showPinningEnterExitToast(int displayId, boolean entering) {
        final NavigationBarView navBarView = getNavigationBarView(displayId);
        if (navBarView != null) {
+16 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public final class NavigationBarTransitions extends BarTransitions implements

    public static final int MIN_COLOR_ADAPT_TRANSITION_TIME = 400;
    public static final int DEFAULT_COLOR_ADAPT_TRANSITION_TIME = 1700;
    private List<Listener> mListeners = new ArrayList<>();

    /**
     * Notified when the color of nav bar elements changes.
@@ -162,7 +163,9 @@ public final class NavigationBarTransitions extends BarTransitions implements
    protected void onTransition(int oldMode, int newMode, boolean animate) {
        super.onTransition(oldMode, newMode, animate);
        applyLightsOut(animate, false /*force*/);
        mView.onBarTransition(newMode);
        for (Listener listener : mListeners) {
            listener.onTransition(newMode);
        }
    }

    private void applyLightsOut(boolean animate, boolean force) {
@@ -255,4 +258,16 @@ public final class NavigationBarTransitions extends BarTransitions implements
        pw.println("  bg color: " + mBarBackground.getColor());
        pw.println("  bg frame: " + mBarBackground.getFrame());
    }

    void addListener(Listener listener) {
        mListeners.add(listener);
    }

    void removeListener(Listener listener) {
        mListeners.remove(listener);
    }

    interface Listener {
        void onTransition(int newMode);
    }
}
+6 −117
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_O
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SEARCH_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.isGesturalMode;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
import static com.android.systemui.util.Utils.isGesturalModeOnDefaultDisplay;

import android.animation.LayoutTransition;
import android.animation.LayoutTransition.TransitionListener;
@@ -34,7 +32,6 @@ import android.animation.PropertyValuesHolder;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.DrawableRes;
import android.annotation.Nullable;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.res.Configuration;
@@ -58,9 +55,10 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.FrameLayout;

import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.Gefingerpoken;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
@@ -74,7 +72,6 @@ import com.android.systemui.navigationbar.buttons.NearestTouchFrame;
import com.android.systemui.navigationbar.buttons.RotationContextButton;
import com.android.systemui.navigationbar.gestural.EdgeBackGestureHandler;
import com.android.systemui.recents.Recents;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
import com.android.systemui.shared.rotation.FloatingRotationButton;
import com.android.systemui.shared.rotation.RotationButton.RotationButtonUpdatesCallback;
import com.android.systemui.shared.rotation.RotationButtonController;
@@ -91,7 +88,6 @@ import com.android.wm.shell.pip.Pip;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

/** */
@@ -100,8 +96,6 @@ public class NavigationBarView extends FrameLayout {
    final static String TAG = "NavBarView";

    final static boolean ALTERNATE_CAR_MODE_UI = false;
    private final RegionSamplingHelper mRegionSamplingHelper;
    private final int mNavColorSampleMargin;

    // The current view is one of mHorizontal or mVertical depending on the current configuration
    View mCurrentView = null;
@@ -161,15 +155,6 @@ public class NavigationBarView extends FrameLayout {
     * fully locked mode we only show that unlocking is blocked.
     */
    private ScreenPinningNotify mScreenPinningNotify;
    private Rect mSamplingBounds = new Rect();
    /**
     * When quickswitching between apps of different orientations, we draw a secondary home handle
     * in the position of the first app's orientation. This rect represents the region of that
     * home handle so we can apply the correct light/dark luma on that.
     * @see {@link NavigationBar#mOrientationHandle}
     */
    @Nullable
    private Rect mOrientedHandleSamplingRegion;

    /**
     * {@code true} if the IME can render the back button and the IME switcher button.
@@ -289,7 +274,6 @@ public class NavigationBarView extends FrameLayout {
        mDarkIconColor = Utils.getColorAttrDefaultColor(darkContext, R.attr.singleToneColor);
        mIsVertical = false;
        mLongClickableAccessibilityButton = false;
        mImeDrawsImeNavBar = Dependency.get(NavigationModeController.class).getImeDrawsImeNavBar();

        // Set up the context group of buttons
        mContextualButtonGroup = new ContextualButtonGroup(R.id.menu_container);
@@ -333,33 +317,6 @@ public class NavigationBarView extends FrameLayout {
        mButtonDispatchers.put(R.id.accessibility_button, accessibilityButton);
        mButtonDispatchers.put(R.id.menu_container, mContextualButtonGroup);
        mDeadZone = new DeadZone(this);

        mNavColorSampleMargin = getResources()
                        .getDimensionPixelSize(R.dimen.navigation_handle_sample_horizontal_margin);
        Executor backgroundExecutor = Dependency.get(Dependency.BACKGROUND_EXECUTOR);
        mRegionSamplingHelper = new RegionSamplingHelper(this,
                new RegionSamplingHelper.SamplingCallback() {
                    @Override
                    public void onRegionDarknessChanged(boolean isRegionDark) {
                        getLightTransitionsController().setIconsDark(!isRegionDark ,
                                true /* animate */);
                    }

                    @Override
                    public Rect getSampledRegion(View sampledView) {
                        if (mOrientedHandleSamplingRegion != null) {
                            return mOrientedHandleSamplingRegion;
                        }

                        updateSamplingRect();
                        return mSamplingBounds;
                    }

                    @Override
                    public boolean isSamplingEnabled() {
                        return isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode);
                    }
                }, backgroundExecutor);
    }

    public void setEdgeBackGestureHandler(EdgeBackGestureHandler edgeBackGestureHandler) {
@@ -407,28 +364,6 @@ public class NavigationBarView extends FrameLayout {
        return super.onTouchEvent(event);
    }

    /**
     * If we're blurring the shade window.
     */
    public void setWindowHasBlurs(boolean hasBlurs) {
        mRegionSamplingHelper.setWindowHasBlurs(hasBlurs);
    }

    void onTransientStateChanged(boolean isTransient, boolean isGestureOnSystemBar) {
        mEdgeBackGestureHandler.onNavBarTransientStateChanged(isTransient);
    }

    void onBarTransition(int newMode) {
        if (newMode == MODE_OPAQUE) {
            // If the nav bar background is opaque, stop auto tinting since we know the icons are
            // showing over a dark background
            mRegionSamplingHelper.stop();
            getLightTransitionsController().setIconsDark(false /* dark */, true /* animate */);
        } else {
            mRegionSamplingHelper.start(mSamplingBounds);
        }
    }

    public void abortCurrentGesture() {
        getHomeButton().abortCurrentGesture();
    }
@@ -603,17 +538,9 @@ public class NavigationBarView extends FrameLayout {
    /** To be called when screen lock/unlock state changes */
    public void onScreenStateChanged(boolean isScreenOn) {
        mScreenOn = isScreenOn;
        if (isScreenOn) {
            if (isGesturalModeOnDefaultDisplay(getContext(), mNavBarMode)) {
                mRegionSamplingHelper.start(mSamplingBounds);
            }
        } else {
            mRegionSamplingHelper.stop();
        }
    }

    public void setWindowVisible(boolean visible) {
        mRegionSamplingHelper.setWindowVisible(visible);
        mRotationButtonController.onNavigationBarWindowVisibilityChange(visible);
    }

@@ -879,18 +806,12 @@ public class NavigationBarView extends FrameLayout {
        wm.updateViewLayout(navbarView, lp);
    }

    void setNavBarMode(int mode) {
    void setNavBarMode(int mode, boolean imeDrawsImeNavBar) {
        mNavBarMode = mode;
        mImeDrawsImeNavBar = Dependency.get(NavigationModeController.class).getImeDrawsImeNavBar();
        mImeDrawsImeNavBar = imeDrawsImeNavBar;
        mBarTransitions.onNavigationModeChanged(mNavBarMode);
        mEdgeBackGestureHandler.onNavigationModeChanged(mNavBarMode);
        updateRotationButton();

        if (isGesturalMode(mNavBarMode)) {
            mRegionSamplingHelper.start(mSamplingBounds);
        } else {
            mRegionSamplingHelper.stop();
        }
    }

    public void setAccessibilityButtonState(final boolean visible, final boolean longClickable) {
@@ -915,29 +836,6 @@ public class NavigationBarView extends FrameLayout {
        super.onDraw(canvas);
    }

    private void updateSamplingRect() {
        mSamplingBounds.setEmpty();
        // TODO: Extend this to 2/3 button layout as well
        View view = getHomeHandle().getCurrentView();

        if (view != null) {
            int[] pos = new int[2];
            view.getLocationOnScreen(pos);
            Point displaySize = new Point();
            view.getContext().getDisplay().getRealSize(displaySize);
            final Rect samplingBounds = new Rect(pos[0] - mNavColorSampleMargin,
                    displaySize.y - getNavBarHeight(),
                    pos[0] + view.getWidth() + mNavColorSampleMargin,
                    displaySize.y);
            mSamplingBounds.set(samplingBounds);
        }
    }

    void setOrientedHandleSamplingRegion(Rect orientedHandleSamplingRegion) {
        mOrientedHandleSamplingRegion = orientedHandleSamplingRegion;
        mRegionSamplingHelper.updateSamplingRect();
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
@@ -1076,7 +974,7 @@ public class NavigationBarView extends FrameLayout {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    private int getNavBarHeight() {
    int getNavBarHeight() {
        return mIsVertical
                ? getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.navigation_bar_height_landscape)
@@ -1184,7 +1082,7 @@ public class NavigationBarView extends FrameLayout {
        mEdgeBackGestureHandler.onNavBarDetached();
    }

    public void dump(PrintWriter pw) {
    void dump(PrintWriter pw) {
        final Rect r = new Rect();
        final Point size = new Point();
        getContextDisplay().getRealSize(size);
@@ -1211,7 +1109,6 @@ public class NavigationBarView extends FrameLayout {
                        mIsVertical ? "true" : "false",
                        getLightTransitionsController().getCurrentDarkIntensity()));

        pw.println("      mOrientedHandleSamplingRegion: " + mOrientedHandleSamplingRegion);
        pw.println("    mScreenOn: " + mScreenOn);


@@ -1228,7 +1125,6 @@ public class NavigationBarView extends FrameLayout {
        }
        mBarTransitions.dump(pw);
        mContextualButtonGroup.dump(pw);
        mRegionSamplingHelper.dump(pw);
        mEdgeBackGestureHandler.dump(pw);
    }

@@ -1289,13 +1185,6 @@ public class NavigationBarView extends FrameLayout {
        mEdgeBackGestureHandler.setPipStashExclusionBounds(bounds);
    });

    void setNavigationBarLumaSamplingEnabled(boolean enable) {
        if (enable) {
            mRegionSamplingHelper.start(mSamplingBounds);
        } else {
            mRegionSamplingHelper.stop();
        }
    }

    interface UpdateActiveTouchRegionsCallback {
        void update();
Loading