Integrate pooled lambda with systrace.
Looper traces handler calls by calling Handler.getTraceName(), which when used with PooledLambda
ends up showing just:
"android.os.Handler: com.android.internal.util.function.pooled.PooledLambdaImpl"
That name doesn't help understand what's the real bottleneck, and even worse, could let people
think it's the PooledLambda who's causing it.
Which this change, it will display names like:
com.android.server.appop.AppOpsService$Lambda
com.android.server.wm$Lambda
Fixes: 141172840
Test: manual verification (neither PoolLambda nor Message have unit tests)
Change-Id: I80d2158a50a644b10f3724fb42a4a9c2aee63ae9
diff --git a/core/java/android/os/TraceNameSupplier.java b/core/java/android/os/TraceNameSupplier.java
new file mode 100644
index 0000000..e4b3a4e
--- /dev/null
+++ b/core/java/android/os/TraceNameSupplier.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.os;
+
+import android.annotation.NonNull;
+
+/**
+ * Supplier for custom trace messages.
+ *
+ * @hide
+ */
+public interface TraceNameSupplier {
+
+ /**
+ * Gets the name used for trace messages.
+ */
+ @NonNull String getTraceName();
+}