diff options
| author | 2017-11-30 11:05:43 -0800 | |
|---|---|---|
| committer | 2017-12-04 09:50:55 -0800 | |
| commit | c59b4f6f8d8b16108e968ee3d6dd9e800c40d05a (patch) | |
| tree | 2a25b3f0e850b55dc851d4f68a88b30365e6efa1 | |
| parent | 9f3d06b78a4746eddfdde8a94354719087fd4b44 (diff) | |
Don't send userLeaving hint when entering split-screen mode.
If the current activity stack we are resuming is in multi-window mode
and the last resumed activity stack should still be visible, then don't
send userLeaving hint as the activity will still be visible to the user
after onPause is called.
Also, added option to say if recents activity should be shown when
split-screen is activated. starting the recents activity during
CTS testing can cause timing issues since the recents activity might
be started after the activity we are trying to launch adjacent to
split-screen.
Change-Id: Iba1d0749062e7365a207ba1172705b5ab70cb869
Fixes: 69419620
Test: ActivityManagerSplitScreenTests.testNoUserLeaveHintOnMultiWindowModeChanged
8 files changed, 30 insertions, 18 deletions
diff --git a/api/test-current.txt b/api/test-current.txt index b18153885867..6a0fc9c4be08 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -18,7 +18,7 @@ package android.app { method public void removeStacksWithActivityTypes(int[]) throws java.lang.SecurityException; method public void resizeStack(int, android.graphics.Rect) throws java.lang.SecurityException; method public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException; - method public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect) throws java.lang.SecurityException; + method public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect, boolean) throws java.lang.SecurityException; method public static boolean supportsMultiWindow(android.content.Context); method public static boolean supportsSplitScreenMultiWindow(android.content.Context); field public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1; // 0x1 diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 02b7f8c59ea6..924137838ad4 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -1944,15 +1944,17 @@ public class ActivityManager { * @param animate Whether we should play an animation for the moving the task * @param initialBounds If the primary stack gets created, it will use these bounds for the * docked stack. Pass {@code null} to use default bounds. + * @param showRecents If the recents activity should be shown on the other side of the task + * going into split-screen mode. * @hide */ @TestApi @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop, - boolean animate, Rect initialBounds) throws SecurityException { + boolean animate, Rect initialBounds, boolean showRecents) throws SecurityException { try { getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, animate, - initialBounds); + initialBounds, showRecents); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index 2d6308ccfe93..21e4227bc481 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -502,7 +502,7 @@ interface IActivityManager { void reportSizeConfigurations(in IBinder token, in int[] horizontalSizeConfiguration, in int[] verticalSizeConfigurations, in int[] smallestWidthConfigurations); boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop, - boolean animate, in Rect initialBounds); + boolean animate, in Rect initialBounds, boolean showRecents); /** * Dismisses split-screen multi-window mode. * {@param toTop} If true the current primary split-screen stack will be placed or left on top. 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 2d3080b1f7d2..130a5e310fd1 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -267,7 +267,7 @@ public class SystemServicesProxy { try { return mIam.setTaskWindowingModeSplitScreenPrimary(taskId, createMode, true /* onTop */, - false /* animate */, initialBounds); + false /* animate */, initialBounds, true /* showRecents */); } catch (RemoteException e) { e.printStackTrace(); } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index fe992daf7d04..55d8fe842249 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -414,6 +414,7 @@ import com.android.server.SystemServiceManager; import com.android.server.ThreadPriorityBooster; import com.android.server.Watchdog; import com.android.server.am.ActivityStack.ActivityState; +import com.android.server.am.EventLogTags; import com.android.server.am.proto.ActivityManagerServiceProto; import com.android.server.am.proto.BroadcastProto; import com.android.server.am.proto.GrantUriProto; @@ -10501,7 +10502,7 @@ public class ActivityManagerService extends IActivityManager.Stub public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) { if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { setTaskWindowingModeSplitScreenPrimary(taskId, SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, - toTop, ANIMATE, null /* initialBounds */); + toTop, ANIMATE, null /* initialBounds */, true /* showRecents */); return; } enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingMode()"); @@ -10547,10 +10548,12 @@ public class ActivityManagerService extends IActivityManager.Stub * @param animate Whether we should play an animation for the moving the task. * @param initialBounds If the primary stack gets created, it will use these bounds for the * stack. Pass {@code null} to use default bounds. + * @param showRecents If the recents activity should be shown on the other side of the task + * going into split-screen mode. */ @Override public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop, - boolean animate, Rect initialBounds) { + boolean animate, Rect initialBounds, boolean showRecents) { enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingModeSplitScreenPrimary()"); synchronized (this) { @@ -10575,7 +10578,7 @@ public class ActivityManagerService extends IActivityManager.Stub if (toTop) { stack.moveToFront("setTaskWindowingModeSplitScreenPrimary", task); } - stack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, animate); + stack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, animate, showRecents); return windowingMode != task.getWindowingMode(); } finally { Binder.restoreCallingIdentity(ident); diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index bdfd82f440a6..46ef88ce12e2 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -144,6 +144,7 @@ import com.android.internal.app.IVoiceInteractor; import com.android.internal.os.BatteryStatsImpl; import com.android.server.Watchdog; import com.android.server.am.ActivityManagerService.ItemMatcher; +import com.android.server.am.EventLogTags; import com.android.server.wm.ConfigurationContainer; import com.android.server.wm.StackWindowController; import com.android.server.wm.StackWindowListener; @@ -482,10 +483,10 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai @Override public void setWindowingMode(int windowingMode) { - setWindowingMode(windowingMode, false /* animate */); + setWindowingMode(windowingMode, false /* animate */, true /* showRecents */); } - void setWindowingMode(int preferredWindowingMode, boolean animate) { + void setWindowingMode(int preferredWindowingMode, boolean animate, boolean showRecents) { final int currentMode = getWindowingMode(); final ActivityDisplay display = getDisplay(); final TaskRecord topTask = topTask(); @@ -579,7 +580,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai resize(mTmpRect2, null /* tempTaskBounds */, null /* tempTaskInsetBounds */); } } finally { - if (!alreadyInSplitScreenMode && mDisplayId == DEFAULT_DISPLAY + if (showRecents && !alreadyInSplitScreenMode && mDisplayId == DEFAULT_DISPLAY && windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { // Make sure recents stack exist when creating a dock stack as it normally needs to // be on the other side of the docked stack and we make visibility decisions based @@ -1424,9 +1425,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai if (prev.app != null && prev.app.thread != null) { if (DEBUG_PAUSE) Slog.v(TAG_PAUSE, "Enqueueing pending pause: " + prev); try { - EventLog.writeEvent(EventLogTags.AM_PAUSE_ACTIVITY, - prev.userId, System.identityHashCode(prev), - prev.shortComponentName); + EventLogTags.writeAmPauseActivity(prev.userId, System.identityHashCode(prev), + prev.shortComponentName, "userLeaving=" + userLeaving); mService.updateUsageStats(prev, false); mService.mLifecycleManager.scheduleTransaction(prev.app.thread, prev.appToken, @@ -2260,7 +2260,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // Remember how we'll process this pause/resume situation, and ensure // that the state is reset however we wind up proceeding. - final boolean userLeaving = mStackSupervisor.mUserLeaving; + boolean userLeaving = mStackSupervisor.mUserLeaving; mStackSupervisor.mUserLeaving = false; if (!hasRunningActivity) { @@ -2331,6 +2331,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // So, why aren't we using prev here??? See the param comment on the method. prev doesn't // represent the last resumed activity. However, the last focus stack does if it isn't null. final ActivityRecord lastResumed = lastFocusedStack.mResumedActivity; + if (userLeaving && inMultiWindowMode() && lastFocusedStack.shouldBeVisible(next)) { + // The user isn't leaving if this stack is the multi-window mode and the last + // focused stack should still be visible. + if(DEBUG_USER_LEAVING) Slog.i(TAG_USER_LEAVING, "Overriding userLeaving to false" + + " next=" + next + " lastResumed=" + lastResumed); + userLeaving = false; + } lastResumedCanPip = lastResumed != null && lastResumed.checkEnterPictureInPictureState( "resumeTopActivity", userLeaving /* beforeStopping */); } diff --git a/services/core/java/com/android/server/am/EventLogTags.logtags b/services/core/java/com/android/server/am/EventLogTags.logtags index b2d3137bb3bc..a131db5c73b0 100644 --- a/services/core/java/com/android/server/am/EventLogTags.logtags +++ b/services/core/java/com/android/server/am/EventLogTags.logtags @@ -38,7 +38,7 @@ option java_package com.android.server.am # The Activity Manager failed to pause the given activity. 30012 am_failed_to_pause (User|1|5),(Token|1|5),(Wanting to pause|3),(Currently pausing|3) # Attempting to pause the current activity -30013 am_pause_activity (User|1|5),(Token|1|5),(Component Name|3) +30013 am_pause_activity (User|1|5),(Token|1|5),(Component Name|3),(User Leaving|3) # Application process has been started 30014 am_proc_start (User|1|5),(PID|1|5),(UID|1|5),(Process Name|3),(Type|3),(Component|3) # An application process has been marked as bad diff --git a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java index 13ca10c545ca..0d03863a0804 100644 --- a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java +++ b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java @@ -479,7 +479,7 @@ public class RecentTasksTest extends ActivityTestsBase { () -> mService.moveTaskToStack(0, INVALID_STACK_ID, true)); assertSecurityException(expectCallable, () -> mService.setTaskWindowingModeSplitScreenPrimary(0, - SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, true, true, new Rect())); + SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, true, true, new Rect(), true)); assertSecurityException(expectCallable, () -> mService.dismissSplitScreenMode(true)); assertSecurityException(expectCallable, () -> mService.dismissPip(true, 0)); assertSecurityException(expectCallable, @@ -781,4 +781,4 @@ public class RecentTasksTest extends ActivityTestsBase { callingUid, allowed); } } -}
\ No newline at end of file +} |