1#!/usr/bin/python 2# Copyright (C) 2018 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 17 18sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) 19import synth_common 20 21trace = synth_common.create_trace() 22trace.add_packet() 23trace.add_process(1, 0, 'init') 24trace.add_process(2, 1, 'system_server') 25trace.add_process(3, 1, 'com.google.android.calendar') 26 27trace.add_ftrace_packet(cpu=0) 28 29# Start intent for a successful launch of calendar 30trace.add_atrace_begin( 31 ts=102, tid=2, pid=2, buf='MetricsLogger:launchObserverNotifyIntentStarted') 32trace.add_atrace_end(ts=103, tid=2, pid=2) 33 34trace.add_atrace_async_begin( 35 ts=110, tid=2, pid=2, buf='launching: com.google.android.calendar') 36 37trace.add_atrace_begin( 38 ts=120, tid=2, pid=2, buf='Start proc: com.google.android.calendar') 39trace.add_atrace_end(ts=155, tid=2, pid=2) 40 41# Unrelated process binding, ignored 42trace.add_atrace_begin(ts=125, tid=1, pid=1, buf='bindApplication') 43trace.add_atrace_end(ts=195, tid=1, pid=1) 44 45trace.add_atrace_begin(ts=185, tid=3, pid=3, buf='bindApplication') 46trace.add_atrace_end(ts=195, tid=3, pid=3) 47 48trace.add_atrace_async_end( 49 ts=210, tid=2, pid=2, buf='launching: com.google.android.calendar') 50trace.add_atrace_begin( 51 ts=211, 52 tid=2, 53 pid=2, 54 buf='MetricsLogger:launchObserverNotifyActivityLaunchFinished') 55trace.add_atrace_end(ts=212, tid=2, pid=2) 56 57print(trace.trace.SerializeToString()) 58