Move all logic of navigation bar to NavigationBarController(2/N)
Since we don't have status bar on external displays, we need to saparate
the logic to make some animations or transitions just work on external
navigation bars. When we set System UI visibility on an external display,
we could make the flag only effect navigation bar. Also, it can simplify
StatusBar code by moving navigation bar related fields into
NavigationBarController.
Test: atest SystemUITests
Bug: 117478341
Change-Id: I1cdf61f6eeb2c377e04a073401efa0cdb45b65cd
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index b089a1a..6e50429 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -46,7 +46,7 @@
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.AmbientPulseManager;
-import com.android.systemui.statusbar.DisplayNavigationBarController;
+import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -244,7 +244,7 @@
@Inject Lazy<NotificationRemoteInputManager.Callback> mNotificationRemoteInputManagerCallback;
@Inject Lazy<InitController> mInitController;
@Inject Lazy<AppOpsController> mAppOpsController;
- @Inject Lazy<DisplayNavigationBarController> mDisplayNavigationBarController;
+ @Inject Lazy<NavigationBarController> mNavigationBarController;
@Inject Lazy<StatusBarStateController> mStatusBarStateController;
@Inject Lazy<NotificationLockscreenUserManager> mNotificationLockscreenUserManager;
@Inject Lazy<NotificationGroupAlertTransferHelper> mNotificationGroupAlertTransferHelper;
@@ -410,8 +410,7 @@
mProviders.put(AppOpsController.class, mAppOpsController::get);
- mProviders.put(DisplayNavigationBarController.class,
- mDisplayNavigationBarController::get);
+ mProviders.put(NavigationBarController.class, mNavigationBarController::get);
mProviders.put(StatusBarStateController.class, mStatusBarStateController::get);
mProviders.put(NotificationLockscreenUserManager.class,
diff --git a/packages/SystemUI/src/com/android/systemui/DependencyProvider.java b/packages/SystemUI/src/com/android/systemui/DependencyProvider.java
index 2b521c5..5c9b999 100644
--- a/packages/SystemUI/src/com/android/systemui/DependencyProvider.java
+++ b/packages/SystemUI/src/com/android/systemui/DependencyProvider.java
@@ -41,6 +41,7 @@
import com.android.systemui.plugins.PluginInitializerImpl;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.shared.plugins.PluginManagerImpl;
+import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -170,6 +171,13 @@
@Singleton
@Provides
+ public NavigationBarController provideNavigationBarController(Context context,
+ @Named(MAIN_HANDLER_NAME) Handler mainHandler) {
+ return new NavigationBarController(context, mainHandler);
+ }
+
+ @Singleton
+ @Provides
public ConfigurationController provideConfigurationController(Context context) {
return new ConfigurationControllerImpl(context);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DisplayNavigationBarController.java b/packages/SystemUI/src/com/android/systemui/statusbar/DisplayNavigationBarController.java
deleted file mode 100644
index 78172f1..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DisplayNavigationBarController.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2018 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;
-
-import static android.view.Display.DEFAULT_DISPLAY;
-
-import static com.android.systemui.Dependency.MAIN_HANDLER_NAME;
-
-import android.content.Context;
-import android.hardware.display.DisplayManager;
-import android.hardware.display.DisplayManager.DisplayListener;
-import android.os.Handler;
-import android.os.RemoteException;
-import android.util.Log;
-import android.util.SparseArray;
-import android.view.Display;
-import android.view.IWindowManager;
-import android.view.View;
-import android.view.WindowManagerGlobal;
-
-import com.android.systemui.statusbar.phone.NavigationBarFragment;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-/**
- * A controller to handle external navigation bars
- */
-@Singleton
-public class DisplayNavigationBarController implements DisplayListener {
-
- private static final String TAG = DisplayNavigationBarController.class.getName();
-
- private final Context mContext;
- private final Handler mHandler;
- private final DisplayManager mDisplayManager;
-
- /** A displayId - nav bar mapping */
- private SparseArray<NavigationBarFragment> mExternalNavigationBarMap = new SparseArray<>();
-
- @Inject
- public DisplayNavigationBarController(Context context,
- @Named(MAIN_HANDLER_NAME) Handler handler) {
- mContext = context;
- mHandler = handler;
- mDisplayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
-
- registerListener();
- }
-
- @Override
- public void onDisplayAdded(int displayId) {
- final Display display = mDisplayManager.getDisplay(displayId);
- addExternalNavigationBar(display);
- }
-
- @Override
- public void onDisplayRemoved(int displayId) {
- final NavigationBarFragment navBar = mExternalNavigationBarMap.get(displayId);
- if (navBar != null) {
- final View navigationView = navBar.getView().getRootView();
- WindowManagerGlobal.getInstance().removeView(navigationView, true);
- mExternalNavigationBarMap.remove(displayId);
- }
- }
-
- @Override
- public void onDisplayChanged(int displayId) {
- }
-
- /** Create external navigation bars when car/status bar initializes */
- public void createNavigationBars() {
- // Add external navigation bars if more than one displays exist.
- final Display[] displays = mDisplayManager.getDisplays();
- for (Display display : displays) {
- addExternalNavigationBar(display);
- }
- }
-
- /** remove external navigation bars and unset everything related to external navigation bars */
- public void destroy() {
- unregisterListener();
- if (mExternalNavigationBarMap.size() > 0) {
- for (int i = 0; i < mExternalNavigationBarMap.size(); i++) {
- final View navigationWindow = mExternalNavigationBarMap.valueAt(i)
- .getView().getRootView();
- WindowManagerGlobal.getInstance()
- .removeView(navigationWindow, true /* immediate */);
- }
- mExternalNavigationBarMap.clear();
- }
- }
-
- private void registerListener() {
- mDisplayManager.registerDisplayListener(this, mHandler);
- }
-
- private void unregisterListener() {
- mDisplayManager.unregisterDisplayListener(this);
- }
-
- /**
- * Add a phone navigation bar on an external display if the display supports system decorations.
- *
- * @param display the display to add navigation bar on
- */
- private void addExternalNavigationBar(Display display) {
- if (display == null || display.getDisplayId() == DEFAULT_DISPLAY
- || !display.supportsSystemDecorations()) {
- return;
- }
-
- final int displayId = display.getDisplayId();
- final IWindowManager wms = WindowManagerGlobal.getWindowManagerService();
-
- try {
- if (!wms.hasNavigationBar(displayId)) {
- return;
- }
- } catch (RemoteException e) {
- // Cannot get wms, just return with warning message.
- Log.w(TAG, "Cannot get WindowManager.");
- return;
- }
- final Context externalDisplayContext = mContext.createDisplayContext(display);
- NavigationBarFragment.create(externalDisplayContext, (tag, fragment) -> {
- final NavigationBarFragment navBar = (NavigationBarFragment) fragment;
- // TODO(b/115978725): handle external nav bars sysuiVisibility
- navBar.setCurrentSysuiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
- mExternalNavigationBarMap.append(displayId, navBar);
- });
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
new file mode 100644
index 0000000..43eaff4
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2018 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;
+
+import static android.view.Display.DEFAULT_DISPLAY;
+
+import static com.android.systemui.Dependency.MAIN_HANDLER_NAME;
+
+import android.content.Context;
+import android.hardware.display.DisplayManager;
+import android.hardware.display.DisplayManager.DisplayListener;
+import android.os.Handler;
+import android.os.RemoteException;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.Display;
+import android.view.IWindowManager;
+import android.view.View;
+import android.view.WindowManagerGlobal;
+
+import com.android.systemui.Dependency;
+import com.android.systemui.plugins.DarkIconDispatcher;
+import com.android.systemui.statusbar.phone.BarTransitions.TransitionMode;
+import com.android.systemui.statusbar.phone.LightBarController;
+import com.android.systemui.statusbar.phone.NavigationBarFragment;
+import com.android.systemui.statusbar.phone.NavigationBarView;
+import com.android.systemui.statusbar.policy.BatteryController;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+
+/** A controller to handle navigation bars. */
+@Singleton
+public class NavigationBarController implements DisplayListener {
+
+ private static final String TAG = NavigationBarController.class.getName();
+
+ private final Context mContext;
+ private final Handler mHandler;
+ private final DisplayManager mDisplayManager;
+
+ /** A displayId - nav bar maps. */
+ private SparseArray<NavigationBarFragment> mNavigationBars = new SparseArray<>();
+
+ @Inject
+ public NavigationBarController(Context context, @Named(MAIN_HANDLER_NAME) Handler handler) {
+ mContext = context;
+ mHandler = handler;
+ mDisplayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
+ mDisplayManager.registerDisplayListener(this, mHandler);
+ }
+
+ @Override
+ public void onDisplayAdded(int displayId) {
+ Display display = mDisplayManager.getDisplay(displayId);
+ createNavigationBar(display);
+ }
+
+ @Override
+ public void onDisplayRemoved(int displayId) {
+ removeNavigationBar(displayId);
+ }
+
+ @Override
+ public void onDisplayChanged(int displayId) {
+ }
+
+ // TODO(b/117478341): I use {@code includeDefaultDisplay} to make this method compatible to
+ // CarStatusBar because they have their own nav bar. Think about a better way for it.
+ /**
+ * Creates navigation bars when car/status bar initializes.
+ *
+ * @param includeDefaultDisplay {@code true} to create navigation bar on default display.
+ */
+ public void createNavigationBars(final boolean includeDefaultDisplay) {
+ Display[] displays = mDisplayManager.getDisplays();
+ for (Display display : displays) {
+ if (includeDefaultDisplay || display.getDisplayId() != DEFAULT_DISPLAY) {
+ createNavigationBar(display);
+ }
+ }
+ }
+
+ /**
+ * Adds a navigation bar on default display or an external display if the display supports
+ * system decorations.
+ *
+ * @param display the display to add navigation bar on.
+ */
+ private void createNavigationBar(Display display) {
+ if (display == null
+ || (display.getDisplayId() != DEFAULT_DISPLAY
+ && !display.supportsSystemDecorations())) {
+ return;
+ }
+
+ final int displayId = display.getDisplayId();
+ final boolean isOnDefaultDisplay = displayId == DEFAULT_DISPLAY;
+ final IWindowManager wms = WindowManagerGlobal.getWindowManagerService();
+
+ try {
+ if (!wms.hasNavigationBar(displayId)) {
+ return;
+ }
+ } catch (RemoteException e) {
+ // Cannot get wms, just return with warning message.
+ Log.w(TAG, "Cannot get WindowManager.");
+ return;
+ }
+ final Context context = isOnDefaultDisplay
+ ? mContext
+ : mContext.createDisplayContext(display);
+ NavigationBarFragment.create(context, (tag, fragment) -> {
+ NavigationBarFragment navBar = (NavigationBarFragment) fragment;
+
+ // Unfortunately, we still need it because status bar needs LightBarController
+ // before notifications creation. We cannot directly use getLightBarController()
+ // from NavigationBarFragment directly.
+ LightBarController controller = isOnDefaultDisplay
+ ? Dependency.get(LightBarController.class)
+ : new LightBarController(context,
+ Dependency.get(DarkIconDispatcher.class),
+ Dependency.get(BatteryController.class));
+ navBar.setLightBarController(controller);
+ navBar.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
+ mNavigationBars.append(displayId, navBar);
+ });
+ }
+
+ /** Removes navigation bars. */
+ public void destroy() {
+ mDisplayManager.unregisterDisplayListener(this);
+ if (mNavigationBars.size() > 0) {
+ for (int i = 0; i < mNavigationBars.size(); i++) {
+ int displayId = mNavigationBars.keyAt(i);
+ removeNavigationBar(displayId);
+ }
+ mNavigationBars.clear();
+ }
+ }
+
+ private void removeNavigationBar(int displayId) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
+ if (navBar != null) {
+ View navigationWindow = navBar.getView().getRootView();
+ WindowManagerGlobal.getInstance()
+ .removeView(navigationWindow, true /* immediate */);
+ mNavigationBars.remove(displayId);
+ }
+ }
+
+ /** @see NavigationBarFragment#checkNavBarModes() */
+ public void checkNavBarModes(int displayId) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
+ if (navBar != null) {
+ navBar.checkNavBarModes();
+ }
+ }
+
+ /** @see NavigationBarFragment#finishBarAnimations() */
+ public void finishBarAnimations(int displayId) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
+ if (navBar != null) {
+ navBar.finishBarAnimations();
+ }
+ }
+
+ /** @see NavigationBarFragment#touchAutoDim() */
+ public void touchAutoDim(int displayId) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
+ if (navBar != null) {
+ navBar.touchAutoDim();
+ }
+ }
+
+ /** @see NavigationBarFragment#transitionTo(int, boolean) */
+ public void transitionTo(int displayId, @TransitionMode int barMode, boolean animate) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
+ if (navBar != null) {
+ navBar.transitionTo(barMode, animate);
+ }
+ }
+
+ /** @see NavigationBarFragment#isSemiTransparent() */
+ public boolean isSemiTransparent(int displayId) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
+ if (navBar != null) {
+ return navBar.isSemiTransparent();
+ }
+ return false;
+ }
+
+ /** @see NavigationBarFragment#disableAnimationsDuringHide(long) */
+ public void disableAnimationsDuringHide(int displayId, long delay) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
+ if (navBar != null) {
+ navBar.disableAnimationsDuringHide(delay);
+ }
+ }
+
+ /** @return {@link NavigationBarView} on the default display. */
+ public NavigationBarView getDefaultNavigationBarView() {
+ NavigationBarFragment navBar = mNavigationBars.get(DEFAULT_DISPLAY);
+ return (navBar == null) ? null : (NavigationBarView) navBar.getView();
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
index 3d81473..7905617 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.phone;
+import android.annotation.IntDef;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@@ -36,6 +37,9 @@
import com.android.systemui.Interpolators;
import com.android.systemui.R;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
public class BarTransitions {
private static final boolean DEBUG = false;
private static final boolean DEBUG_COLORS = false;
@@ -48,6 +52,18 @@
public static final int MODE_WARNING = 5;
public static final int MODE_LIGHTS_OUT_TRANSPARENT = 6;
+ @IntDef(flag = true, prefix = { "MODE_" }, value = {
+ MODE_OPAQUE,
+ MODE_SEMI_TRANSPARENT,
+ MODE_TRANSLUCENT,
+ MODE_LIGHTS_OUT,
+ MODE_TRANSPARENT,
+ MODE_WARNING,
+ MODE_LIGHTS_OUT_TRANSPARENT
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface TransitionMode {}
+
public static final int LIGHTS_IN_DURATION = 250;
public static final int LIGHTS_OUT_DURATION = 1500;
public static final int BACKGROUND_DURATION = 200;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index 2daff2c..270565b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -16,14 +16,19 @@
import static android.app.StatusBarManager.NAVIGATION_HINT_BACK_ALT;
import static android.app.StatusBarManager.NAVIGATION_HINT_IME_SHOWN;
+import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.app.StatusBarManager.windowStateToString;
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
import static com.android.systemui.shared.system.NavigationBarCompat.InteractionType;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_LIGHTS_OUT_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_SEMI_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode;
import static com.android.systemui.statusbar.phone.StatusBar.DEBUG_WINDOW_STATE;
import static com.android.systemui.statusbar.phone.StatusBar.dumpBarTransitions;
@@ -55,6 +60,7 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.Display;
+import android.view.IWindowManager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -63,6 +69,7 @@
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
+import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityManager.AccessibilityServicesStateChangeListener;
@@ -72,6 +79,7 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.LatencyTracker;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.assist.AssistManager;
@@ -83,6 +91,8 @@
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue.Callbacks;
+import com.android.systemui.statusbar.StatusBarState;
+import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.stack.StackStateAnimator;
import com.android.systemui.statusbar.phone.ContextualButton.ContextButtonListener;
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
@@ -111,6 +121,7 @@
/** Allow some time inbetween the long press for back and recents. */
private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200;
+ private static final long AUTOHIDE_TIMEOUT_MS = 2250;
private final AccessibilityManagerWrapper mAccessibilityManagerWrapper;
protected final AssistManager mAssistManager;
@@ -122,10 +133,11 @@
private int mNavigationBarWindowState = WINDOW_STATE_SHOWING;
private int mNavigationIconHints = 0;
- private int mNavigationBarMode;
+ private @TransitionMode int mNavigationBarMode;
private AccessibilityManager mAccessibilityManager;
private MagnificationContentObserver mMagnificationObserver;
private ContentResolver mContentResolver;
+ private IWindowManager mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
private int mDisabledFlags1;
private int mDisabledFlags2;
@@ -144,9 +156,15 @@
private OverviewProxyService mOverviewProxyService;
- private boolean mIsOnDefaultDisplay = true;
+ private int mDisplayId;
+ private boolean mIsOnDefaultDisplay;
public boolean mHomeBlockedThisTouch;
+ private Handler mHandler = Dependency.get(Dependency.MAIN_HANDLER);
+
+ // last value sent to window manager
+ private int mLastDispatchedSystemUiVisibility = ~View.SYSTEM_UI_FLAG_VISIBLE;
+
private final OverviewProxyListener mOverviewProxyListener = new OverviewProxyListener() {
@Override
public void onConnectionChanged(boolean isConnected) {
@@ -183,14 +201,20 @@
}
};
- private final ContextButtonListener mRotationButtonListener = new ContextButtonListener() {
- @Override
- public void onVisibilityChanged(ContextualButton button, boolean visible) {
- if (visible) {
- // If the button will actually become visible and the navbar is about to hide,
- // tell the statusbar to keep it around for longer
- mStatusBar.touchAutoHide();
- }
+ private final ContextButtonListener mRotationButtonListener = (button, visible) -> {
+ if (visible) {
+ // If the button will actually become visible and the navbar is about to hide,
+ // tell the statusbar to keep it around for longer
+ touchAutoHide();
+ }
+ };
+
+ private final Runnable mAutoDim = () -> getBarTransitions().setAutoDim(true);
+
+ private final Runnable mAutoHide = () -> {
+ int requested = mSystemUiVisibility & ~View.NAVIGATION_BAR_TRANSIENT;
+ if (mSystemUiVisibility != requested) {
+ notifySystemUiVisibilityChanged(requested);
}
};
@@ -251,7 +275,8 @@
final Display display = view.getDisplay();
// It may not have display when running unit test.
if (display != null) {
- mIsOnDefaultDisplay = display.getDisplayId() == Display.DEFAULT_DISPLAY;
+ mDisplayId = display.getDisplayId();
+ mIsOnDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY;
}
mNavigationBarView.setComponents(mStatusBar.getPanel());
@@ -381,7 +406,7 @@
if (mNavigationBarView != null) {
mNavigationBarView.setNavigationIconHints(hints);
}
- mStatusBar.checkBarModes();
+ checkBarModes();
}
@Override
@@ -426,23 +451,22 @@
.onRotationProposal(rotation, winRotation, isValid);
}
- // Injected from StatusBar at creation.
- public void setCurrentSysuiVisibility(int systemUiVisibility) {
+ /**
+ * Sets System UI flags to {@link NavigationBarFragment}.
+ *
+ * @see View#setSystemUiVisibility(int)
+ */
+ public void setSystemUiVisibility(int systemUiVisibility) {
mSystemUiVisibility = systemUiVisibility;
- final int barMode = mStatusBar.computeBarMode(0, mSystemUiVisibility,
- View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT,
- View.NAVIGATION_BAR_TRANSPARENT);
+ final int barMode = computeBarMode(0, mSystemUiVisibility);
if (barMode != -1) {
mNavigationBarMode = barMode;
}
checkNavBarModes();
- mStatusBar.touchAutoHide();
+ touchAutoHide();
- // TODO(115978725): Support light bar controller on external nav bars.
- if (mLightBarController != null) {
- mLightBarController.onNavigationVisibilityChanged(mSystemUiVisibility, 0 /* mask */,
+ mLightBarController.onNavigationVisibilityChanged(mSystemUiVisibility, 0 /* mask */,
true /* nbModeChanged */, mNavigationBarMode);
- }
}
@Override
@@ -457,9 +481,7 @@
// update navigation bar mode
final int nbMode = getView() == null
- ? -1 : mStatusBar.computeBarMode(oldVal, newVal,
- View.NAVIGATION_BAR_TRANSIENT, View.NAVIGATION_BAR_TRANSLUCENT,
- View.NAVIGATION_BAR_TRANSPARENT);
+ ? -1 : computeBarMode(oldVal, newVal);
nbModeChanged = nbMode != -1;
if (nbModeChanged) {
if (mNavigationBarMode != nbMode) {
@@ -470,14 +492,46 @@
mNavigationBarMode = nbMode;
checkNavBarModes();
}
- mStatusBar.touchAutoHide();
+ touchAutoHide();
+ }
+ if ((vis & View.NAVIGATION_BAR_UNHIDE) != 0) {
+ mSystemUiVisibility &= ~View.NAVIGATION_BAR_UNHIDE;
+ }
+
+
+ // On the default display, just make StatusBar do this job.
+ if (!mIsOnDefaultDisplay) {
+ notifySystemUiVisibilityChanged(mSystemUiVisibility);
}
}
+ mLightBarController.onNavigationVisibilityChanged(
+ vis, mask, nbModeChanged, mNavigationBarMode);
+ }
- // TODO(115978725): Support light bar controller on external nav bars.
- if (mLightBarController != null) {
- mLightBarController.onNavigationVisibilityChanged(vis, mask, nbModeChanged,
- mNavigationBarMode);
+ private @TransitionMode int computeBarMode(int oldVis, int newVis) {
+ final int oldMode = barMode(oldVis);
+ final int newMode = barMode(newVis);
+ if (oldMode == newMode) {
+ return -1; // no mode change
+ }
+ return newMode;
+ }
+
+ private @TransitionMode int barMode(int vis) {
+ final int lightsOutTransparent =
+ View.SYSTEM_UI_FLAG_LOW_PROFILE | View.NAVIGATION_BAR_TRANSIENT;
+ if ((vis & View.NAVIGATION_BAR_TRANSIENT) != 0) {
+ return MODE_SEMI_TRANSPARENT;
+ } else if ((vis & View.NAVIGATION_BAR_TRANSLUCENT) != 0) {
+ return MODE_TRANSLUCENT;
+ } else if ((vis & lightsOutTransparent) == lightsOutTransparent) {
+ return MODE_LIGHTS_OUT_TRANSPARENT;
+ } else if ((vis & View.NAVIGATION_BAR_TRANSPARENT) != 0) {
+ return MODE_TRANSPARENT;
+ } else if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
+ return MODE_LIGHTS_OUT;
+ } else {
+ return MODE_OPAQUE;
}
}
@@ -511,7 +565,7 @@
}
}
- // ----- Internal stuffz -----
+ // ----- Internal stuff -----
private void refreshLayout(int layoutDirection) {
if (mNavigationBarView != null) {
@@ -610,7 +664,7 @@
}
private boolean onNavigationTouch(View v, MotionEvent event) {
- mStatusBar.checkUserAutohide(event);
+ checkUserAutoHide(event);
return false;
}
@@ -800,7 +854,79 @@
mNavigationBarView.setAccessibilityButtonState(showAccessibilityButton, targetSelection);
}
- // ----- Methods that StatusBar talks to (should be minimized) -----
+ private void touchAutoHide() {
+ // There is status bar on default display. Thus the hide animations should apply on both
+ // status/navigation bar.
+ if (mIsOnDefaultDisplay) {
+ mStatusBar.touchAutoHide();
+ } else {
+ touchAutoHideInternal();
+ }
+ }
+
+ private void touchAutoHideInternal() {
+ // update transient bar autoHide.
+ if (isSemiTransparent()) {
+ scheduleAutoHide();
+ } else {
+ cancelAutoHide();
+ }
+ }
+
+ private void checkUserAutoHide(MotionEvent event) {
+ // There is status bar on default display. Thus the hide animations should apply on both
+ // status/navigation bar.
+ if (mIsOnDefaultDisplay) {
+ mStatusBar.checkUserAutoHide(event);
+ } else {
+ checkUserAutoHideInternal(event);
+ }
+ }
+
+ private void checkUserAutoHideInternal(MotionEvent event) {
+ if ((mSystemUiVisibility & View.NAVIGATION_BAR_TRANSIENT) != 0
+ // a transient bar is revealed
+ && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar.
+ && event.getX() == 0 && event.getY() == 0) { // a touch outside both bars.
+ userAutoHide();
+ }
+ }
+
+ private void userAutoHide() {
+ cancelAutoHide();
+ mHandler.postDelayed(mAutoHide, 350); // longer than app gesture -> flag clear.
+ }
+
+ private void cancelAutoHide() {
+ mHandler.removeCallbacks(mAutoHide);
+ }
+
+ private void scheduleAutoHide() {
+ cancelAutoHide();
+ mHandler.postDelayed(mAutoHide, AUTOHIDE_TIMEOUT_MS);
+ }
+
+ private void notifySystemUiVisibilityChanged(int vis) {
+ try {
+ if (mLastDispatchedSystemUiVisibility != vis) {
+ mWindowManagerService.statusBarVisibilityChanged(mDisplayId, vis);
+ mLastDispatchedSystemUiVisibility = vis;
+ }
+ } catch (RemoteException ex) {
+ }
+ }
+
+ // ----- Methods that DisplayNavigationBarController talks to -----
+
+ /** Applys auto dimming animation on navigation bar when touched. */
+ public void touchAutoDim() {
+ getBarTransitions().setAutoDim(false);
+ mHandler.removeCallbacks(mAutoDim);
+ int state = Dependency.get(StatusBarStateController.class).getState();
+ if (state != StatusBarState.KEYGUARD && state != StatusBarState.SHADE_LOCKED) {
+ mHandler.postDelayed(mAutoDim, AUTOHIDE_TIMEOUT_MS);
+ }
+ }
public void setLightBarController(LightBarController lightBarController) {
mLightBarController = lightBarController;
@@ -811,19 +937,42 @@
return mNavigationBarMode == MODE_SEMI_TRANSPARENT;
}
+ private void checkBarModes() {
+ // We only have status bar on default display now.
+ if (mIsOnDefaultDisplay) {
+ mStatusBar.checkBarModes();
+ } else {
+ checkNavBarModes();
+ }
+ }
+
+ /**
+ * Checks current navigation bar mode and make transitions.
+ */
+ public void checkNavBarModes() {
+ final boolean anim = mStatusBar.isDeviceInteractive()
+ && mNavigationBarWindowState != WINDOW_STATE_HIDDEN;
+ mNavigationBarView.getBarTransitions().transitionTo(mNavigationBarMode, anim);
+ }
+
public void disableAnimationsDuringHide(long delay) {
mNavigationBarView.setLayoutTransitionsEnabled(false);
mNavigationBarView.postDelayed(() -> mNavigationBarView.setLayoutTransitionsEnabled(true),
delay + StackStateAnimator.ANIMATION_DURATION_GO_TO_FULL_SHADE);
}
- public BarTransitions getBarTransitions() {
- return mNavigationBarView.getBarTransitions();
+ /**
+ * Performs transitions on navigation bar.
+ *
+ * @param barMode transition bar mode.
+ * @param animate shows animations if {@code true}.
+ */
+ public void transitionTo(@TransitionMode int barMode, boolean animate) {
+ getBarTransitions().transitionTo(barMode, animate);
}
- public void checkNavBarModes() {
- mStatusBar.checkBarMode(mNavigationBarMode,
- mNavigationBarWindowState, mNavigationBarView.getBarTransitions());
+ private BarTransitions getBarTransitions() {
+ return mNavigationBarView.getBarTransitions();
}
public void finishBarAnimations() {
@@ -873,12 +1022,11 @@
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
// The accessibility settings may be different for the new user
updateAccessibilityServicesState(mAccessibilityManager);
- };
+ }
}
};
public static View create(Context context, FragmentListener listener) {
- final int displayId = context.getDisplay().getDisplayId();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_NAVIGATION_BAR,
@@ -890,7 +1038,7 @@
| WindowManager.LayoutParams.FLAG_SLIPPERY,
PixelFormat.TRANSLUCENT);
lp.token = new Binder();
- lp.setTitle("NavigationBar" + displayId);
+ lp.setTitle("NavigationBar" + context.getDisplayId());
lp.accessibilityTitle = context.getString(R.string.nav_bar);
lp.windowAnimations = 0;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 9642b8d..9f0eec4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -37,6 +37,7 @@
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSLUCENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_WARNING;
+import static com.android.systemui.statusbar.phone.BarTransitions.TransitionMode;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -71,7 +72,6 @@
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
-import android.hardware.display.DisplayManager;
import android.media.AudioAttributes;
import android.metrics.LogMaker;
import android.net.Uri;
@@ -170,11 +170,11 @@
import com.android.systemui.statusbar.BackDropView;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CrossFadeHelper;
-import com.android.systemui.statusbar.DisplayNavigationBarController;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyboardShortcuts;
import com.android.systemui.statusbar.KeyguardIndicationController;
+import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -447,18 +447,18 @@
protected final H mHandler = createHandler();
private int mInteractingWindows;
- private boolean mAutohideSuspended;
- private int mStatusBarMode;
+ private boolean mAutoHideSuspended;
+ private @TransitionMode int mStatusBarMode;
private ViewMediatorCallback mKeyguardViewMediatorCallback;
protected ScrimController mScrimController;
protected DozeScrimController mDozeScrimController;
private final UiOffloadThread mUiOffloadThread = Dependency.get(UiOffloadThread.class);
- private final Runnable mAutohide = () -> {
+ private final Runnable mAutoHide = () -> {
int requested = mSystemUiVisibility & ~STATUS_OR_NAV_TRANSIENT;
if (mSystemUiVisibility != requested) {
- notifyUiVisibilityChanged(requested);
+ notifySystemUiVisibilityChanged(requested);
}
};
@@ -585,11 +585,6 @@
}
};
- protected DisplayManager mDisplayManager;
-
- private NavigationBarFragment mNavigationBar;
- private View mNavigationBarView;
-
private HeadsUpAppearanceController mHeadsUpAppearanceController;
private boolean mVibrateOnOpening;
private VibratorHelper mVibratorHelper;
@@ -643,7 +638,7 @@
mKeyguardViewMediator = getComponent(KeyguardViewMediator.class);
mColorExtractor = Dependency.get(SysuiColorExtractor.class);
mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
- mNavigationBarController = Dependency.get(DisplayNavigationBarController.class);
+ mNavigationBarController = Dependency.get(NavigationBarController.class);
mBubbleController = Dependency.get(BubbleController.class);
mBubbleController.setExpandListener(mBubbleExpandListener);
KeyguardSliceProvider sliceProvider = KeyguardSliceProvider.getAttachedInstance();
@@ -907,11 +902,7 @@
}
});
- // TODO(115978725): Support light bar controller on external nav bars.
mLightBarController = Dependency.get(LightBarController.class);
- if (mNavigationBar != null) {
- mNavigationBar.setLightBarController(mLightBarController);
- }
ScrimView scrimBehind = mStatusBarWindow.findViewById(R.id.scrim_behind);
ScrimView scrimInFront = mStatusBarWindow.findViewById(R.id.scrim_in_front);
@@ -1097,25 +1088,10 @@
}
}
+ // TODO(b/117478341): This was left such that CarStatusBar can override this method.
+ // Try to remove this.
protected void createNavigationBar() {
- try {
- // TODO(117478341): Move this into DisplayNavigationBarController#createNavigationBars
- // for-loop. We will also move the whole navigation bar logic together.
- final boolean showNav = mWindowManagerService.hasNavigationBar(DEFAULT_DISPLAY);
- if (DEBUG) Log.v(TAG, "hasNavigationBar=" + showNav);
- if (!showNav) return;
-
- mNavigationBarView = NavigationBarFragment.create(mContext, (tag, fragment) -> {
- mNavigationBar = (NavigationBarFragment) fragment;
- if (mLightBarController != null) {
- mNavigationBar.setLightBarController(mLightBarController);
- }
- mNavigationBar.setCurrentSysuiVisibility(mSystemUiVisibility);
- });
- } catch (RemoteException ex) {
- // no window manager? good luck with that
- }
- mNavigationBarController.createNavigationBars();
+ mNavigationBarController.createNavigationBars(true /* includeDefaultDisplay */);
}
/**
@@ -1124,7 +1100,7 @@
*/
protected View.OnTouchListener getStatusBarWindowTouchListener() {
return (v, event) -> {
- checkUserAutohide(event);
+ checkUserAutoHide(event);
mRemoteInputManager.checkRemoteInputOutside(event);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (mExpandedVisible) {
@@ -2105,7 +2081,7 @@
}
// send updated sysui visibility to window manager
- notifyUiVisibilityChanged(mSystemUiVisibility);
+ notifySystemUiVisibilityChanged(mSystemUiVisibility);
}
mLightBarController.onSystemUiVisibilityChanged(fullscreenStackVis, dockedStackVis,
@@ -2135,52 +2111,55 @@
}
}
- // TODO(115978725): Support auto hide on external nav bars.
void touchAutoHide() {
- // update transient bar autohide
- if (mStatusBarMode == MODE_SEMI_TRANSPARENT || (mNavigationBar != null
- && mNavigationBar.isSemiTransparent())) {
- scheduleAutohide();
+ // update transient bar auto hide
+ if (mStatusBarMode == MODE_SEMI_TRANSPARENT
+ || mNavigationBarController.isSemiTransparent(DEFAULT_DISPLAY)) {
+ scheduleAutoHide();
} else {
- cancelAutohide();
+ cancelAutoHide();
}
}
- protected int computeStatusBarMode(int oldVal, int newVal) {
- return computeBarMode(oldVal, newVal, View.STATUS_BAR_TRANSIENT,
- View.STATUS_BAR_TRANSLUCENT, View.STATUS_BAR_TRANSPARENT);
+ protected @TransitionMode int computeStatusBarMode(int oldVal, int newVal) {
+ return computeBarMode(oldVal, newVal);
}
protected BarTransitions getStatusBarTransitions() {
return mStatusBarView.getBarTransitions();
}
- protected int computeBarMode(int oldVis, int newVis,
- int transientFlag, int translucentFlag, int transparentFlag) {
- final int oldMode = barMode(oldVis, transientFlag, translucentFlag, transparentFlag);
- final int newMode = barMode(newVis, transientFlag, translucentFlag, transparentFlag);
+ protected @TransitionMode int computeBarMode(int oldVis, int newVis) {
+ final int oldMode = barMode(oldVis);
+ final int newMode = barMode(newVis);
if (oldMode == newMode) {
return -1; // no mode change
}
return newMode;
}
- private int barMode(int vis, int transientFlag, int translucentFlag, int transparentFlag) {
- int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | transparentFlag;
- return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT
- : (vis & translucentFlag) != 0 ? MODE_TRANSLUCENT
- : (vis & lightsOutTransparent) == lightsOutTransparent ? MODE_LIGHTS_OUT_TRANSPARENT
- : (vis & transparentFlag) != 0 ? MODE_TRANSPARENT
- : (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0 ? MODE_LIGHTS_OUT
- : MODE_OPAQUE;
+ private @TransitionMode int barMode(int vis) {
+ int lightsOutTransparent = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.STATUS_BAR_TRANSPARENT;
+ if ((vis & View.STATUS_BAR_TRANSIENT) != 0) {
+ return MODE_SEMI_TRANSPARENT;
+ } else if ((vis & View.STATUS_BAR_TRANSLUCENT) != 0) {
+ return MODE_TRANSLUCENT;
+ } else if ((vis & lightsOutTransparent) == lightsOutTransparent) {
+ return MODE_LIGHTS_OUT_TRANSPARENT;
+ } else if ((vis & View.STATUS_BAR_TRANSPARENT) != 0) {
+ return MODE_TRANSPARENT;
+ } else if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
+ return MODE_LIGHTS_OUT;
+ } else {
+ return MODE_OPAQUE;
+ }
}
- // TODO(115978725): Support animations on external nav bars.
void checkBarModes() {
if (mDemoMode) return;
if (mStatusBarView != null) checkBarMode(mStatusBarMode, mStatusBarWindowState,
getStatusBarTransitions());
- if (mNavigationBar != null) mNavigationBar.checkNavBarModes();
+ mNavigationBarController.checkNavBarModes(DEFAULT_DISPLAY);
mNoAnimationOnNextBarModeChange = false;
}
@@ -2189,20 +2168,17 @@
mNotificationPanel.setQsScrimEnabled(scrimEnabled);
}
- void checkBarMode(int mode, int windowState, BarTransitions transitions) {
+ void checkBarMode(@TransitionMode int mode, int windowState, BarTransitions transitions) {
final boolean anim = !mNoAnimationOnNextBarModeChange && mDeviceInteractive
&& windowState != WINDOW_STATE_HIDDEN;
transitions.transitionTo(mode, anim);
}
- // TODO(115978725): Support animations on external nav bars.
private void finishBarAnimations() {
if (mStatusBarView != null) {
mStatusBarView.getBarTransitions().finishAnimations();
}
- if (mNavigationBar != null) {
- mNavigationBar.finishBarAnimations();
- }
+ mNavigationBarController.finishBarAnimations(DEFAULT_DISPLAY);
}
private final Runnable mCheckBarModes = this::checkBarModes;
@@ -2213,13 +2189,13 @@
? (mInteractingWindows | barWindow)
: (mInteractingWindows & ~barWindow);
if (mInteractingWindows != 0) {
- suspendAutohide();
+ suspendAutoHide();
} else {
- resumeSuspendedAutohide();
+ resumeSuspendedAutoHide();
}
// manually dismiss the volume panel when interacting with the nav bar
if (changing && interacting && barWindow == StatusBarManager.WINDOW_NAVIGATION_BAR) {
- touchAutoDim();
+ mNavigationBarController.touchAutoDim(DEFAULT_DISPLAY);
dismissVolumeDialog();
}
checkBarModes();
@@ -2231,57 +2207,42 @@
}
}
- private void resumeSuspendedAutohide() {
- if (mAutohideSuspended) {
- scheduleAutohide();
+ private void resumeSuspendedAutoHide() {
+ if (mAutoHideSuspended) {
+ scheduleAutoHide();
mHandler.postDelayed(mCheckBarModes, 500); // longer than home -> launcher
}
}
- private void suspendAutohide() {
- mHandler.removeCallbacks(mAutohide);
+ private void suspendAutoHide() {
+ mHandler.removeCallbacks(mAutoHide);
mHandler.removeCallbacks(mCheckBarModes);
- mAutohideSuspended = (mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0;
+ mAutoHideSuspended = (mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0;
}
- private void cancelAutohide() {
- mAutohideSuspended = false;
- mHandler.removeCallbacks(mAutohide);
+ private void cancelAutoHide() {
+ mAutoHideSuspended = false;
+ mHandler.removeCallbacks(mAutoHide);
}
- private void scheduleAutohide() {
- cancelAutohide();
- mHandler.postDelayed(mAutohide, AUTOHIDE_TIMEOUT_MS);
+ private void scheduleAutoHide() {
+ cancelAutoHide();
+ mHandler.postDelayed(mAutoHide, AUTOHIDE_TIMEOUT_MS);
}
- public void touchAutoDim() {
- if (mNavigationBar != null) {
- mNavigationBar.getBarTransitions().setAutoDim(false);
- }
- mHandler.removeCallbacks(mAutoDim);
-
- // Do not dim the navigation buttons if the its tint is controlled by the bar's background
- if (NavBarTintController.isEnabled(mContext)) {
- return;
- }
- if (mState != StatusBarState.KEYGUARD && mState != StatusBarState.SHADE_LOCKED) {
- mHandler.postDelayed(mAutoDim, AUTOHIDE_TIMEOUT_MS);
- }
- }
-
- void checkUserAutohide(MotionEvent event) {
+ void checkUserAutoHide(MotionEvent event) {
if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0 // a transient bar is revealed
&& event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar
&& event.getX() == 0 && event.getY() == 0 // a touch outside both bars
&& !mRemoteInputManager.getController()
.isRemoteInputActive()) { // not due to typing in IME
- userAutohide();
+ userAutoHide();
}
}
- private void userAutohide() {
- cancelAutohide();
- mHandler.postDelayed(mAutohide, 350); // longer than app gesture -> flag clear
+ private void userAutoHide() {
+ cancelAutoHide();
+ mHandler.postDelayed(mAutoHide, 350); // longer than app gesture -> flag clear
}
private boolean areLightsOn() {
@@ -2300,11 +2261,10 @@
}
}
- private void notifyUiVisibilityChanged(int vis) {
+ private void notifySystemUiVisibilityChanged(int vis) {
try {
if (mLastDispatchedSystemUiVisibility != vis) {
- // TODO (b/117478341): Resolve one status bar/ navigation bar assumption
- mWindowManagerService.statusBarVisibilityChanged(Display.DEFAULT_DISPLAY, vis);
+ mWindowManagerService.statusBarVisibilityChanged(DEFAULT_DISPLAY, vis);
mLastDispatchedSystemUiVisibility = vis;
}
} catch (RemoteException ex) {
@@ -2929,10 +2889,6 @@
mWindowManager.removeViewImmediate(mStatusBarWindow);
mStatusBarWindow = null;
}
- if (mNavigationBarView != null) {
- mWindowManager.removeViewImmediate(mNavigationBarView);
- mNavigationBarView = null;
- }
mNavigationBarController.destroy();
mContext.unregisterReceiver(mBroadcastReceiver);
mContext.unregisterReceiver(mDemoReceiver);
@@ -3002,15 +2958,12 @@
"transparent".equals(mode) ? MODE_TRANSPARENT :
"warning".equals(mode) ? MODE_WARNING :
-1;
- // TODO(115978725): Support external nav bar transitions
if (barMode != -1) {
boolean animate = true;
if (mStatusBarView != null) {
mStatusBarView.getBarTransitions().transitionTo(barMode, animate);
}
- if (mNavigationBar != null) {
- mNavigationBar.getBarTransitions().transitionTo(barMode, animate);
- }
+ mNavigationBarController.transitionTo(DEFAULT_DISPLAY, barMode, animate);
}
}
if (modeChange || command.equals(COMMAND_OPERATOR)) {
@@ -3236,12 +3189,9 @@
mDraggedDownEntry = null;
}
- // TODO(115978725): Support animations on external nav bars.
// Disable layout transitions in navbar for this transition because the load is just
// too heavy for the CPU and GPU on any device.
- if (mNavigationBar != null) {
- mNavigationBar.disableAnimationsDuringHide(delay);
- }
+ mNavigationBarController.disableAnimationsDuringHide(DEFAULT_DISPLAY, delay);
} else if (!mNotificationPanel.isCollapsing()) {
instantCollapseNotificationPanel();
}
@@ -3471,7 +3421,7 @@
updateReportRejectedTouchVisibility();
updateDozing();
updateTheme();
- touchAutoDim();
+ mNavigationBarController.touchAutoDim(DEFAULT_DISPLAY);
Trace.beginSection("StatusBar#updateKeyguardState");
if (mState == StatusBarState.KEYGUARD) {
mKeyguardIndicationController.setVisible(true);
@@ -3592,11 +3542,7 @@
// TODO: Figure out way to remove these.
public NavigationBarView getNavigationBarView() {
- return (mNavigationBar != null ? (NavigationBarView) mNavigationBar.getView() : null);
- }
-
- public View getNavigationBarWindow() {
- return mNavigationBarView;
+ return mNavigationBarController.getDefaultNavigationBarView();
}
/**
@@ -4178,7 +4124,7 @@
private DeviceProvisionedController mDeviceProvisionedController
= Dependency.get(DeviceProvisionedController.class);
- protected DisplayNavigationBarController mNavigationBarController;
+ protected NavigationBarController mNavigationBarController;
// UI-specific methods
@@ -4506,13 +4452,6 @@
}
// End Extra BaseStatusBarMethods.
- // TODO(115978725): Handle dimming for external nav bars
- private final Runnable mAutoDim = () -> {
- if (mNavigationBar != null) {
- mNavigationBar.getBarTransitions().setAutoDim(true);
- }
- };
-
public NotificationGutsManager getGutsManager() {
return mGutsManager;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java
index 4a11754..54502e4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java
@@ -24,10 +24,10 @@
import android.view.MotionEvent;
import android.view.Surface;
+import com.android.systemui.Dependency;
import com.android.systemui.R;
-import com.android.systemui.SysUiServiceProvider;
+import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.phone.NavigationBarView;
-import com.android.systemui.statusbar.phone.StatusBar;
/**
* The "dead zone" consumes unintentional taps along the top edge of the navigation bar.
@@ -44,7 +44,7 @@
public static final int VERTICAL = 1; // Consume taps along the left edge.
private static final boolean CHATTY = true; // print to logcat when we eat a click
- private final StatusBar mStatusBar;
+ private final NavigationBarController mNavBarController;
private final NavigationBarView mNavigationBarView;
private boolean mShouldFlash;
@@ -58,6 +58,7 @@
private boolean mVertical;
private long mLastPokeTime;
private int mDisplayRotation;
+ private final int mDisplayId;
private final Runnable mDebugFlash = new Runnable() {
@Override
@@ -68,8 +69,8 @@
public DeadZone(NavigationBarView view) {
mNavigationBarView = view;
- mStatusBar = SysUiServiceProvider.getComponent(mNavigationBarView.getContext(),
- StatusBar.class);
+ mNavBarController = Dependency.get(NavigationBarController.class);
+ mDisplayId = view.getContext().getDisplayId();
onConfigurationChanged(HORIZONTAL);
}
@@ -133,7 +134,7 @@
if (DEBUG) {
Slog.v(TAG, this + " ACTION_DOWN: " + event.getX() + "," + event.getY());
}
- if (mStatusBar != null) mStatusBar.touchAutoDim();
+ mNavBarController.touchAutoDim(mDisplayId);
int size = (int) getSize(event.getEventTime());
// In the vertical orientation consume taps along the left edge.
// In horizontal orientation consume taps along the top edge.
diff --git a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
index b84f85b..122b094 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/ScreenDecorationsTest.java
@@ -16,13 +16,13 @@
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY;
-import static com.android.systemui.ScreenDecorations.rectsToRegion;
+import static com.android.systemui.ScreenDecorations.rectsToRegion;
import static com.android.systemui.tuner.TunablePadding.FLAG_END;
import static com.android.systemui.tuner.TunablePadding.FLAG_START;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
@@ -87,7 +87,6 @@
mWindowManager = mock(WindowManager.class);
mView = spy(new StatusBarWindowView(mContext, null));
when(mStatusBar.getStatusBarWindow()).thenReturn(mView);
- when(mStatusBar.getNavigationBarWindow()).thenReturn(mView);
mContext.putComponent(StatusBar.class, mStatusBar);
Display display = mContext.getSystemService(WindowManager.class).getDefaultDisplay();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarTransitionsTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarTransitionsTest.java
index 76f57f0..40d5415 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarTransitionsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarTransitionsTest.java
@@ -67,5 +67,4 @@
assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
}
-
}
\ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index e80694c..18ead90 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -82,6 +82,7 @@
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.KeyguardIndicationController;
+import com.android.systemui.statusbar.NavigationBarController;
import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationMediaManager;
@@ -196,6 +197,7 @@
mDreamManager);
mDependency.injectTestDependency(NotificationInterruptionStateProvider.class,
mNotificationInterruptionStateProvider);
+ mDependency.injectMockDependency(NavigationBarController.class);
mContext.addMockSystemService(TrustManager.class, mock(TrustManager.class));
mContext.addMockSystemService(FingerprintManager.class, mock(FingerprintManager.class));
@@ -245,7 +247,7 @@
mock(StatusBarWindowController.class), mock(NotificationIconAreaController.class),
mDozeScrimController, mock(NotificationShelf.class),
mLockscreenUserManager, mCommandQueue, mNotificationPresenter,
- mock(BubbleController.class));
+ mock(BubbleController.class), mock(NavigationBarController.class));
mStatusBar.mContext = mContext;
mStatusBar.mComponents = mContext.getComponents();
SystemUIFactory.getInstance().getRootComponent()
@@ -695,7 +697,8 @@
NotificationLockscreenUserManager notificationLockscreenUserManager,
CommandQueue commandQueue,
NotificationPresenter notificationPresenter,
- BubbleController bubbleController) {
+ BubbleController bubbleController,
+ NavigationBarController navBarController) {
mStatusBarKeyguardViewManager = man;
mUnlockMethodCache = unlock;
mKeyguardIndicationController = key;
@@ -726,6 +729,7 @@
mPresenter = notificationPresenter;
mGestureWakeLock = mock(PowerManager.WakeLock.class);
mBubbleController = bubbleController;
+ mNavigationBarController = navBarController;
}
private WakefulnessLifecycle createAwakeWakefulnessLifecycle() {