profcollect: trace on background thread

trace is a blocking event, needs to be moved off from the main thread.

Test: build
Bug: 206893189
Change-Id: Iead5a8f2471c2c0dbe0903294b7dcaf0b810256d
This commit is contained in:
Yi Kong
2021-11-18 14:22:45 +08:00
parent 5f91507b2b
commit 092c15cfd9

View File

@@ -230,14 +230,16 @@ public final class ProfcollectForwardingService extends SystemService {
"applaunch_trace_freq", 2);
int randomNum = ThreadLocalRandom.current().nextInt(100);
if (randomNum < traceFrequency) {
try {
if (DEBUG) {
Log.d(LOG_TAG, "Tracing on app launch event: " + packageName);
}
mIProfcollect.trace_once("applaunch");
} catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage());
if (DEBUG) {
Log.d(LOG_TAG, "Tracing on app launch event: " + packageName);
}
BackgroundThread.get().getThreadHandler().post(() -> {
try {
mIProfcollect.trace_once("applaunch");
} catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage());
}
});
}
}