Merge "Suppress immersive mode confirmation if navbar is empty" into nyc-mr1-dev

This commit is contained in:
Adrian Roos
2016-07-13 17:02:46 +00:00
committed by Android (Google) Code Review
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

@@ -1024,7 +1024,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);
}
@@ -7590,7 +7591,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);
@@ -7649,6 +7650,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
*