1#!/usr/bin/env python3 2# Copyright (C) 2023 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16from os import sys, path 17import synth_common 18 19SYSUI_PID = 1000 20 21trace = synth_common.create_trace() 22trace.add_packet() 23 24trace.add_package_list( 25 ts=0, name="com.android.systemui", uid=SYSUI_PID, version_code=1) 26trace.add_process( 27 pid=SYSUI_PID, ppid=0, cmdline="com.android.systemui", uid=SYSUI_PID) 28trace.add_ftrace_packet(cpu=0) 29 30slices_to_standardize = [ 31 "Lock contention on thread list lock (owner tid: 1665)", 32 "Lock contention on thread suspend count lock (owner tid: 0)", 33 "Lock contention on a monitor lock (owner tid: 0)", 34 "monitor contention with owner BG Thread #1 (30) at", 35 "SuspendThreadByThreadId suspended Primes-1 id=19", 36 "LoadApkAssetsFd({ParcelFileDescriptor: java.io.FileDescriptor@340019d})", 37 "relayoutWindow#first=false/resize=false/vis=true/params=true/force=false", 38 "android.os.Handler: kotlinx.coroutines.CancellableContinuationImpl", 39 "Choreographer#doFrame 122932914", 40 "DrawFrames 122921845", 41 "/data/app/.../base.apk", 42 "OpenDexFilesFromOat(/data/app/.../base.apk)", 43 "Open oat file /data/misc/apexdata/com.android.art/dalvik-cache/boot.oat", 44 "android.os.Handler: kotlinx.coroutines.internal.DispatchedContinuation", 45 "GC: Wait For Completion Alloc", 46 'android.view.ViewRootImpl$ViewRootHandler: android.view.View$$Lambda4', 47 'android.os.AsyncTask$InternalHandler: #1', 48 'android.os.Handler: com.android.systemui.broadcast.ActionReceiver$1$1', 49 'com.android.keyguard.KeyguardUpdateMonitor$13: #302', 50 'android.os.Handler: com.android.systemui.qs.TileServiceManager$1', 51] 52 53for name in slices_to_standardize: 54 trace.add_atrace_async_begin( 55 ts=1_000_000, tid=SYSUI_PID, pid=SYSUI_PID, buf=name) 56 trace.add_atrace_async_end( 57 ts=2_000_000, tid=SYSUI_PID, pid=SYSUI_PID, buf=name) 58 59sys.stdout.buffer.write(trace.trace.SerializeToString()) 60