mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Fix a couple trace issues
- Adding trace tokens since we can be starting/ending traces out of order - Fixing issue with draw hitting twice causing the trace stack to be popped twice - Fix issue with endFlagOverrides not removing from the stack Bug: 142803200 Change-Id: I8649b94249910a352f00f2f2c2459c355d2bab00
This commit is contained in:
@@ -46,35 +46,44 @@ public class TraceHelper {
|
||||
*/
|
||||
public static TraceHelper INSTANCE = new TraceHelper();
|
||||
|
||||
public void beginSection(String sectionName) {
|
||||
beginSection(sectionName, 0);
|
||||
/**
|
||||
* @return a token to pass into {@link #endSection(Object)}.
|
||||
*/
|
||||
public Object beginSection(String sectionName) {
|
||||
return beginSection(sectionName, 0);
|
||||
}
|
||||
|
||||
public void beginSection(String sectionName, int flags) {
|
||||
public Object beginSection(String sectionName, int flags) {
|
||||
Trace.beginSection(sectionName);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void endSection() {
|
||||
/**
|
||||
* @param token the token returned from {@link #beginSection(String, int)}
|
||||
*/
|
||||
public void endSection(Object token) {
|
||||
Trace.endSection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link #beginSection} but doesn't add a trace section.
|
||||
*/
|
||||
public void beginFlagsOverride(int flags) { }
|
||||
public Object beginFlagsOverride(int flags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void endFlagsOverride() { }
|
||||
public void endFlagsOverride(Object token) { }
|
||||
|
||||
/**
|
||||
* Temporarily ignore blocking binder calls for the duration of this {@link Supplier}.
|
||||
*/
|
||||
@MainThread
|
||||
public static <T> T whitelistIpcs(String rpcName, Supplier<T> supplier) {
|
||||
INSTANCE.beginSection(rpcName, FLAG_IGNORE_BINDERS);
|
||||
Object traceToken = INSTANCE.beginSection(rpcName, FLAG_IGNORE_BINDERS);
|
||||
try {
|
||||
return supplier.get();
|
||||
} finally {
|
||||
INSTANCE.endSection();
|
||||
INSTANCE.endSection(traceToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user