diff options
| author | Felipe Leme <felipeal@google.com> | 2019-09-16 17:52:07 -0700 |
|---|---|---|
| committer | Felipe Leme <felipeal@google.com> | 2019-09-26 16:45:43 -0700 |
| commit | 4bc790d2326a097ed0e8db789f9afc0ec552c722 (patch) | |
| tree | f1bb349944cb5758bfd0b37de0d9d487739647cb /core/java/android | |
| parent | a56786981ea9451d533ecb432335370c4b8d5a02 (diff) | |
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
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/os/Handler.java | 4 | ||||
| -rw-r--r-- | core/java/android/os/TraceNameSupplier.java | 31 |
2 files changed, 35 insertions, 0 deletions
diff --git a/core/java/android/os/Handler.java b/core/java/android/os/Handler.java index 9af9edae9a3f..45a9cf5ab869 100644 --- a/core/java/android/os/Handler.java +++ b/core/java/android/os/Handler.java @@ -295,6 +295,10 @@ public class Handler { /** {@hide} */ @NonNull public String getTraceName(@NonNull Message message) { + if (message.callback instanceof TraceNameSupplier) { + return ((TraceNameSupplier) message.callback).getTraceName(); + } + final StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()).append(": "); if (message.callback != null) { diff --git a/core/java/android/os/TraceNameSupplier.java b/core/java/android/os/TraceNameSupplier.java new file mode 100644 index 000000000000..e4b3a4edce38 --- /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(); +} |
