diff options
author | Louis Chang <louischang@google.com> | 2020-09-22 16:37:47 +0800 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-10-01 03:36:44 +0000 |
commit | a06fbd2397621615eabbe5a11337f82d4dc30af2 (patch) | |
tree | ac9c4813d07aac2f750dbecd3f9acb03b7e965f4 | |
parent | e15e87e92a149da8223c426cc92061258855a033 (diff) | |
download | base-a06fbd2397621615eabbe5a11337f82d4dc30af2.tar.gz |
RESTRICT AUTOMERGE Make task visible if activity launched behind
Activities were unable to be started while dream started and
keyguard locked because the started activities were not on the
top-most focused tasks (it was the dream task on top).
Even the activities were set as launched behind, the visibilities
of the belonging tasks were still invisible and aborted the
launches.
Making the task visible if the top activity is launched behind
and also starting activities on all visible tasks for attached
application.
Bug: 168326273
Test: making phone call on Auto while Dream started on Phone
Test: atest DreamManagerServiceTests
Test: atest ActivityRecordTests
Change-Id: I199435bcfc7593e6c58488cd6de7c2289d5d0e20
(cherry picked from commit 0f26f573f5f79970a99b46c0b55b8c1d4e106ae5)
3 files changed, 35 insertions, 17 deletions
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java index 4700864c03bc..edb1984aea92 100644 --- a/services/core/java/com/android/server/wm/RootWindowContainer.java +++ b/services/core/java/com/android/server/wm/RootWindowContainer.java @@ -48,6 +48,7 @@ import static com.android.server.wm.ActivityStack.ActivityState.PAUSED; import static com.android.server.wm.ActivityStack.ActivityState.RESUMED; import static com.android.server.wm.ActivityStack.ActivityState.STOPPED; import static com.android.server.wm.ActivityStack.ActivityState.STOPPING; +import static com.android.server.wm.ActivityStack.STACK_VISIBILITY_INVISIBLE; import static com.android.server.wm.ActivityStackSupervisor.DEFER_RESUME; import static com.android.server.wm.ActivityStackSupervisor.ON_TOP; import static com.android.server.wm.ActivityStackSupervisor.dumpHistoryList; @@ -1927,24 +1928,29 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } boolean attachApplication(WindowProcessController app) throws RemoteException { - final String processName = app.mName; boolean didSomething = false; for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) { - final DisplayContent display = getChildAt(displayNdx); - final ActivityStack stack = display.getFocusedStack(); - if (stack == null) { - continue; - } - mTmpRemoteException = null; mTmpBoolean = false; // Set to true if an activity was started. - final PooledFunction c = PooledLambda.obtainFunction( - RootWindowContainer::startActivityForAttachedApplicationIfNeeded, this, - PooledLambda.__(ActivityRecord.class), app, stack.topRunningActivity()); - stack.forAllActivities(c); - c.recycle(); - if (mTmpRemoteException != null) { - throw mTmpRemoteException; + + final DisplayContent display = getChildAt(displayNdx); + for (int areaNdx = display.getTaskDisplayAreaCount() - 1; areaNdx >= 0; --areaNdx) { + final TaskDisplayArea taskDisplayArea = display.getTaskDisplayAreaAt(areaNdx); + for (int taskNdx = taskDisplayArea.getStackCount() - 1; taskNdx >= 0; --taskNdx) { + final ActivityStack rootTask = taskDisplayArea.getStackAt(taskNdx); + if (rootTask.getVisibility(null /*starting*/) == STACK_VISIBILITY_INVISIBLE) { + break; + } + final PooledFunction c = PooledLambda.obtainFunction( + RootWindowContainer::startActivityForAttachedApplicationIfNeeded, this, + PooledLambda.__(ActivityRecord.class), app, + rootTask.topRunningActivity()); + rootTask.forAllActivities(c); + c.recycle(); + if (mTmpRemoteException != null) { + throw mTmpRemoteException; + } + } } didSomething |= mTmpBoolean; } @@ -1962,8 +1968,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } try { - if (mStackSupervisor.realStartActivityLocked(r, app, top == r /*andResume*/, - true /*checkConfig*/)) { + if (mStackSupervisor.realStartActivityLocked(r, app, + top == r && r.isFocusable() /*andResume*/, true /*checkConfig*/)) { mTmpBoolean = true; } } catch (RemoteException e) { diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 6785127d5953..32230cdbdca6 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -3649,6 +3649,10 @@ class Task extends WindowContainer<WindowContainer> { return STACK_VISIBILITY_INVISIBLE; } + if (isTopActivityLaunchedBehind()) { + return STACK_VISIBILITY_VISIBLE; + } + boolean gotSplitScreenStack = false; boolean gotOpaqueSplitScreenPrimary = false; boolean gotOpaqueSplitScreenSecondary = false; @@ -3766,6 +3770,14 @@ class Task extends WindowContainer<WindowContainer> { : STACK_VISIBILITY_VISIBLE; } + private boolean isTopActivityLaunchedBehind() { + final ActivityRecord top = topRunningActivity(); + if (top != null && top.mLaunchTaskBehind) { + return true; + } + return false; + } + ActivityRecord isInTask(ActivityRecord r) { if (r == null) { return null; diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 6ab0697206e3..c6d788b10056 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -543,7 +543,7 @@ public class ActivityRecordTests extends ActivityTestsBase { final ActivityStack stack = new StackBuilder(mRootWindowContainer).build(); try { doReturn(false).when(stack).isTranslucent(any()); - assertFalse(mStack.shouldBeVisible(null /* starting */)); + assertTrue(mStack.shouldBeVisible(null /* starting */)); mActivity.setLastReportedConfiguration(new MergedConfiguration(new Configuration(), mActivity.getConfiguration())); |