summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-05-07 16:24:22 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-05-07 16:24:22 +0000
commit41b811907f0f63fb38a514e12c8263d45eb938db (patch)
treee7631b8a31fbe4db4bb6b6d64c0e0a7f1b9b4d65
parent1eb6476824c6df4c33fe0736eb360cec156bf4f8 (diff)
parent64172bbc055e0c3c825a994054ffd04d2ec143b5 (diff)
Merge "Hide nav bar when keyguard on the 2nd display" into qt-dev
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java41
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NavigationBarController.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java2
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java4
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java3
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java21
6 files changed, 80 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
index ae8bc528ab6a..050655c79ffc 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardDisplayManager.java
@@ -19,6 +19,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
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.LayoutInflater;
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 @@ public class KeyguardDisplayManager {
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 class KeyguardDisplayManager {
public void onDisplayAdded(int displayId) {
final Display display = mDisplayService.getDisplay(displayId);
if (mShowing) {
+ updateNavigationBarVisibility(displayId, false /* navBarVisible */);
showPresentation(display);
}
}
@@ -192,11 +199,15 @@ public class KeyguardDisplayManager {
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 @@ public class KeyguardDisplayManager {
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 @@ public class KeyguardDisplayManager {
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 bd25209d5c0f..7bcbd3683130 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.IWindowManager;
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 @@ public class NavigationBarController implements Callbacks {
}
/** @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 c01367a4d213..776be00f8ea4 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 @@ public class StatusBar extends SystemUI implements DemoMode,
// TODO: Figure out way to remove these.
public NavigationBarView getNavigationBarView() {
- return mNavigationBarController.getDefaultNavigationBarView();
+ return mNavigationBarController.getNavigationBarView(mDisplayId);
}
/**
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index b6295e194aac..b8504db8e810 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -70,6 +70,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
+import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;
@@ -2007,7 +2008,8 @@ public class DisplayPolicy {
pf.set(displayFrames.mOverscan);
} else if ((sysUiFl & SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0
&& (type >= FIRST_APPLICATION_WINDOW && type <= LAST_SUB_WINDOW
- || type == TYPE_VOLUME_OVERLAY)) {
+ || type == TYPE_VOLUME_OVERLAY
+ || type == TYPE_KEYGUARD_DIALOG)) {
// Asking for layout as if the nav bar is hidden, lets the application
// extend into the unrestricted overscan screen area. We only do this for
// application windows and certain system windows to ensure no window that
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 3834d57c3525..dd3c6004dcad 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1078,7 +1078,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
+ mRequestedWidth + ", mRequestedheight="
+ mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
+ "): frame=" + mWindowFrames.mFrame.toShortString()
- + " " + mWindowFrames.getInsetsInfo());
+ + " " + mWindowFrames.getInsetsInfo()
+ + " " + mAttrs.getTitle());
}
// TODO: Look into whether this override is still necessary.
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
index e90f094636f7..4a87aa46db58 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayPolicyLayoutTests.java
@@ -21,6 +21,7 @@ import static android.view.Surface.ROTATION_270;
import static android.view.Surface.ROTATION_90;
import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR;
@@ -32,6 +33,7 @@ import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
+import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
@@ -160,6 +162,25 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
}
@Test
+ public void layoutWindowLw_keyguardDialog_hideNav() {
+ synchronized (mWm.mGlobalLock) {
+ mWindow.mAttrs.type = TYPE_KEYGUARD_DIALOG;
+ mWindow.mAttrs.flags |= FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
+ mWindow.mAttrs.systemUiVisibility = SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
+ addWindow(mWindow);
+
+ mDisplayPolicy.beginLayoutLw(mFrames, 0 /* uiMode */);
+ mDisplayPolicy.layoutWindowLw(mWindow, null /* attached */, mFrames);
+
+ assertInsetByTopBottom(mWindow.getParentFrame(), 0, 0);
+ assertInsetByTopBottom(mWindow.getStableFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getContentFrameLw(), STATUS_BAR_HEIGHT, NAV_BAR_HEIGHT);
+ assertInsetByTopBottom(mWindow.getDecorFrame(), 0, 0);
+ assertInsetByTopBottom(mWindow.getDisplayFrameLw(), 0, 0);
+ }
+ }
+
+ @Test
public void layoutWindowLw_withDisplayCutout() {
synchronized (mWm.mGlobalLock) {
addDisplayCutout();