Merge "Ensure we get the right nav bar mode for the current user in sysui" into qt-dev
am: 05500a3651
Change-Id: Id98dba16b731eb62ee5b6e85075733a98092bc85
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -43,6 +44,7 @@ public class NavBarTintController implements View.OnAttachStateChangeListener,
|
||||
private final Handler mHandler = new Handler();
|
||||
private final NavigationBarView mNavigationBarView;
|
||||
private final LightBarTransitionsController mLightBarController;
|
||||
private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
private final CompositionSamplingListener mSamplingListener;
|
||||
private final Runnable mUpdateSamplingListener = this::updateSamplingListener;
|
||||
@@ -91,7 +93,7 @@ public class NavBarTintController implements View.OnAttachStateChangeListener,
|
||||
}
|
||||
|
||||
void start() {
|
||||
if (!isEnabled(mNavigationBarView.getContext())) {
|
||||
if (!isEnabled(mNavigationBarView.getContext(), mNavBarMode)) {
|
||||
return;
|
||||
}
|
||||
mSamplingEnabled = true;
|
||||
@@ -178,6 +180,10 @@ public class NavBarTintController implements View.OnAttachStateChangeListener,
|
||||
}
|
||||
}
|
||||
|
||||
public void onNavigationModeChanged(int mode) {
|
||||
mNavBarMode = mode;
|
||||
}
|
||||
|
||||
void dump(PrintWriter pw) {
|
||||
pw.println("NavBarTintController:");
|
||||
pw.println(" navBar isAttached: " + mNavigationBarView.isAttachedToWindow());
|
||||
@@ -190,8 +196,8 @@ public class NavBarTintController implements View.OnAttachStateChangeListener,
|
||||
pw.println(" mCurrentMedianLuma: " + mCurrentMedianLuma);
|
||||
}
|
||||
|
||||
public static boolean isEnabled(Context context) {
|
||||
public static boolean isEnabled(Context context, int navBarMode) {
|
||||
return context.getDisplayId() == DEFAULT_DISPLAY
|
||||
&& QuickStepContract.isGesturalMode(context);
|
||||
&& QuickStepContract.isGesturalMode(navBarMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
|
||||
import static android.app.StatusBarManager.WindowType;
|
||||
import static android.app.StatusBarManager.WindowVisibleState;
|
||||
import static android.app.StatusBarManager.windowStateToString;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
|
||||
import static com.android.systemui.shared.system.NavigationBarCompat.InteractionType;
|
||||
@@ -119,7 +120,8 @@ import javax.inject.Inject;
|
||||
* Fragment containing the NavigationBarFragment. Contains logic for what happens
|
||||
* on clicks and view states of the nav bar.
|
||||
*/
|
||||
public class NavigationBarFragment extends LifecycleFragment implements Callbacks {
|
||||
public class NavigationBarFragment extends LifecycleFragment implements Callbacks,
|
||||
NavigationModeController.ModeChangedListener {
|
||||
|
||||
public static final String TAG = "NavigationBar";
|
||||
private static final boolean DEBUG = false;
|
||||
@@ -160,6 +162,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
private int mLayoutDirection;
|
||||
|
||||
private int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE;
|
||||
private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
|
||||
private LightBarController mLightBarController;
|
||||
private AutoHideController mAutoHideController;
|
||||
|
||||
@@ -209,7 +212,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
final ButtonDispatcher backButton = mNavigationBarView.getBackButton();
|
||||
final boolean useAltBack =
|
||||
(mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0;
|
||||
if (QuickStepContract.isGesturalMode(getContext()) && !useAltBack) {
|
||||
if (QuickStepContract.isGesturalMode(mNavBarMode) && !useAltBack) {
|
||||
// If property was changed to hide/show back button, going home will trigger
|
||||
// launcher to to change the back button alpha to reflect property change
|
||||
backButton.setVisibility(View.GONE);
|
||||
@@ -246,13 +249,15 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
@Inject
|
||||
public NavigationBarFragment(AccessibilityManagerWrapper accessibilityManagerWrapper,
|
||||
DeviceProvisionedController deviceProvisionedController, MetricsLogger metricsLogger,
|
||||
AssistManager assistManager, OverviewProxyService overviewProxyService) {
|
||||
AssistManager assistManager, OverviewProxyService overviewProxyService,
|
||||
NavigationModeController navigationModeController) {
|
||||
mAccessibilityManagerWrapper = accessibilityManagerWrapper;
|
||||
mDeviceProvisionedController = deviceProvisionedController;
|
||||
mMetricsLogger = metricsLogger;
|
||||
mAssistManager = assistManager;
|
||||
mAssistantAvailable = mAssistManager.getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
|
||||
mOverviewProxyService = overviewProxyService;
|
||||
mNavBarMode = navigationModeController.addListener(this);
|
||||
}
|
||||
|
||||
// ----- Fragment Lifecycle Callbacks -----
|
||||
@@ -928,7 +933,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
if (mOverviewProxyService.getProxy() != null) {
|
||||
try {
|
||||
mOverviewProxyService.getProxy().onAssistantAvailable(available
|
||||
&& QuickStepContract.isGesturalMode(getContext()));
|
||||
&& QuickStepContract.isGesturalMode(mNavBarMode));
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Unable to send assistant availability data to launcher");
|
||||
}
|
||||
@@ -984,6 +989,11 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
mNavigationBarView.getBarTransitions().transitionTo(mNavigationBarMode, anim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationModeChanged(int mode) {
|
||||
mNavBarMode = mode;
|
||||
}
|
||||
|
||||
public void disableAnimationsDuringHide(long delay) {
|
||||
mNavigationBarView.setLayoutTransitionsEnabled(false);
|
||||
mNavigationBarView.postDelayed(() -> mNavigationBarView.setLayoutTransitionsEnabled(true),
|
||||
@@ -1040,7 +1050,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
|
||||
if (Intent.ACTION_SCREEN_ON.equals(action)) {
|
||||
// Enabled and screen is on, start it again if enabled
|
||||
if (NavBarTintController.isEnabled(getContext())) {
|
||||
if (NavBarTintController.isEnabled(getContext(), mNavBarMode)) {
|
||||
mNavigationBarView.getTintController().start();
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
@@ -49,7 +50,8 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class NavigationBarInflaterView extends FrameLayout
|
||||
implements Tunable, PluginListener<NavBarButtonProvider> {
|
||||
implements Tunable, PluginListener<NavBarButtonProvider>,
|
||||
NavigationModeController.ModeChangedListener {
|
||||
|
||||
private static final String TAG = "NavBarInflater";
|
||||
|
||||
@@ -102,11 +104,13 @@ public class NavigationBarInflaterView extends FrameLayout
|
||||
private boolean mUsingCustomLayout;
|
||||
|
||||
private OverviewProxyService mOverviewProxyService;
|
||||
private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
public NavigationBarInflaterView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
createInflaters();
|
||||
mOverviewProxyService = Dependency.get(OverviewProxyService.class);
|
||||
mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -138,7 +142,7 @@ public class NavigationBarInflaterView extends FrameLayout
|
||||
}
|
||||
|
||||
protected String getDefaultLayout() {
|
||||
final int defaultResource = QuickStepContract.isGesturalMode(getContext())
|
||||
final int defaultResource = QuickStepContract.isGesturalMode(mNavBarMode)
|
||||
? R.string.config_navBarLayoutHandle
|
||||
: mOverviewProxyService.shouldShowSwipeUpUI()
|
||||
? R.string.config_navBarLayoutQuickstep
|
||||
@@ -146,6 +150,12 @@ public class NavigationBarInflaterView extends FrameLayout
|
||||
return getContext().getString(defaultResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationModeChanged(int mode) {
|
||||
mNavBarMode = mode;
|
||||
onLikelyDefaultLayoutChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
@@ -159,6 +169,7 @@ public class NavigationBarInflaterView extends FrameLayout
|
||||
protected void onDetachedFromWindow() {
|
||||
Dependency.get(TunerService.class).removeTunable(this);
|
||||
Dependency.get(PluginManager.class).removePluginListener(this);
|
||||
Dependency.get(NavigationModeController.class).removeListener(this);
|
||||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
import static com.android.systemui.statusbar.phone.NavBarTintController.DEFAULT_COLOR_ADAPT_TRANSITION_TIME;
|
||||
import static com.android.systemui.statusbar.phone.NavBarTintController.MIN_COLOR_ADAPT_TRANSITION_TIME;
|
||||
|
||||
@@ -46,6 +48,7 @@ public final class NavigationBarTransitions extends BarTransitions implements
|
||||
private boolean mLightsOut;
|
||||
private boolean mAutoDim;
|
||||
private View mNavButtons;
|
||||
private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
private final Handler mHandler = Handler.getMain();
|
||||
private final IWallpaperVisibilityListener mWallpaperVisibilityListener =
|
||||
@@ -176,9 +179,13 @@ public final class NavigationBarTransitions extends BarTransitions implements
|
||||
|
||||
@Override
|
||||
public int getTintAnimationDuration() {
|
||||
if (NavBarTintController.isEnabled(mView.getContext())) {
|
||||
if (NavBarTintController.isEnabled(mView.getContext(), mNavBarMode)) {
|
||||
return Math.max(DEFAULT_COLOR_ADAPT_TRANSITION_TIME, MIN_COLOR_ADAPT_TRANSITION_TIME);
|
||||
}
|
||||
return LightBarTransitionsController.DEFAULT_TINT_ANIMATION_DURATION;
|
||||
}
|
||||
|
||||
public void onNavigationModeChanged(int mode) {
|
||||
mNavBarMode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.content.Intent.ACTION_OVERLAY_CHANGED;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_INVALID;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
|
||||
@@ -31,10 +31,7 @@ import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.DrawableRes;
|
||||
import android.app.StatusBarManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Point;
|
||||
@@ -84,7 +81,8 @@ import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class NavigationBarView extends FrameLayout implements PluginListener<NavGesture> {
|
||||
public class NavigationBarView extends FrameLayout implements PluginListener<NavGesture>,
|
||||
NavigationModeController.ModeChangedListener {
|
||||
final static boolean DEBUG = false;
|
||||
final static String TAG = "StatusBar/NavBarView";
|
||||
|
||||
@@ -104,6 +102,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
boolean mLongClickableAccessibilityButton;
|
||||
int mDisabledFlags = 0;
|
||||
int mNavigationIconHints = 0;
|
||||
private int mNavBarMode = NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
private Rect mHomeButtonBounds = new Rect();
|
||||
private Rect mBackButtonBounds = new Rect();
|
||||
@@ -234,13 +233,6 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
}
|
||||
};
|
||||
|
||||
private BroadcastReceiver mOverlaysChangedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
onOverlaysChanged();
|
||||
}
|
||||
};
|
||||
|
||||
public NavigationBarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
@@ -287,7 +279,6 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
|
||||
mEdgeBackGestureHandler = new EdgeBackGestureHandler(context, mOverviewProxyService);
|
||||
mTintController = new NavBarTintController(this, getLightTransitionsController());
|
||||
|
||||
}
|
||||
|
||||
public NavBarTintController getTintController() {
|
||||
@@ -470,7 +461,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
return;
|
||||
}
|
||||
|
||||
if (QuickStepContract.isGesturalMode(getContext())) {
|
||||
if (QuickStepContract.isGesturalMode(mNavBarMode)) {
|
||||
drawable.setRotation(degrees);
|
||||
return;
|
||||
}
|
||||
@@ -578,7 +569,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
|
||||
mBarTransitions.reapplyDarkIntensity();
|
||||
|
||||
boolean disableHome = QuickStepContract.isGesturalMode(getContext())
|
||||
boolean disableHome = QuickStepContract.isGesturalMode(mNavBarMode)
|
||||
|| ((mDisabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
|
||||
|
||||
// TODO(b/113914868): investigation log for disappearing home button
|
||||
@@ -588,7 +579,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
// Always disable recents when alternate car mode UI is active and for secondary displays.
|
||||
boolean disableRecent = isRecentsButtonDisabled();
|
||||
|
||||
boolean disableBack = !useAltBack && (QuickStepContract.isGesturalMode(getContext())
|
||||
boolean disableBack = !useAltBack && (QuickStepContract.isGesturalMode(mNavBarMode)
|
||||
|| ((mDisabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0));
|
||||
|
||||
// When screen pinning, don't hide back and home when connected service or back and
|
||||
@@ -724,7 +715,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
}
|
||||
|
||||
public void updateWindowTouchable() {
|
||||
boolean touchable = mImeVisible || !QuickStepContract.isGesturalMode(getContext());
|
||||
boolean touchable = mImeVisible || !QuickStepContract.isGesturalMode(mNavBarMode);
|
||||
setWindowFlag(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, !touchable);
|
||||
}
|
||||
|
||||
@@ -746,16 +737,21 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
wm.updateViewLayout(navbarView, lp);
|
||||
}
|
||||
|
||||
private void onOverlaysChanged() {
|
||||
mNavigationInflaterView.setNavigationBarLayout(null);
|
||||
@Override
|
||||
public void onNavigationModeChanged(int mode) {
|
||||
mNavBarMode = mode;
|
||||
mBarTransitions.onNavigationModeChanged(mNavBarMode);
|
||||
mEdgeBackGestureHandler.onNavigationModeChanged(mNavBarMode);
|
||||
mRecentsOnboarding.onNavigationModeChanged(mNavBarMode);
|
||||
|
||||
// Color adaption is tied with showing home handle, only avaliable if visible
|
||||
if (QuickStepContract.isGesturalMode(getContext())) {
|
||||
mTintController.onNavigationModeChanged(mNavBarMode);
|
||||
if (QuickStepContract.isGesturalMode(mNavBarMode)) {
|
||||
mTintController.start();
|
||||
} else {
|
||||
mTintController.stop();
|
||||
}
|
||||
mEdgeBackGestureHandler.onOverlaysChanged();
|
||||
updateWindowTouchable();
|
||||
}
|
||||
|
||||
public void setMenuVisibility(final boolean show) {
|
||||
@@ -938,7 +934,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
"onMeasure: (%dx%d) old: (%dx%d)", w, h, getMeasuredWidth(), getMeasuredHeight()));
|
||||
|
||||
final boolean newVertical = w > 0 && h > w
|
||||
&& !QuickStepContract.isGesturalMode(getContext());
|
||||
&& !QuickStepContract.isGesturalMode(mNavBarMode);
|
||||
if (newVertical != mIsVertical) {
|
||||
mIsVertical = newVertical;
|
||||
if (DEBUG) {
|
||||
@@ -949,7 +945,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
notifyVerticalChangedListener(newVertical);
|
||||
}
|
||||
|
||||
if (QuickStepContract.isGesturalMode(getContext())) {
|
||||
if (QuickStepContract.isGesturalMode(mNavBarMode)) {
|
||||
// Update the nav bar background to match the height of the visible nav bar
|
||||
int height = mIsVertical
|
||||
? getResources().getDimensionPixelSize(
|
||||
@@ -1048,11 +1044,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
onPluginDisconnected(null); // Create default gesture helper
|
||||
Dependency.get(PluginManager.class).addPluginListener(this,
|
||||
NavGesture.class, false /* Only one */);
|
||||
int navBarMode = Dependency.get(NavigationModeController.class).addListener(this);
|
||||
onNavigationModeChanged(navBarMode);
|
||||
setUpSwipeUpOnboarding(isQuickStepSwipeUpEnabled());
|
||||
|
||||
IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED);
|
||||
filter.addDataScheme("package");
|
||||
getContext().registerReceiver(mOverlaysChangedReceiver, filter);
|
||||
mEdgeBackGestureHandler.onNavBarAttached();
|
||||
updateWindowTouchable();
|
||||
}
|
||||
@@ -1061,6 +1056,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
Dependency.get(PluginManager.class).removePluginListener(this);
|
||||
Dependency.get(NavigationModeController.class).removeListener(this);
|
||||
if (mGestureHelper != null) {
|
||||
mGestureHelper.destroy();
|
||||
}
|
||||
@@ -1068,8 +1064,6 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
for (int i = 0; i < mButtonDispatchers.size(); ++i) {
|
||||
mButtonDispatchers.valueAt(i).onDestroy();
|
||||
}
|
||||
|
||||
getContext().unregisterReceiver(mOverlaysChangedReceiver);
|
||||
mEdgeBackGestureHandler.onNavBarDetached();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.content.Intent.ACTION_OVERLAY_CHANGED;
|
||||
import static android.content.Intent.ACTION_USER_SWITCHED;
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ApkAssets;
|
||||
import android.os.PatternMatcher;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.systemui.Dumpable;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Controller for tracking the current navigation bar mode.
|
||||
*/
|
||||
@Singleton
|
||||
public class NavigationModeController implements Dumpable {
|
||||
|
||||
private static final String TAG = NavigationModeController.class.getName();
|
||||
private static final boolean DEBUG = true;
|
||||
|
||||
public interface ModeChangedListener {
|
||||
void onNavigationModeChanged(int mode);
|
||||
}
|
||||
|
||||
private final Context mContext;
|
||||
private final IOverlayManager mOverlayManager;
|
||||
|
||||
private int mMode = NAV_BAR_MODE_3BUTTON;
|
||||
private ArrayList<ModeChangedListener> mListeners = new ArrayList<>();
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
context = getCurrentUserContext();
|
||||
int mode = getCurrentInteractionMode(context);
|
||||
mMode = mode;
|
||||
if (DEBUG) {
|
||||
Log.e(TAG, "ACTION_OVERLAY_CHANGED: mode=" + mMode
|
||||
+ " contextUser=" + context.getUserId());
|
||||
dumpAssetPaths(context);
|
||||
}
|
||||
|
||||
for (int i = 0; i < mListeners.size(); i++) {
|
||||
mListeners.get(i).onNavigationModeChanged(mode);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Inject
|
||||
public NavigationModeController(Context context) {
|
||||
mContext = context;
|
||||
mOverlayManager = IOverlayManager.Stub.asInterface(
|
||||
ServiceManager.getService(Context.OVERLAY_SERVICE));
|
||||
|
||||
IntentFilter overlayFilter = new IntentFilter(ACTION_OVERLAY_CHANGED);
|
||||
overlayFilter.addDataScheme("package");
|
||||
overlayFilter.addDataSchemeSpecificPart("android", PatternMatcher.PATTERN_LITERAL);
|
||||
mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, overlayFilter, null, null);
|
||||
|
||||
IntentFilter userFilter = new IntentFilter(ACTION_USER_SWITCHED);
|
||||
mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, userFilter, null, null);
|
||||
|
||||
mMode = getCurrentInteractionMode(getCurrentUserContext());
|
||||
}
|
||||
|
||||
public int addListener(ModeChangedListener listener) {
|
||||
mListeners.add(listener);
|
||||
return getCurrentInteractionMode(mContext);
|
||||
}
|
||||
|
||||
public void removeListener(ModeChangedListener listener) {
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
private int getCurrentInteractionMode(Context context) {
|
||||
int mode = context.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_navBarInteractionMode);
|
||||
return mode;
|
||||
}
|
||||
|
||||
private Context getCurrentUserContext() {
|
||||
int userId = ActivityManagerWrapper.getInstance().getCurrentUserId();
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "getCurrentUserContext: contextUser=" + mContext.getUserId()
|
||||
+ " currentUser=" + userId);
|
||||
}
|
||||
if (mContext.getUserId() == userId) {
|
||||
return mContext;
|
||||
}
|
||||
try {
|
||||
return mContext.createPackageContextAsUser(mContext.getPackageName(),
|
||||
0 /* flags */, UserHandle.of(userId));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
// Never happens for the sysui package
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
pw.println("NavigationModeController:");
|
||||
pw.println(" mode=" + mMode);
|
||||
dumpAssetPaths(getCurrentUserContext());
|
||||
}
|
||||
|
||||
private void dumpAssetPaths(Context context) {
|
||||
Log.d(TAG, "assetPaths=");
|
||||
ApkAssets[] assets = context.getResources().getAssets().getApkAssets();
|
||||
for (ApkAssets a : assets) {
|
||||
Log.d(TAG, " " + a.getAssetPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.content.ComponentCallbacks;
|
||||
import android.content.Context;
|
||||
@@ -119,7 +121,7 @@ public class NavigationPrototypeController extends ContentObserver implements Co
|
||||
mListener.onHomeButtonVisibilityChanged(!hideHomeButton());
|
||||
} else if (path.endsWith(NAV_COLOR_ADAPT_ENABLE_SETTING)) {
|
||||
mListener.onColorAdaptChanged(
|
||||
NavBarTintController.isEnabled(mContext));
|
||||
NavBarTintController.isEnabled(mContext, NAV_BAR_MODE_GESTURAL));
|
||||
} else if (path.endsWith(SHOW_HOME_HANDLE_SETTING)) {
|
||||
mListener.onHomeHandleVisiblilityChanged(showHomeHandle());
|
||||
} else if (path.endsWith(ENABLE_ASSISTANT_GESTURE)) {
|
||||
@@ -132,7 +134,8 @@ public class NavigationPrototypeController extends ContentObserver implements Co
|
||||
* @return the width for edge swipe
|
||||
*/
|
||||
public int getEdgeSensitivityWidth() {
|
||||
return QuickStepContract.getEdgeSensitivityWidth(mContext);
|
||||
return mContext.getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.config_backGestureInset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,7 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class StatusBarKeyguardViewManager implements RemoteInputController.Callback,
|
||||
StatusBarStateController.StateListener, ConfigurationController.ConfigurationListener,
|
||||
NotificationPanelView.PanelExpansionListener {
|
||||
NotificationPanelView.PanelExpansionListener, NavigationModeController.ModeChangedListener {
|
||||
|
||||
// When hiding the Keyguard with timing supplied from WindowManager, better be early than late.
|
||||
private static final long HIDE_TIMING_CORRECTION_MS = - 16 * 3;
|
||||
@@ -192,10 +192,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
mViewMediatorCallback = callback;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
mStatusBarWindowController = Dependency.get(StatusBarWindowController.class);
|
||||
mGesturalNav = QuickStepContract.isGesturalMode(context);
|
||||
KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitorCallback);
|
||||
mStatusBarStateController.addCallback(this);
|
||||
Dependency.get(ConfigurationController.class).addCallback(this);
|
||||
mLastGesturalNav = QuickStepContract.isGesturalMode(
|
||||
Dependency.get(NavigationModeController.class).addListener(this));
|
||||
mDockManager = SysUiServiceProvider.getComponent(context, DockManager.class);
|
||||
if (mDockManager != null) {
|
||||
mDockManager.addListener(mDockEventListener);
|
||||
@@ -587,8 +588,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOverlayChanged() {
|
||||
boolean gesturalNav = QuickStepContract.isGesturalMode(mContext);
|
||||
public void onNavigationModeChanged(int mode) {
|
||||
boolean gesturalNav = QuickStepContract.isGesturalMode(mode);
|
||||
if (gesturalNav != mGesturalNav) {
|
||||
mGesturalNav = gesturalNav;
|
||||
updateStates();
|
||||
|
||||
@@ -214,7 +214,8 @@ public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
|
||||
deviceProvisionedController,
|
||||
new MetricsLogger(),
|
||||
mock(AssistManager.class),
|
||||
mOverviewProxyService);
|
||||
mOverviewProxyService,
|
||||
mock(NavigationModeController.class));
|
||||
}
|
||||
|
||||
private class HostCallbacksForExternalDisplay extends
|
||||
|
||||
Reference in New Issue
Block a user