Hide nav bar when keyguard on the 2nd display
Bug: 130963707
Test: atest SystemUITest
Test: atest DisplayPolicyLayoutTests#layoutWindowLw_keyguardDialog_hideNav
Test: manual - use chromecast with debug patch + force Desktop mode
Press power key to make the lockscreen show and check if
nav bar is gone
Change-Id: I7f8f9c2c6d1157218e5dda1068170799fdccb64b
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
index ae8bc52..050655c 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
@@ -19,6 +19,7 @@
import android.app.Presentation;
import android.content.Context;
+import android.graphics.Color;
import android.graphics.Point;
import android.hardware.display.DisplayManager;
import android.media.MediaRouter;
@@ -32,9 +33,11 @@
import android.view.View;
import android.view.WindowManager;
+import com.android.systemui.Dependency;
+import com.android.systemui.statusbar.NavigationBarController;
+import com.android.systemui.statusbar.phone.NavigationBarView;
import com.android.systemui.util.InjectionInflationController;
-// TODO(multi-display): Support multiple external displays
public class KeyguardDisplayManager {
protected static final String TAG = "KeyguardDisplayManager";
private static boolean DEBUG = KeyguardConstants.DEBUG;
@@ -49,6 +52,9 @@
private final SparseArray<Presentation> mPresentations = new SparseArray<>();
+ private final NavigationBarController mNavBarController =
+ Dependency.get(NavigationBarController.class);
+
private final DisplayManager.DisplayListener mDisplayListener =
new DisplayManager.DisplayListener() {
@@ -56,6 +62,7 @@
public void onDisplayAdded(int displayId) {
final Display display = mDisplayService.getDisplay(displayId);
if (mShowing) {
+ updateNavigationBarVisibility(displayId, false /* navBarVisible */);
showPresentation(display);
}
}
@@ -192,11 +199,15 @@
if (showing) {
final Display[] displays = mDisplayService.getDisplays();
for (Display display : displays) {
+ int displayId = display.getDisplayId();
+ updateNavigationBarVisibility(displayId, false /* navBarVisible */);
changed |= showPresentation(display);
}
} else {
changed = mPresentations.size() > 0;
for (int i = mPresentations.size() - 1; i >= 0; i--) {
+ int displayId = mPresentations.keyAt(i);
+ updateNavigationBarVisibility(displayId, true /* navBarVisible */);
mPresentations.valueAt(i).dismiss();
}
mPresentations.clear();
@@ -204,6 +215,25 @@
return changed;
}
+ // TODO(b/127878649): this logic is from
+ // {@link StatusBarKeyguardViewManager#updateNavigationBarVisibility}. Try to revisit a long
+ // term solution in R.
+ private void updateNavigationBarVisibility(int displayId, boolean navBarVisible) {
+ // Leave this task to {@link StatusBarKeyguardViewManager}
+ if (displayId == DEFAULT_DISPLAY) return;
+
+ NavigationBarView navBarView = mNavBarController.getNavigationBarView(displayId);
+ // We may not have nav bar on a display.
+ if (navBarView == null) return;
+
+ if (navBarVisible) {
+ navBarView.getRootView().setVisibility(View.VISIBLE);
+ } else {
+ navBarView.getRootView().setVisibility(View.GONE);
+ }
+
+ }
+
private final static class KeyguardPresentation extends Presentation {
private static final int VIDEO_SAFE_REGION = 80; // Percentage of display width & height
private static final int MOVE_CLOCK_TIMEOUT = 10000; // 10s
@@ -251,6 +281,15 @@
LayoutInflater inflater = mInjectableInflater.injectable(
LayoutInflater.from(getContext()));
setContentView(inflater.inflate(R.layout.keyguard_presentation, null));
+
+ // Logic to make the lock screen fullscreen
+ getWindow().getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ getWindow().setNavigationBarContrastEnforced(false);
+ getWindow().setNavigationBarColor(Color.TRANSPARENT);
+
mClock = findViewById(R.id.clock);
// Avoid screen burn in
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
index bd25209..7bcbd36 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java
@@ -32,6 +32,8 @@
import android.view.View;
import android.view.WindowManagerGlobal;
+import androidx.annotation.Nullable;
+
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.RegisterStatusBarResult;
import com.android.systemui.Dependency;
@@ -213,8 +215,17 @@
}
/** @return {@link NavigationBarView} on the default display. */
- public NavigationBarView getDefaultNavigationBarView() {
- NavigationBarFragment navBar = mNavigationBars.get(DEFAULT_DISPLAY);
+ public @Nullable NavigationBarView getDefaultNavigationBarView() {
+ return getNavigationBarView(DEFAULT_DISPLAY);
+ }
+
+ /**
+ * @param displayId the ID of display which Navigation bar is on
+ * @return {@link NavigationBarView} on the display with {@code displayId}.
+ * {@code null} if no navigation bar on that display.
+ */
+ public @Nullable NavigationBarView getNavigationBarView(int displayId) {
+ NavigationBarFragment navBar = mNavigationBars.get(displayId);
return (navBar == null) ? null : (NavigationBarView) navBar.getView();
}
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 c01367a..776be00 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -3487,7 +3487,7 @@
// TODO: Figure out way to remove these.
public NavigationBarView getNavigationBarView() {
- return mNavigationBarController.getDefaultNavigationBarView();
+ return mNavigationBarController.getNavigationBarView(mDisplayId);
}
/**