diff options
author | Vinit Nayak <peanutbutter@google.com> | 2019-08-26 14:18:51 -0700 |
---|---|---|
committer | Vinit Nayak <peanutbutter@google.com> | 2019-08-26 15:10:21 -0700 |
commit | 9b26e63f9051e5059921e265e62e1dbb083b5840 (patch) | |
tree | 3033b09936dca9f16fea5ef7ffbf5bb13df8f4ad /src | |
parent | 2345e6cdc6aad5c5e6bc5caf810873e89405822f (diff) | |
download | android_packages_apps_Trebuchet-9b26e63f9051e5059921e265e62e1dbb083b5840.tar.gz android_packages_apps_Trebuchet-9b26e63f9051e5059921e265e62e1dbb083b5840.tar.bz2 android_packages_apps_Trebuchet-9b26e63f9051e5059921e265e62e1dbb083b5840.zip |
Add unique id to trace logs through recents animations
Generate a 3 digit number and append it to
log statements here as well as in platform.
fixes: 134619041
Test: Inspected log output with adb shell dumpsys activity service TouchInteractionService
Change-Id: I52a76dd2950565b246384d7766fdede9e28f5bb9
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/logging/EventLogArray.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/com/android/launcher3/logging/EventLogArray.java b/src/com/android/launcher3/logging/EventLogArray.java index f20f3659e..3ecfb23c2 100644 --- a/src/com/android/launcher3/logging/EventLogArray.java +++ b/src/com/android/launcher3/logging/EventLogArray.java @@ -16,11 +16,13 @@ package com.android.launcher3.logging; +import android.util.Log; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Locale; +import java.util.Random; /** * A utility class to record and log events. Events are stored in a fixed size array and old logs @@ -37,6 +39,7 @@ public class EventLogArray { private final String name; private final EventEntry[] logs; private int nextIndex; + private int mLogId; public EventLogArray(String name, int size) { this.name = name; @@ -52,10 +55,6 @@ public class EventLogArray { addLog(TYPE_INTEGER, event, extras); } - public void addLog(String event, float extras) { - addLog(TYPE_FLOAT, event, extras); - } - public void addLog(String event, boolean extras) { addLog(extras ? TYPE_BOOL_TRUE : TYPE_BOOL_FALSE, event, 0); } @@ -65,7 +64,7 @@ public class EventLogArray { int last = (nextIndex + logs.length - 1) % logs.length; int secondLast = (nextIndex + logs.length - 2) % logs.length; if (isEntrySame(logs[last], type, event) && isEntrySame(logs[secondLast], type, event)) { - logs[last].update(type, event, extras); + logs[last].update(type, event, extras, mLogId); logs[secondLast].duplicateCount++; return; } @@ -73,7 +72,7 @@ public class EventLogArray { if (logs[nextIndex] == null) { logs[nextIndex] = new EventEntry(); } - logs[nextIndex].update(type, event, extras); + logs[nextIndex].update(type, event, extras, mLogId); nextIndex = (nextIndex + 1) % logs.length; } @@ -113,10 +112,18 @@ public class EventLogArray { if (log.duplicateCount > 0) { msg.append(" & ").append(log.duplicateCount).append(" similar events"); } + msg.append(" traceId: ").append(log.traceId); writer.println(msg); } } + /** Returns a 3 digit random number between 100-999 */ + public int generateAndSetLogId() { + Random r = new Random(); + mLogId = r.nextInt(900) + 100; + return mLogId; + } + private boolean isEntrySame(EventEntry entry, int type, String event) { return entry != null && entry.type == type && entry.event.equals(event); } @@ -129,11 +136,13 @@ public class EventLogArray { private float extras; private long time; private int duplicateCount; + private int traceId; - public void update(int type, String event, float extras) { + public void update(int type, String event, float extras, int traceId) { this.type = type; this.event = event; this.extras = extras; + this.traceId = traceId; time = System.currentTimeMillis(); duplicateCount = 0; } |