From dd7593ac21bf0ba1cd8c946f305a21345d3d5afe Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 5 Jul 2017 18:02:36 -0700 Subject: [PATCH] Ensure transparent assistant works with PiP - When an always-on-top stack is visible, then ensure that a stack is visible if it is behind a translucent assistant stack (similar to b/37294521). Bug: 63055581 Test: android.server.cts.ActivityManagerPinnedStackTests Test: android.server.cts.ActivityManagerAssistantStackTests Test: #testPinnedStackWithAssistant Change-Id: I4ffec7bbcbd11c496604fcd1da381fd10fb6a892 --- .../com/android/server/am/ActivityStack.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 9cde985989874..c5d1cf651cc1f 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -1690,14 +1690,20 @@ class ActivityStack extends ConfigurationContai } final int stackBehindTopId = (stackBehindTopIndex >= 0) ? mStacks.get(stackBehindTopIndex).mStackId : INVALID_STACK_ID; - if ((topStackId == DOCKED_STACK_ID || topStackId == PINNED_STACK_ID) - && (stackIndex == stackBehindTopIndex - || (stackBehindTopId == DOCKED_STACK_ID - && stackIndex == stackBehindTopIndex - 1))) { - // Stacks directly behind the docked or pinned stack are always visible. - // Also this stack is visible if behind docked stack and the docked stack is behind the - // top-most pinned stack - return STACK_VISIBLE; + if (topStackId == DOCKED_STACK_ID || StackId.isAlwaysOnTop(topStackId)) { + if (stackIndex == stackBehindTopIndex) { + // Stacks directly behind the docked or pinned stack are always visible. + return STACK_VISIBLE; + } else if (StackId.isAlwaysOnTop(topStackId) && stackIndex == stackBehindTopIndex - 1) { + // Otherwise, this stack can also be visible if it is directly behind a docked stack + // or translucent assistant stack behind an always-on-top top-most stack + if (stackBehindTopId == DOCKED_STACK_ID) { + return STACK_VISIBLE; + } else if (stackBehindTopId == ASSISTANT_STACK_ID) { + return mStacks.get(stackBehindTopIndex).isStackTranslucent(starting, mStackId) + ? STACK_VISIBLE : STACK_INVISIBLE; + } + } } if (StackId.isBackdropToTranslucentActivity(topStackId)