Apply FLAG_SHOW_WHEN_LOCKED within tasks.
If the bottommost fullscreen window of a task has FLAG_SHOW_WHEN_LOCKED
set then show all windows of the task that are above that window.
Fixes bug 13558398.
Change-Id: Ied8ada54efbb079eaf375470b2eae749e5551c24
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index bd203c8..858cf4b 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -124,6 +124,8 @@
* to prepareAddWindow() until removeWindow().
*/
public interface WindowState {
+ public final static int UNKNOWN_TASK_ID = -1;
+
/**
* Return the uid of the app that owns this window.
*/
@@ -272,7 +274,7 @@
* Get the layer at which this window's surface will be Z-ordered.
*/
public int getSurfaceLayer();
-
+
/**
* Return the token for the application (actually activity) that owns
* this window. May return null for system windows.
@@ -282,6 +284,11 @@
public IApplicationToken getAppToken();
/**
+ * Return the taskId of the task that owns this window.
+ */
+ public int getTaskId();
+
+ /**
* Return true if, at any point, the application token associated with
* this window has actually displayed any windows. This is most useful
* with the "starting up" window to determine if any windows were
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 3c23c6e..41705ef 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -106,6 +106,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.HashSet;
import static android.view.WindowManager.LayoutParams.*;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT;
@@ -374,7 +375,7 @@
static final Rect mTmpNavigationFrame = new Rect();
WindowState mTopFullscreenOpaqueWindowState;
- boolean mHideWindowBehindKeyguard;
+ HashSet<Integer> mTasksToBeHidden = new HashSet<Integer>();
boolean mTopIsFullscreen;
boolean mForceStatusBar;
boolean mForceStatusBarFromKeyguard;
@@ -3366,7 +3367,7 @@
@Override
public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) {
mTopFullscreenOpaqueWindowState = null;
- mHideWindowBehindKeyguard = false;
+ mTasksToBeHidden.clear();
mForceStatusBar = false;
mForceStatusBarFromKeyguard = false;
mForcingShowNavBar = false;
@@ -3417,12 +3418,18 @@
final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0;
if (appWindow) {
+ final int taskId = win.getTaskId();
+ if (taskId != WindowState.UNKNOWN_TASK_ID && showWhenLocked) {
+ mTasksToBeHidden.remove(taskId);
+ } else {
+ mTasksToBeHidden.add(taskId);
+ }
if (attrs.x == 0 && attrs.y == 0
&& attrs.width == WindowManager.LayoutParams.MATCH_PARENT
&& attrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win);
mTopFullscreenOpaqueWindowState = win;
- if (!mHideWindowBehindKeyguard) {
+ if (mTasksToBeHidden.isEmpty()) {
if (showWhenLocked) {
if (DEBUG_LAYOUT) Slog.v(TAG,
"Setting mHideLockScreen to true by win " + win);
@@ -3442,8 +3449,6 @@
if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) {
mAllowLockscreenWhenOn = true;
}
- } else if (!showWhenLocked) {
- mHideWindowBehindKeyguard = true;
}
}
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 2c0e99e..3434053 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -709,6 +709,11 @@
return mAppToken != null ? mAppToken.appToken : null;
}
+ @Override
+ public int getTaskId() {
+ return mAppToken != null ? mAppToken.groupId : UNKNOWN_TASK_ID;
+ }
+
boolean setInsetsChanged() {
mOverscanInsetsChanged |= !mLastOverscanInsets.equals(mOverscanInsets);
mContentInsetsChanged |= !mLastContentInsets.equals(mContentInsets);