OSDN Git Service

Allow dismissing ImmersiveModeCling without touch
authorAdrian Roos <roosa@google.com>
Mon, 12 Sep 2016 22:08:35 +0000 (15:08 -0700)
committerAdrian Roos <roosa@google.com>
Tue, 13 Sep 2016 22:55:06 +0000 (15:55 -0700)
The immersive mode confirmation was not dismissable
without touching it because it wasn't focusable.

Change-Id: I89cdb7d4bd44e302859e731034c4395529f5e5fc
Fixes: 30469869

services/core/java/com/android/server/policy/ImmersiveModeConfirmation.java
services/core/java/com/android/server/policy/PhoneWindowManager.java

index c764833..9bf0476 100644 (file)
@@ -25,7 +25,9 @@ import android.content.Intent;
 import android.content.IntentFilter;
 import android.graphics.PixelFormat;
 import android.graphics.drawable.ColorDrawable;
+import android.os.Binder;
 import android.os.Handler;
+import android.os.IBinder;
 import android.os.Message;
 import android.os.RemoteException;
 import android.os.ServiceManager;
@@ -36,7 +38,6 @@ import android.service.vr.IVrManager;
 import android.service.vr.IVrStateCallbacks;
 import android.util.DisplayMetrics;
 import android.util.Slog;
-import android.util.SparseBooleanArray;
 import android.view.Gravity;
 import android.view.MotionEvent;
 import android.view.View;
@@ -66,6 +67,7 @@ public class ImmersiveModeConfirmation {
     private final H mHandler;
     private final long mShowDelayMs;
     private final long mPanicThresholdMs;
+    private final IBinder mWindowToken = new Binder();
 
     private boolean mConfirmed;
     private ClingWindowView mClingWindow;
@@ -190,13 +192,13 @@ public class ImmersiveModeConfirmation {
                 WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL,
                 0
                         | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
-                        | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                         | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED
                 ,
                 PixelFormat.TRANSLUCENT);
         lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
         lp.setTitle("ImmersiveModeConfirmation");
         lp.windowAnimations = com.android.internal.R.style.Animation_ImmersiveModeConfirmation;
+        lp.token = getWindowToken();
         return lp;
     }
 
@@ -208,6 +210,13 @@ public class ImmersiveModeConfirmation {
                 Gravity.CENTER_HORIZONTAL | Gravity.TOP);
     }
 
+    /**
+     * @return the window token that's used by all ImmersiveModeConfirmation windows.
+     */
+    public IBinder getWindowToken() {
+        return mWindowToken;
+    }
+
     private class ClingWindowView extends FrameLayout {
         private static final int BGCOLOR = 0x80000000;
         private static final int OFFSET_DP = 96;
index 363f4a6..140ab8f 100644 (file)
@@ -7418,11 +7418,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     private int updateSystemUiVisibilityLw() {
         // If there is no window focused, there will be nobody to handle the events
         // anyway, so just hang on in whatever state we're in until things settle down.
-        final WindowState win = mFocusedWindow != null ? mFocusedWindow
+        WindowState winCandidate = mFocusedWindow != null ? mFocusedWindow
                 : mTopFullscreenOpaqueWindowState;
-        if (win == null) {
+        if (winCandidate == null) {
             return 0;
         }
+        if (winCandidate.getAttrs().token == mImmersiveModeConfirmation.getWindowToken()) {
+            // The immersive mode confirmation should never affect the system bar visibility,
+            // otherwise it will unhide the navigation bar and hide itself.
+            winCandidate = isStatusBarKeyguard() ? mStatusBar : mTopFullscreenOpaqueWindowState;
+            if (winCandidate == null) {
+                return 0;
+            }
+        }
+        final WindowState win = winCandidate;
         if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && mHideLockScreen == true) {
             // We are updating at a point where the keyguard has gotten
             // focus, but we were last in a state where the top window is