From 529c8e4cf24375ca21b5d61fb6b34e7010d6edad Mon Sep 17 00:00:00 2001 From: Winson Date: Tue, 17 May 2016 11:08:40 -0700 Subject: [PATCH] Mark occluded home stack as invisible. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The home stack is still visible when a translucent activity (like dialer) is on top, which caused us to use the logic path that just tries to launch the next task. However, that path does not reload the stack state (since the activity stack generally doesn’t change while Recents is visible) so it was always launching the already top activity. The new check ensures that we start the activity anew as if it was coming from an occluding app. Bug: 28767764 Change-Id: Iec0fdc0957e5070cec532c5de5cba3454c906a3b --- core/java/android/app/ActivityManager.java | 4 ++++ .../systemui/recents/misc/SystemServicesProxy.java | 14 +++++++++++--- .../android/server/am/ActivityStackSupervisor.java | 5 ++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 8a92b5477caf0..e3035daf0fd34 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -2370,6 +2370,8 @@ public class ActivityManager { public int displayId; public int userId; public boolean visible; + // Index of the stack in the display's stack list, can be used for comparison of stack order + public int position; @Override public int describeContents() { @@ -2397,6 +2399,7 @@ public class ActivityManager { dest.writeInt(displayId); dest.writeInt(userId); dest.writeInt(visible ? 1 : 0); + dest.writeInt(position); if (topActivity != null) { dest.writeInt(1); topActivity.writeToParcel(dest, 0); @@ -2426,6 +2429,7 @@ public class ActivityManager { displayId = source.readInt(); userId = source.readInt(); visible = source.readInt() > 0; + position = source.readInt(); if (source.readInt() > 0) { topActivity = ComponentName.readFromParcel(source); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index 15bc2796e53e0..64f83a9389289 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -371,11 +371,19 @@ public class SystemServicesProxy { try { ActivityManager.StackInfo stackInfo = mIam.getStackInfo( ActivityManager.StackId.HOME_STACK_ID); + ActivityManager.StackInfo fullscreenStackInfo = mIam.getStackInfo( + ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID); ComponentName topActivity = stackInfo.topActivity; - if (isHomeStackVisible != null) { - isHomeStackVisible.value = stackInfo.visible; + boolean homeStackVisibleNotOccluded = stackInfo.visible; + if (fullscreenStackInfo != null) { + boolean isFullscreenStackOccludingHome = fullscreenStackInfo.visible && + fullscreenStackInfo.position > stackInfo.position; + homeStackVisibleNotOccluded &= !isFullscreenStackOccludingHome; } - return (stackInfo.visible && topActivity != null + if (isHomeStackVisible != null) { + isHomeStackVisible.value = homeStackVisibleNotOccluded; + } + return (homeStackVisibleNotOccluded && topActivity != null && topActivity.getPackageName().equals(RecentsImpl.RECENTS_PACKAGE) && (topActivity.getClassName().equals(RecentsImpl.RECENTS_ACTIVITY) || topActivity.getClassName().equals(RecentsTvImpl.RECENTS_TV_ACTIVITY))); diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 0baca9e3db15d..ded9aa89382ee 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -123,7 +123,6 @@ import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; -import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ALL; @@ -3406,12 +3405,16 @@ public final class ActivityStackSupervisor implements DisplayListener { } private StackInfo getStackInfoLocked(ActivityStack stack) { + final ActivityDisplay display = mActivityDisplays.get(Display.DEFAULT_DISPLAY); StackInfo info = new StackInfo(); mWindowManager.getStackBounds(stack.mStackId, info.bounds); info.displayId = Display.DEFAULT_DISPLAY; info.stackId = stack.mStackId; info.userId = stack.mCurrentUser; info.visible = stack.getStackVisibilityLocked(null) == STACK_VISIBLE; + info.position = display != null + ? display.mStacks.indexOf(stack) + : 0; ArrayList tasks = stack.getAllTasks(); final int numTasks = tasks.size();