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

Commit 458bccbd authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Merge "Ensure we get the right nav bar mode for the current user in sysui" into qt-dev

am: 05500a36

Change-Id: Id98dba16b731eb62ee5b6e85075733a98092bc85
parents 5378135a 05500a36
Loading
Loading
Loading
Loading
+0 −46
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;

import android.annotation.IntDef;
import android.content.Context;
import android.content.res.Resources;
import android.view.WindowManagerPolicyConstants;

@@ -94,13 +93,6 @@ public class QuickStepContract {
        return mode == NAV_BAR_MODE_GESTURAL;
    }

    /**
     * @return whether the current nav bar mode is gestural
     */
    public static boolean isGesturalMode(Context context) {
        return isGesturalMode(getCurrentInteractionMode(context));
    }

    /**
     * @return whether this nav bar mode is swipe up
     */
@@ -108,13 +100,6 @@ public class QuickStepContract {
        return mode == NAV_BAR_MODE_2BUTTON;
    }

    /**
     * @return whether the current nav bar mode is swipe up
     */
    public static boolean isSwipeUpMode(Context context) {
        return isSwipeUpMode(getCurrentInteractionMode(context));
    }

    /**
     * @return whether this nav bar mode is 3 button
     */
@@ -122,37 +107,6 @@ public class QuickStepContract {
        return mode == NAV_BAR_MODE_3BUTTON;
    }

    /**
     * @return whether this nav bar mode is 3 button
     */
    public static boolean isLegacyMode(Context context) {
        return isLegacyMode(getCurrentInteractionMode(context));
    }

    /**
     * @return the current nav bar interaction mode
     */
    public static int getCurrentInteractionMode(Context context) {
        return context.getResources().getInteger(
                com.android.internal.R.integer.config_navBarInteractionMode);
    }

    /**
     * @return {@code true} if the navbar can be clicked through
     */
    public static boolean isNavBarClickThrough(Context context) {
        return context.getResources().getBoolean(
                com.android.internal.R.bool.config_navBarTapThrough);
    }

    /**
     * @return the edge sensitivity width in px
     */
    public static int getEdgeSensitivityWidth(Context context) {
        return context.getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.config_backGestureInset);
    }

    /**
     * Corner radius that should be used on windows in order to cover the display.
     * These values are expressed in pixels because they should not respect display or font
+4 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.phone.LockscreenGestureLogger;
import com.android.systemui.statusbar.phone.ManagedProfileController;
import com.android.systemui.statusbar.phone.NavigationModeController;
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
@@ -244,6 +245,7 @@ public class Dependency extends SystemUI {
    @Inject Lazy<LightBarController> mLightBarController;
    @Inject Lazy<IWindowManager> mIWindowManager;
    @Inject Lazy<OverviewProxyService> mOverviewProxyService;
    @Inject Lazy<NavigationModeController> mNavBarModeController;
    @Inject Lazy<EnhancedEstimates> mEnhancedEstimates;
    @Inject Lazy<VibratorHelper> mVibratorHelper;
    @Inject Lazy<IStatusBarService> mIStatusBarService;
@@ -407,6 +409,8 @@ public class Dependency extends SystemUI {

        mProviders.put(OverviewProxyService.class, mOverviewProxyService::get);

        mProviders.put(NavigationModeController.class, mNavBarModeController::get);

        mProviders.put(EnhancedEstimates.class, mEnhancedEstimates::get);

        mProviders.put(VibratorHelper.class, mVibratorHelper::get);
+14 −14
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;

import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_SWIPE_UP;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON;
@@ -70,6 +71,7 @@ import com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.phone.NavigationBarFragment;
import com.android.systemui.statusbar.phone.NavigationModeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.CallbackController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
@@ -87,7 +89,8 @@ import javax.inject.Singleton;
 * Class to send information from overview to launcher with a binder.
 */
