Skip to content

Commit

Permalink
EventSequenceValidator: Only record the debug log in debugging level.
Browse files Browse the repository at this point in the history
The stack trace log may confuse other developers and mistakenly points
to IORap as the bug cause.

cherry-pick from ef5e1a6dbee8c7b2db4f150ea9463a8523a207ec

Bug: 161145462
Test: Make and check the logcat.
Merged-In: I3cb24cace060cff381ab3c5770ff6c1c948a2d89
Change-Id: I3cb24cace060cff381ab3c5770ff6c1c948a2d89
  • Loading branch information
yan-wang-google committed Jul 21, 2020
1 parent 90c7090 commit 782bdfc
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
*/
public class EventSequenceValidator implements ActivityMetricsLaunchObserver {
static final String TAG = "EventSequenceValidator";

/** $> adb shell 'setprop log.tag.EventSequenceValidator VERBOSE' */
public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private State state = State.INIT;
private long accIntentStartedEvents = 0;

Expand Down Expand Up @@ -255,9 +256,11 @@ private void decAccIntentStartedEvents() {
}

private void logWarningWithStackTrace(String log) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
new Throwable("EventSequenceValidator#getStackTrace").printStackTrace(pw);
Log.d(TAG, String.format("%s\n%s", log, sw));
if (DEBUG) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
new Throwable("EventSequenceValidator#getStackTrace").printStackTrace(pw);
Log.wtf(TAG, String.format("%s\n%s", log, sw));
}
}
}

0 comments on commit 782bdfc

Please sign in to comment.