Suppress immersive mode confirmation if navbar is empty

Bug: 29501674
Change-Id: Icc5b02e378dfca9136a0d04f286926127fdec70d
This commit is contained in:
Adrian Roos
2016-07-12 15:27:24 -07:00
parent a8b4e7320a
commit 7aaa551733
2 changed files with 16 additions and 5 deletions

View File

@@ -134,7 +134,7 @@ public class ImmersiveModeConfirmation {
}
public void immersiveModeChangedLw(String pkg, boolean isImmersiveMode,
boolean userSetupComplete) {
boolean userSetupComplete, boolean navBarEmpty) {
mHandler.removeMessages(H.SHOW);
if (isImmersiveMode) {
final boolean disabled = PolicyControl.disableImmersiveConfirmation(pkg);
@@ -144,6 +144,7 @@ public class ImmersiveModeConfirmation {
&& (DEBUG_SHOW_EVERY_TIME || !mConfirmed)
&& userSetupComplete
&& !mVrModeEnabled
&& !navBarEmpty
&& !UserManager.isDeviceInDemoMode(mContext)) {
mHandler.sendEmptyMessageDelayed(H.SHOW, mShowDelayMs);
}
@@ -152,12 +153,13 @@ public class ImmersiveModeConfirmation {
}
}
public boolean onPowerKeyDown(boolean isScreenOn, long time, boolean inImmersiveMode) {
public boolean onPowerKeyDown(boolean isScreenOn, long time, boolean inImmersiveMode,
boolean navBarEmpty) {
if (!isScreenOn && (time - mPanicTime < mPanicThresholdMs)) {
// turning the screen back on within the panic threshold
return mClingWindow == null;
}
if (isScreenOn && inImmersiveMode) {
if (isScreenOn && inImmersiveMode && !navBarEmpty) {
// turning the screen off, remember if we were in immersive mode
mPanicTime = time;
} else {

View File

@@ -1018,7 +1018,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Detect user pressing the power button in panic when an application has
// taken over the whole screen.
boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive,
SystemClock.elapsedRealtime(), isImmersiveMode(mLastSystemUiFlags));
SystemClock.elapsedRealtime(), isImmersiveMode(mLastSystemUiFlags),
isNavBarEmpty(mLastSystemUiFlags));
if (panic) {
mHandler.post(mHiddenNavPanic);
}
@@ -7560,7 +7561,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (win != null && oldImmersiveMode != newImmersiveMode) {
final String pkg = win.getOwningPackage();
mImmersiveModeConfirmation.immersiveModeChangedLw(pkg, newImmersiveMode,
isUserSetupComplete());
isUserSetupComplete(), isNavBarEmpty(win.getSystemUiVisibility()));
}
vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis);
@@ -7619,6 +7620,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
&& canHideNavigationBar();
}
private static boolean isNavBarEmpty(int systemUiFlags) {
final int disableNavigationBar = (View.STATUS_BAR_DISABLE_HOME
| View.STATUS_BAR_DISABLE_BACK
| View.STATUS_BAR_DISABLE_RECENT);
return (systemUiFlags & disableNavigationBar) == disableNavigationBar;
}
/**
* @return whether the navigation or status bar can be made translucent
*