@Singleton
public class OverviewProxyService implements CallbackController<OverviewProxyListener>, Dumpable {
public class OverviewProxyService implements CallbackController<OverviewProxyListener>,
        NavigationModeController.ModeChangedListener, Dumpable {

    private static final String ACTION_QUICKSTEP = "android.intent.action.QUICKSTEP_SERVICE";

@@ -124,6 +127,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
    private MotionEvent mStatusBarGestureDownEvent;
    private float mWindowCornerRadius;
    private boolean mSupportsRoundedCornersOnWindows;
    private int mNavBarMode = NAV_BAR_MODE_3BUTTON;

    private ISystemUiProxy mSysUiProxy = new ISystemUiProxy.Stub() {

@@ -427,16 +431,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis

    private final DeviceProvisionedListener mDeviceProvisionedCallback =
                new DeviceProvisionedListener() {

        @Override
        public void onDeviceProvisionedChanged() {
            /*
            on initialize, keep track of the previous gestural state (nothing is enabled by default)
            restore to a non gestural state if device is not provisioned
            once the device is provisioned, restore to the original state
             */
        }

        @Override
        public void onUserSetupChanged() {
            if (mDeviceProvisionedController.isCurrentUserSetup()) {
@@ -474,6 +468,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        // Assumes device always starts with back button until launcher tells it that it does not
        mBackButtonAlpha = 1.0f;

        mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this);

        // Listen for the package update changes.
        if (mDeviceProvisionedController.getCurrentUser() == UserHandle.USER_SYSTEM) {
            updateEnabledState();
@@ -483,6 +479,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
            filter.addDataSchemeSpecificPart(mRecentsComponentName.getPackageName(),
                    PatternMatcher.PATTERN_LITERAL);
            filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
            // TODO: Shouldn't this be per-user?
            mContext.registerReceiver(mLauncherStateChangedReceiver, filter);
        }
    }
@@ -678,7 +675,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis

    private int getDefaultInteractionFlags() {
        // If there is no settings available use device default or get it from settings
        return QuickStepContract.isLegacyMode(mContext)
        return QuickStepContract.isLegacyMode(mNavBarMode)
                ? DEFAULT_DISABLE_SWIPE_UP_STATE
                : 0;
    }
@@ -735,6 +732,11 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                ActivityManagerWrapper.getInstance().getCurrentUserId()) != null;
    }

    @Override
    public void onNavigationModeChanged(int mode) {
        mNavBarMode = mode;
    }

    @Override
    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
        pw.println(TAG_OPS + " state:");
@@ -747,8 +749,6 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis

        pw.print("  quickStepIntent="); pw.println(mQuickStepIntent);
        pw.print("  quickStepIntentResolved="); pw.println(isEnabled());
        pw.print("  navBarMode=");
        pw.println(QuickStepContract.getCurrentInteractionMode(mContext));
        pw.print("  mSysUiStateFlags="); pw.println(mSysUiStateFlags);
    }

+7 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.recents;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;

import static com.android.systemui.Prefs.Key.DISMISSED_RECENTS_SWIPE_UP_ONBOARDING_COUNT;
import static com.android.systemui.Prefs.Key.HAS_DISMISSED_RECENTS_QUICK_SCRUB_ONBOARDING_ONCE;
@@ -111,6 +112,7 @@ public class RecentsOnboarding {
    private final int mOnboardingToastColor;
    private final int mOnboardingToastArrowRadius;
    private int mNavBarHeight;
    private int mNavBarMode = NAV_BAR_MODE_3BUTTON;

    private boolean mOverviewProxyListenerRegistered;
    private boolean mTaskListenerRegistered;
@@ -339,8 +341,12 @@ public class RecentsOnboarding {
        } catch (RemoteException e) {}
    }

    public void onNavigationModeChanged(int mode) {
        mNavBarMode = mode;
    }

    public void onConnectedToLauncher() {
        if (!ONBOARDING_ENABLED || QuickStepContract.isGesturalMode(mContext)) {
        if (!ONBOARDING_ENABLED || QuickStepContract.isGesturalMode(mNavBarMode)) {
            return;
        }

+6 −7
Original line number Diff line number Diff line
@@ -156,7 +156,9 @@ public class EdgeBackGestureHandler implements DisplayListener {
        mWm = context.getSystemService(WindowManager.class);
        mOverviewProxyService = overviewProxyService;

        mEdgeWidth = QuickStepContract.getEdgeSensitivityWidth(context);
        // TODO: Get this for the current user
        mEdgeWidth = res.getDimensionPixelSize(
                com.android.internal.R.dimen.config_backGestureInset);
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        mSwipeThreshold = res.getDimension(R.dimen.navigation_edge_action_drag_threshold);

@@ -168,7 +170,7 @@ public class EdgeBackGestureHandler implements DisplayListener {
     */
    public void onNavBarAttached() {
        mIsAttached = true;
        onOverlaysChanged();
        updateIsEnabled();
    }

    /**
@@ -179,11 +181,8 @@ public class EdgeBackGestureHandler implements DisplayListener {
        updateIsEnabled();
    }

    /**
     * Called when system overlays has changed
     */
    public void onOverlaysChanged() {
        mIsGesturalModeEnabled = QuickStepContract.isGesturalMode(mContext);
    public void onNavigationModeChanged(int mode) {
        mIsGesturalModeEnabled = QuickStepContract.isGesturalMode(mode);
        updateIsEnabled();
    }

Loading