Merge "Revert "Distinguish warm/hot launch by whether the activity has attached process"" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d410132104
@@ -129,6 +129,7 @@ class ActivityMetricsLogger {
|
|||||||
*/
|
*/
|
||||||
private static final int IGNORE_CALLER = -1;
|
private static final int IGNORE_CALLER = -1;
|
||||||
private static final int INVALID_DELAY = -1;
|
private static final int INVALID_DELAY = -1;
|
||||||
|
private static final int INVALID_TRANSITION_TYPE = -1;
|
||||||
|
|
||||||
// Preallocated strings we are sending to tron, so we don't have to allocate a new one every
|
// Preallocated strings we are sending to tron, so we don't have to allocate a new one every
|
||||||
// time we log.
|
// time we log.
|
||||||
@@ -223,19 +224,22 @@ class ActivityMetricsLogger {
|
|||||||
static TransitionInfo create(@NonNull ActivityRecord r,
|
static TransitionInfo create(@NonNull ActivityRecord r,
|
||||||
@NonNull LaunchingState launchingState, boolean processRunning,
|
@NonNull LaunchingState launchingState, boolean processRunning,
|
||||||
boolean processSwitch, int startResult) {
|
boolean processSwitch, int startResult) {
|
||||||
if (startResult != START_SUCCESS && startResult != START_TASK_TO_FRONT) {
|
int transitionType = INVALID_TRANSITION_TYPE;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final int transitionType;
|
|
||||||
if (processRunning) {
|
if (processRunning) {
|
||||||
transitionType = r.attachedToProcess()
|
if (startResult == START_SUCCESS) {
|
||||||
? TYPE_TRANSITION_HOT_LAUNCH
|
transitionType = TYPE_TRANSITION_WARM_LAUNCH;
|
||||||
: TYPE_TRANSITION_WARM_LAUNCH;
|
} else if (startResult == START_TASK_TO_FRONT) {
|
||||||
} else {
|
transitionType = TYPE_TRANSITION_HOT_LAUNCH;
|
||||||
|
}
|
||||||
|
} else if (startResult == START_SUCCESS || startResult == START_TASK_TO_FRONT) {
|
||||||
// Task may still exist when cold launching an activity and the start result will be
|
// Task may still exist when cold launching an activity and the start result will be
|
||||||
// set to START_TASK_TO_FRONT. Treat this as a COLD launch.
|
// set to START_TASK_TO_FRONT. Treat this as a COLD launch.
|
||||||
transitionType = TYPE_TRANSITION_COLD_LAUNCH;
|
transitionType = TYPE_TRANSITION_COLD_LAUNCH;
|
||||||
}
|
}
|
||||||
|
if (transitionType == INVALID_TRANSITION_TYPE) {
|
||||||
|
// That means the startResult is neither START_SUCCESS nor START_TASK_TO_FRONT.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new TransitionInfo(r, launchingState, transitionType, processRunning,
|
return new TransitionInfo(r, launchingState, transitionType, processRunning,
|
||||||
processSwitch);
|
processSwitch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import static org.mockito.ArgumentMatchers.argThat;
|
|||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.timeout;
|
import static org.mockito.Mockito.timeout;
|
||||||
|
|
||||||
import android.app.WaitResult;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
@@ -164,15 +163,10 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnActivityLaunchFinished() {
|
public void testOnActivityLaunchFinished() {
|
||||||
// Assume that the process is started (ActivityBuilder has mocked the returned value of
|
|
||||||
// ATMS#getProcessController) but the activity has not attached process.
|
|
||||||
mTopActivity.app = null;
|
|
||||||
onActivityLaunched(mTopActivity);
|
onActivityLaunched(mTopActivity);
|
||||||
|
|
||||||
notifyTransitionStarting(mTopActivity);
|
notifyTransitionStarting(mTopActivity);
|
||||||
final ActivityMetricsLogger.TransitionInfoSnapshot info = notifyWindowsDrawn(mTopActivity);
|
notifyWindowsDrawn(mTopActivity);
|
||||||
assertWithMessage("Warm launch").that(info.getLaunchState())
|
|
||||||
.isEqualTo(WaitResult.LAUNCH_STATE_WARM);
|
|
||||||
|
|
||||||
verifyOnActivityLaunchFinished(mTopActivity);
|
verifyOnActivityLaunchFinished(mTopActivity);
|
||||||
verifyNoMoreInteractions(mLaunchObserver);
|
verifyNoMoreInteractions(mLaunchObserver);
|
||||||
@@ -207,7 +201,7 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
|
|||||||
notifyActivityLaunching(noDrawnActivity.intent);
|
notifyActivityLaunching(noDrawnActivity.intent);
|
||||||
notifyActivityLaunched(START_SUCCESS, noDrawnActivity);
|
notifyActivityLaunched(START_SUCCESS, noDrawnActivity);
|
||||||
|
|
||||||
noDrawnActivity.mVisibleRequested = false;
|
noDrawnActivity.destroyIfPossible("test");
|
||||||
mActivityMetricsLogger.notifyVisibilityChanged(noDrawnActivity);
|
mActivityMetricsLogger.notifyVisibilityChanged(noDrawnActivity);
|
||||||
|
|
||||||
verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(noDrawnActivity));
|
verifyAsync(mLaunchObserver).onActivityLaunchCancelled(eqProto(noDrawnActivity));
|
||||||
@@ -223,9 +217,6 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
|
|||||||
notifyTransitionStarting(mTopActivity);
|
notifyTransitionStarting(mTopActivity);
|
||||||
// The pending fully drawn event should send when the actual windows drawn event occurs.
|
// The pending fully drawn event should send when the actual windows drawn event occurs.
|
||||||
notifyWindowsDrawn(mTopActivity);
|
notifyWindowsDrawn(mTopActivity);
|
||||||
final ActivityMetricsLogger.TransitionInfoSnapshot info = notifyWindowsDrawn(mTopActivity);
|
|
||||||
assertWithMessage("Hot launch").that(info.getLaunchState())
|
|
||||||
.isEqualTo(WaitResult.LAUNCH_STATE_HOT);
|
|
||||||
|
|
||||||
verifyAsync(mLaunchObserver).onReportFullyDrawn(eqProto(mTopActivity), anyLong());
|
verifyAsync(mLaunchObserver).onReportFullyDrawn(eqProto(mTopActivity), anyLong());
|
||||||
verifyOnActivityLaunchFinished(mTopActivity);
|
verifyOnActivityLaunchFinished(mTopActivity);
|
||||||
@@ -269,8 +260,8 @@ public class ActivityMetricsLaunchObserverTests extends ActivityTestsBase {
|
|||||||
mActivityMetricsLogger.notifyTransitionStarting(reasons);
|
mActivityMetricsLogger.notifyTransitionStarting(reasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActivityMetricsLogger.TransitionInfoSnapshot notifyWindowsDrawn(ActivityRecord r) {
|
private void notifyWindowsDrawn(ActivityRecord r) {
|
||||||
return mActivityMetricsLogger.notifyWindowsDrawn(r, SystemClock.elapsedRealtimeNanos());
|
mActivityMetricsLogger.notifyWindowsDrawn(r, SystemClock.elapsedRealtimeNanos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user