DO NOT MERGE: startop: Downgrade EventSequenceValidator to warning.
Downgrade EventSequenceValidator into warnings for rvc-dev since the C++ side will already handle bad state transitions from ActivityMetricsLogger. Only for rvc-dev because we'll want to properly fix this for S. Bug: 152322073 Test: build Change-Id: Idf7a68436c2d60b123e0e6e58dc098b62aa11e80
This commit is contained in:
@@ -23,6 +23,9 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.android.server.wm.ActivityMetricsLaunchObserver;
|
import com.android.server.wm.ActivityMetricsLaunchObserver;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A validator to check the correctness of event sequence during app startup.
|
* A validator to check the correctness of event sequence during app startup.
|
||||||
*
|
*
|
||||||
@@ -100,7 +103,8 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
@Override
|
@Override
|
||||||
public void onIntentStarted(@NonNull Intent intent, long timestampNs) {
|
public void onIntentStarted(@NonNull Intent intent, long timestampNs) {
|
||||||
if (state == State.UNKNOWN) {
|
if (state == State.UNKNOWN) {
|
||||||
Log.wtf(TAG, "IntentStarted during UNKNOWN." + intent);
|
logWarningWithStackTrace(
|
||||||
|
String.format("IntentStarted during UNKNOWN. " + intent));
|
||||||
incAccIntentStartedEvents();
|
incAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -110,7 +114,7 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
state != State.ACTIVITY_CANCELLED &&
|
state != State.ACTIVITY_CANCELLED &&
|
||||||
state != State.ACTIVITY_FINISHED &&
|
state != State.ACTIVITY_FINISHED &&
|
||||||
state != State.REPORT_FULLY_DRAWN) {
|
state != State.REPORT_FULLY_DRAWN) {
|
||||||
Log.wtf(TAG,
|
logWarningWithStackTrace(
|
||||||
String.format("Cannot transition from %s to %s", state, State.INTENT_STARTED));
|
String.format("Cannot transition from %s to %s", state, State.INTENT_STARTED));
|
||||||
incAccIntentStartedEvents();
|
incAccIntentStartedEvents();
|
||||||
incAccIntentStartedEvents();
|
incAccIntentStartedEvents();
|
||||||
@@ -124,12 +128,12 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
@Override
|
@Override
|
||||||
public void onIntentFailed() {
|
public void onIntentFailed() {
|
||||||
if (state == State.UNKNOWN) {
|
if (state == State.UNKNOWN) {
|
||||||
Log.wtf(TAG, "IntentFailed during UNKNOWN.");
|
logWarningWithStackTrace(String.format("onIntentFailed during UNKNOWN."));
|
||||||
decAccIntentStartedEvents();
|
decAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state != State.INTENT_STARTED) {
|
if (state != State.INTENT_STARTED) {
|
||||||
Log.wtf(TAG,
|
logWarningWithStackTrace(
|
||||||
String.format("Cannot transition from %s to %s", state, State.INTENT_FAILED));
|
String.format("Cannot transition from %s to %s", state, State.INTENT_FAILED));
|
||||||
incAccIntentStartedEvents();
|
incAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
@@ -143,11 +147,12 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
public void onActivityLaunched(@NonNull @ActivityRecordProto byte[] activity,
|
public void onActivityLaunched(@NonNull @ActivityRecordProto byte[] activity,
|
||||||
@Temperature int temperature) {
|
@Temperature int temperature) {
|
||||||
if (state == State.UNKNOWN) {
|
if (state == State.UNKNOWN) {
|
||||||
Log.wtf(TAG, "onActivityLaunched during UNKNOWN.");
|
logWarningWithStackTrace(
|
||||||
|
String.format("onActivityLaunched during UNKNOWN."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state != State.INTENT_STARTED) {
|
if (state != State.INTENT_STARTED) {
|
||||||
Log.wtf(TAG,
|
logWarningWithStackTrace(
|
||||||
String.format("Cannot transition from %s to %s", state, State.ACTIVITY_LAUNCHED));
|
String.format("Cannot transition from %s to %s", state, State.ACTIVITY_LAUNCHED));
|
||||||
incAccIntentStartedEvents();
|
incAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
@@ -160,12 +165,13 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
@Override
|
@Override
|
||||||
public void onActivityLaunchCancelled(@Nullable @ActivityRecordProto byte[] activity) {
|
public void onActivityLaunchCancelled(@Nullable @ActivityRecordProto byte[] activity) {
|
||||||
if (state == State.UNKNOWN) {
|
if (state == State.UNKNOWN) {
|
||||||
Log.wtf(TAG, "onActivityLaunchCancelled during UNKNOWN.");
|
logWarningWithStackTrace(
|
||||||
|
String.format("onActivityLaunchCancelled during UNKNOWN."));
|
||||||
decAccIntentStartedEvents();
|
decAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state != State.ACTIVITY_LAUNCHED) {
|
if (state != State.ACTIVITY_LAUNCHED) {
|
||||||
Log.wtf(TAG,
|
logWarningWithStackTrace(
|
||||||
String.format("Cannot transition from %s to %s", state, State.ACTIVITY_CANCELLED));
|
String.format("Cannot transition from %s to %s", state, State.ACTIVITY_CANCELLED));
|
||||||
incAccIntentStartedEvents();
|
incAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
@@ -179,13 +185,14 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
public void onActivityLaunchFinished(@NonNull @ActivityRecordProto byte[] activity,
|
public void onActivityLaunchFinished(@NonNull @ActivityRecordProto byte[] activity,
|
||||||
long timestampNs) {
|
long timestampNs) {
|
||||||
if (state == State.UNKNOWN) {
|
if (state == State.UNKNOWN) {
|
||||||
Log.wtf(TAG, "onActivityLaunchFinished during UNKNOWN.");
|
logWarningWithStackTrace(
|
||||||
|
String.format("onActivityLaunchFinished during UNKNOWN."));
|
||||||
decAccIntentStartedEvents();
|
decAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != State.ACTIVITY_LAUNCHED) {
|
if (state != State.ACTIVITY_LAUNCHED) {
|
||||||
Log.wtf(TAG,
|
logWarningWithStackTrace(
|
||||||
String.format("Cannot transition from %s to %s", state, State.ACTIVITY_FINISHED));
|
String.format("Cannot transition from %s to %s", state, State.ACTIVITY_FINISHED));
|
||||||
incAccIntentStartedEvents();
|
incAccIntentStartedEvents();
|
||||||
return;
|
return;
|
||||||
@@ -199,7 +206,8 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
public void onReportFullyDrawn(@NonNull @ActivityRecordProto byte[] activity,
|
public void onReportFullyDrawn(@NonNull @ActivityRecordProto byte[] activity,
|
||||||
long timestampNs) {
|
long timestampNs) {
|
||||||
if (state == State.UNKNOWN) {
|
if (state == State.UNKNOWN) {
|
||||||
Log.wtf(TAG, "onReportFullyDrawn during UNKNOWN.");
|
logWarningWithStackTrace(
|
||||||
|
String.format("onReportFullyDrawn during UNKNOWN."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (state == State.INIT) {
|
if (state == State.INIT) {
|
||||||
@@ -207,7 +215,7 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state != State.ACTIVITY_FINISHED) {
|
if (state != State.ACTIVITY_FINISHED) {
|
||||||
Log.wtf(TAG,
|
logWarningWithStackTrace(
|
||||||
String.format("Cannot transition from %s to %s", state, State.REPORT_FULLY_DRAWN));
|
String.format("Cannot transition from %s to %s", state, State.REPORT_FULLY_DRAWN));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -252,4 +260,11 @@ public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
|
|||||||
Log.i(TAG,
|
Log.i(TAG,
|
||||||
String.format("dec AccIntentStartedEvents to %d", accIntentStartedEvents));
|
String.format("dec AccIntentStartedEvents to %d", accIntentStartedEvents));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void logWarningWithStackTrace(String log) {
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
new Throwable("EventSequenceValidator#getStackTrace").printStackTrace(pw);
|
||||||
|
Log.w(TAG, String.format("%s\n%s", log, sw));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user