diff options
5 files changed, 33 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java index cab6744e3c81..2752fa9f1eb3 100644 --- a/core/java/android/app/ActivityManagerInternal.java +++ b/core/java/android/app/ActivityManagerInternal.java @@ -69,6 +69,13 @@ public abstract class ActivityManagerInternal { AppProtoEnums.APP_TRANSITION_SNAPSHOT; // 4 /** + * Type for {@link #notifyAppTransitionStarting}: The transition was started because it was a + * recents animation and we only needed to wait on the wallpaper. + */ + public static final int APP_TRANSITION_RECENTS_ANIM = + AppProtoEnums.APP_TRANSITION_RECENTS_ANIM; // 5 + + /** * The bundle key to extract the assist data. */ public static final String ASSIST_KEY_DATA = "data"; diff --git a/core/proto/android/app/enums.proto b/core/proto/android/app/enums.proto index 5eb05be1a1d1..1754e426fe93 100644 --- a/core/proto/android/app/enums.proto +++ b/core/proto/android/app/enums.proto @@ -32,6 +32,9 @@ enum AppTransitionReasonEnum { APP_TRANSITION_TIMEOUT = 3; // The transition was started because of a we drew a task snapshot. APP_TRANSITION_SNAPSHOT = 4; + // The transition was started because it was a recents animation and we only needed to wait on + // the wallpaper. + APP_TRANSITION_RECENTS_ANIM = 5; } // ActivityManager.java PROCESS_STATEs diff --git a/services/core/java/com/android/server/am/ActivityMetricsLogger.java b/services/core/java/com/android/server/am/ActivityMetricsLogger.java index 352b75704d6e..724dd3fd9847 100644 --- a/services/core/java/com/android/server/am/ActivityMetricsLogger.java +++ b/services/core/java/com/android/server/am/ActivityMetricsLogger.java @@ -299,7 +299,7 @@ class ActivityMetricsLogger { final boolean otherWindowModesLaunching = mWindowingModeTransitionInfo.size() > 0 && info == null; - if ((resultCode < 0 || launchedActivity == null || !processSwitch + if ((!isLoggableResultCode(resultCode) || launchedActivity == null || !processSwitch || windowingMode == WINDOWING_MODE_UNDEFINED) && !otherWindowModesLaunching) { // Failed to launch or it was not a process switch, so we don't care about the timing. @@ -322,6 +322,14 @@ class ActivityMetricsLogger { } /** + * @return True if we should start logging an event for an activity start that returned + * {@code resultCode} and that we'll indeed get a windows drawn event. + */ + private boolean isLoggableResultCode(int resultCode) { + return resultCode == START_SUCCESS || resultCode == START_TASK_TO_FRONT; + } + + /** * Notifies the tracker that all windows of the app have been drawn. */ void notifyWindowsDrawn(int windowingMode, long timestamp) { diff --git a/services/core/java/com/android/server/am/RecentsAnimation.java b/services/core/java/com/android/server/am/RecentsAnimation.java index 91215685f35f..da56ffd57bf3 100644 --- a/services/core/java/com/android/server/am/RecentsAnimation.java +++ b/services/core/java/com/android/server/am/RecentsAnimation.java @@ -16,6 +16,7 @@ package com.android.server.am; +import static android.app.ActivityManager.START_TASK_TO_FRONT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION; @@ -95,6 +96,8 @@ class RecentsAnimation implements RecentsAnimationCallbacks { } } + mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunching(); + mService.setRunningRemoteAnimation(mCallingPid, true); mWindowManager.deferSurfaceLayout(); @@ -143,6 +146,9 @@ class RecentsAnimation implements RecentsAnimationCallbacks { // If we updated the launch-behind state, update the visibility of the activities after // we fetch the visible tasks to be controlled by the animation mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, PRESERVE_WINDOWS); + + mStackSupervisor.getActivityMetricsLogger().notifyActivityLaunched(START_TASK_TO_FRONT, + homeActivity); } finally { mWindowManager.continueSurfaceLayout(); Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index 0b0df6ff588d..3e72a713272a 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -16,13 +16,16 @@ package com.android.server.wm; +import static android.app.ActivityManagerInternal.APP_TRANSITION_RECENTS_ANIM; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; +import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.view.RemoteAnimationTarget.MODE_CLOSING; import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION; import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; +import static com.android.server.wm.WindowManagerService.H.NOTIFY_APP_TRANSITION_STARTING; import static com.android.server.wm.proto.RemoteAnimationAdapterWrapperProto.TARGET; import static com.android.server.wm.proto.AnimationAdapterProto.REMOTE; @@ -37,6 +40,7 @@ import android.util.ArraySet; import android.util.Log; import android.util.Slog;import android.util.proto.ProtoOutputStream; import android.util.SparseBooleanArray; +import android.util.SparseIntArray; import android.util.proto.ProtoOutputStream; import android.view.IRecentsAnimationController; import android.view.IRecentsAnimationRunner; @@ -279,6 +283,10 @@ public class RecentsAnimationController { } catch (RemoteException e) { Slog.e(TAG, "Failed to start recents animation", e); } + final SparseIntArray reasons = new SparseIntArray(); + reasons.put(WINDOWING_MODE_FULLSCREEN, APP_TRANSITION_RECENTS_ANIM); + mService.mH.obtainMessage(NOTIFY_APP_TRANSITION_STARTING, + reasons).sendToTarget(); } void cancelAnimation() { |