Merge "Add the process state prior to the activity start" into tm-qpr-dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.android.server.wm;
|
package com.android.server.wm;
|
||||||
|
|
||||||
|
import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT;
|
||||||
import static android.app.ActivityManager.START_SUCCESS;
|
import static android.app.ActivityManager.START_SUCCESS;
|
||||||
import static android.app.ActivityManager.START_TASK_TO_FRONT;
|
import static android.app.ActivityManager.START_TASK_TO_FRONT;
|
||||||
import static android.app.ActivityManager.processStateAmToProto;
|
import static android.app.ActivityManager.processStateAmToProto;
|
||||||
@@ -274,6 +275,8 @@ class ActivityMetricsLogger {
|
|||||||
final boolean mProcessRunning;
|
final boolean mProcessRunning;
|
||||||
/** whether the process of the launching activity didn't have any active activity. */
|
/** whether the process of the launching activity didn't have any active activity. */
|
||||||
final boolean mProcessSwitch;
|
final boolean mProcessSwitch;
|
||||||
|
/** The process state of the launching activity prior to the launch */
|
||||||
|
final int mProcessState;
|
||||||
/** Whether the last launched activity has reported drawn. */
|
/** Whether the last launched activity has reported drawn. */
|
||||||
boolean mIsDrawn;
|
boolean mIsDrawn;
|
||||||
/** The latest activity to have been launched. */
|
/** The latest activity to have been launched. */
|
||||||
@@ -309,8 +312,8 @@ class ActivityMetricsLogger {
|
|||||||
@Nullable
|
@Nullable
|
||||||
static TransitionInfo create(@NonNull ActivityRecord r,
|
static TransitionInfo create(@NonNull ActivityRecord r,
|
||||||
@NonNull LaunchingState launchingState, @Nullable ActivityOptions options,
|
@NonNull LaunchingState launchingState, @Nullable ActivityOptions options,
|
||||||
boolean processRunning, boolean processSwitch, boolean newActivityCreated,
|
boolean processRunning, boolean processSwitch, int processState,
|
||||||
int startResult) {
|
boolean newActivityCreated, int startResult) {
|
||||||
if (startResult != START_SUCCESS && startResult != START_TASK_TO_FRONT) {
|
if (startResult != START_SUCCESS && startResult != START_TASK_TO_FRONT) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -325,18 +328,19 @@ class ActivityMetricsLogger {
|
|||||||
transitionType = TYPE_TRANSITION_COLD_LAUNCH;
|
transitionType = TYPE_TRANSITION_COLD_LAUNCH;
|
||||||
}
|
}
|
||||||
return new TransitionInfo(r, launchingState, options, transitionType, processRunning,
|
return new TransitionInfo(r, launchingState, options, transitionType, processRunning,
|
||||||
processSwitch);
|
processSwitch, processState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Use {@link TransitionInfo#create} instead to ensure the transition type is valid. */
|
/** Use {@link TransitionInfo#create} instead to ensure the transition type is valid. */
|
||||||
private TransitionInfo(ActivityRecord r, LaunchingState launchingState,
|
private TransitionInfo(ActivityRecord r, LaunchingState launchingState,
|
||||||
ActivityOptions options, int transitionType, boolean processRunning,
|
ActivityOptions options, int transitionType, boolean processRunning,
|
||||||
boolean processSwitch) {
|
boolean processSwitch, int processState) {
|
||||||
mLaunchingState = launchingState;
|
mLaunchingState = launchingState;
|
||||||
mTransitionStartTimeNs = launchingState.mCurrentTransitionStartTimeNs;
|
mTransitionStartTimeNs = launchingState.mCurrentTransitionStartTimeNs;
|
||||||
mTransitionType = transitionType;
|
mTransitionType = transitionType;
|
||||||
mProcessRunning = processRunning;
|
mProcessRunning = processRunning;
|
||||||
mProcessSwitch = processSwitch;
|
mProcessSwitch = processSwitch;
|
||||||
|
mProcessState = processState;
|
||||||
mTransitionDeviceUptimeMs = launchingState.mCurrentUpTimeMs;
|
mTransitionDeviceUptimeMs = launchingState.mCurrentUpTimeMs;
|
||||||
setLatestLaunchedActivity(r);
|
setLatestLaunchedActivity(r);
|
||||||
// The launching state can be reused by consecutive launch. Its original association
|
// The launching state can be reused by consecutive launch. Its original association
|
||||||
@@ -640,12 +644,16 @@ class ActivityMetricsLogger {
|
|||||||
// interesting.
|
// interesting.
|
||||||
final boolean processSwitch = !processRunning
|
final boolean processSwitch = !processRunning
|
||||||
|| !processRecord.hasStartedActivity(launchedActivity);
|
|| !processRecord.hasStartedActivity(launchedActivity);
|
||||||
|
final int processState = processRunning
|
||||||
|
? processRecord.getCurrentProcState()
|
||||||
|
: PROCESS_STATE_NONEXISTENT;
|
||||||
|
|
||||||
final TransitionInfo info = launchingState.mAssociatedTransitionInfo;
|
final TransitionInfo info = launchingState.mAssociatedTransitionInfo;
|
||||||
if (DEBUG_METRICS) {
|
if (DEBUG_METRICS) {
|
||||||
Slog.i(TAG, "notifyActivityLaunched" + " resultCode=" + resultCode
|
Slog.i(TAG, "notifyActivityLaunched" + " resultCode=" + resultCode
|
||||||
+ " launchedActivity=" + launchedActivity + " processRunning=" + processRunning
|
+ " launchedActivity=" + launchedActivity + " processRunning=" + processRunning
|
||||||
+ " processSwitch=" + processSwitch
|
+ " processSwitch=" + processSwitch
|
||||||
|
+ " processState=" + processState
|
||||||
+ " newActivityCreated=" + newActivityCreated + " info=" + info);
|
+ " newActivityCreated=" + newActivityCreated + " info=" + info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,7 +689,8 @@ class ActivityMetricsLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final TransitionInfo newInfo = TransitionInfo.create(launchedActivity, launchingState,
|
final TransitionInfo newInfo = TransitionInfo.create(launchedActivity, launchingState,
|
||||||
options, processRunning, processSwitch, newActivityCreated, resultCode);
|
options, processRunning, processSwitch, processState, newActivityCreated,
|
||||||
|
resultCode);
|
||||||
if (newInfo == null) {
|
if (newInfo == null) {
|
||||||
abort(launchingState, "unrecognized launch");
|
abort(launchingState, "unrecognized launch");
|
||||||
return;
|
return;
|
||||||
@@ -995,8 +1004,9 @@ class ActivityMetricsLogger {
|
|||||||
final long timestamp = info.mTransitionStartTimeNs;
|
final long timestamp = info.mTransitionStartTimeNs;
|
||||||
final long uptime = info.mTransitionDeviceUptimeMs;
|
final long uptime = info.mTransitionDeviceUptimeMs;
|
||||||
final int transitionDelay = info.mCurrentTransitionDelayMs;
|
final int transitionDelay = info.mCurrentTransitionDelayMs;
|
||||||
|
final int processState = info.mProcessState;
|
||||||
mLoggerHandler.post(() -> logAppTransition(
|
mLoggerHandler.post(() -> logAppTransition(
|
||||||
timestamp, uptime, transitionDelay, infoSnapshot, isHibernating));
|
timestamp, uptime, transitionDelay, infoSnapshot, isHibernating, processState));
|
||||||
}
|
}
|
||||||
mLoggerHandler.post(() -> logAppDisplayed(infoSnapshot));
|
mLoggerHandler.post(() -> logAppDisplayed(infoSnapshot));
|
||||||
if (info.mPendingFullyDrawn != null) {
|
if (info.mPendingFullyDrawn != null) {
|
||||||
@@ -1008,7 +1018,8 @@ class ActivityMetricsLogger {
|
|||||||
|
|
||||||
// This gets called on another thread without holding the activity manager lock.
|
// This gets called on another thread without holding the activity manager lock.
|
||||||
private void logAppTransition(long transitionStartTimeNs, long transitionDeviceUptimeMs,
|
private void logAppTransition(long transitionStartTimeNs, long transitionDeviceUptimeMs,
|
||||||
int currentTransitionDelayMs, TransitionInfoSnapshot info, boolean isHibernating) {
|
int currentTransitionDelayMs, TransitionInfoSnapshot info, boolean isHibernating,
|
||||||
|
int processState) {
|
||||||
final LogMaker builder = new LogMaker(APP_TRANSITION);
|
final LogMaker builder = new LogMaker(APP_TRANSITION);
|
||||||
builder.setPackageName(info.packageName);
|
builder.setPackageName(info.packageName);
|
||||||
builder.setType(info.type);
|
builder.setType(info.type);
|
||||||
@@ -1074,7 +1085,8 @@ class ActivityMetricsLogger {
|
|||||||
isIncremental,
|
isIncremental,
|
||||||
isLoading,
|
isLoading,
|
||||||
info.launchedActivityName.hashCode(),
|
info.launchedActivityName.hashCode(),
|
||||||
TimeUnit.NANOSECONDS.toMillis(transitionStartTimeNs));
|
TimeUnit.NANOSECONDS.toMillis(transitionStartTimeNs),
|
||||||
|
processState);
|
||||||
|
|
||||||
if (DEBUG_METRICS) {
|
if (DEBUG_METRICS) {
|
||||||
Slog.i(TAG, String.format("APP_START_OCCURRED(%s, %s, %s, %s, %s)",
|
Slog.i(TAG, String.format("APP_START_OCCURRED(%s, %s, %s, %s, %s)",
|
||||||
|
|||||||
Reference in New Issue
Block a user