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 a 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 python.generators.diff_tests.testing import Path, DataPath, Metric, Systrace 17from python.generators.diff_tests.testing import Csv, Json, TextProto, BinaryProto 18from python.generators.diff_tests.testing import DiffTestBlueprint 19from python.generators.diff_tests.testing import TestSuite 20from python.generators.diff_tests.testing import PrintProfileProto 21 22 23class AndroidStdlib(TestSuite): 24 25 def test_android_battery_stats_event_slices(self): 26 # The following has three events 27 # * top (123, mail) from 1000 to 9000 explicit 28 # * job (456, mail_job) starting at 3000 (end is inferred as trace end) 29 # * job (789, video_job) ending at 4000 (start is inferred as trace start) 30 return DiffTestBlueprint( 31 trace=TextProto(r""" 32 packet { 33 ftrace_events { 34 cpu: 1 35 event { 36 timestamp: 1000 37 pid: 1 38 print { 39 buf: "N|1000|battery_stats.top|+top=123:\"mail\"\n" 40 } 41 } 42 event { 43 timestamp: 3000 44 pid: 1 45 print { 46 buf: "N|1000|battery_stats.job|+job=456:\"mail_job\"\n" 47 } 48 } 49 event { 50 timestamp: 4000 51 pid: 1 52 print { 53 buf: "N|1000|battery_stats.job|-job=789:\"video_job\"\n" 54 } 55 } 56 event { 57 timestamp: 9000 58 pid: 1 59 print { 60 buf: "N|1000|battery_stats.top|-top=123:\"mail\"\n" 61 } 62 } 63 } 64 } 65 """), 66 query=""" 67 INCLUDE PERFETTO MODULE android.battery_stats; 68 SELECT * FROM android_battery_stats_event_slices 69 ORDER BY str_value; 70 """, 71 out=Path('android_battery_stats_event_slices.out')) 72 73 def test_android_battery_stats_counters(self): 74 return DiffTestBlueprint( 75 trace=TextProto(r""" 76 packet { 77 ftrace_events { 78 cpu: 1 79 event { 80 timestamp: 1000 81 pid: 1 82 print { 83 buf: "C|1000|battery_stats.data_conn|13\n" 84 } 85 } 86 event { 87 timestamp: 4000 88 pid: 1 89 print { 90 buf: "C|1000|battery_stats.data_conn|20\n" 91 } 92 } 93 event { 94 timestamp: 1000 95 pid: 1 96 print { 97 buf: "C|1000|battery_stats.audio|1\n" 98 } 99 } 100 } 101 } 102 """), 103 query=""" 104 INCLUDE PERFETTO MODULE android.battery_stats; 105 SELECT * FROM android_battery_stats_state 106 ORDER BY ts, track_name; 107 """, 108 out=Csv(""" 109 "ts","dur","safe_dur","track_name","value","value_name" 110 1000,-1,3000,"battery_stats.audio",1,"active" 111 1000,3000,3000,"battery_stats.data_conn",13,"4G (LTE)" 112 4000,-1,0,"battery_stats.data_conn",20,"5G (NR)" 113 """)) 114 115 def test_anrs(self): 116 return DiffTestBlueprint( 117 trace=Path('../../metrics/android/android_anr_metric.py'), 118 query=""" 119 INCLUDE PERFETTO MODULE android.anrs; 120 SELECT * 121 FROM android_anrs; 122 """, 123 out=Csv(""" 124 "process_name","pid","upid","error_id","ts","subject" 125 "com.google.android.app1",11167,"[NULL]","da24554c-452a-4ae1-b74a-fb898f6e0982",1000,"Test ANR subject 1" 126 "com.google.android.app2","[NULL]","[NULL]","8612fece-c2f1-4aeb-9d45-8e6d9d0201cf",2000,"Test ANR subject 2" 127 "com.google.android.app3","[NULL]","[NULL]","c25916a0-a8f0-41f3-87df-319e06471a0f",3000,"[NULL]" 128 """)) 129 130 def test_binder_sync_binder_metrics(self): 131 return DiffTestBlueprint( 132 trace=DataPath('android_binder_metric_trace.atr'), 133 query=""" 134 INCLUDE PERFETTO MODULE android.binder; 135 SELECT 136 aidl_name, 137 binder_txn_id, 138 client_process, 139 client_thread, 140 client_upid, 141 client_utid, 142 client_tid, 143 is_main_thread, 144 client_ts, 145 client_dur, 146 client_oom_score, 147 binder_reply_id, 148 server_process, 149 server_thread, 150 server_upid, 151 server_utid, 152 server_tid, 153 server_ts, 154 server_dur, 155 server_oom_score 156 FROM android_binder_txns 157 WHERE binder_txn_id = 34382 158 ORDER BY client_ts 159 LIMIT 1; 160 """, 161 out=Csv(""" 162 "aidl_name","binder_txn_id","client_process","client_thread","client_upid","client_utid","client_tid","is_main_thread","client_ts","client_dur","client_oom_score","binder_reply_id","server_process","server_thread","server_upid","server_utid","server_tid","server_ts","server_dur","server_oom_score" 163 "AIDL::java::ISensorPrivacyManager::isSensorPrivacyEnabled::server",34382,"/system/bin/audioserver","audioserver",281,281,492,1,25505818197,3125407,-1000,34383,"system_server","binder:641_4",311,539,1596,25505891588,3000749,-900 164 """)) 165 166 def test_binder_sync_binder_thread_state(self): 167 return DiffTestBlueprint( 168 trace=DataPath('android_binder_metric_trace.atr'), 169 query=""" 170 INCLUDE PERFETTO MODULE android.binder; 171 SELECT 172 binder_txn_id, 173 client_ts, 174 client_tid, 175 binder_reply_id, 176 server_ts, 177 server_tid, 178 thread_state_type, 179 thread_state, 180 thread_state_dur, 181 thread_state_count 182 FROM android_sync_binder_thread_state_by_txn 183 WHERE binder_txn_id = 34382 184 ORDER BY thread_state_dur; 185 """, 186 out=Csv(""" 187 "binder_txn_id","client_ts","client_tid","binder_reply_id","server_ts","server_tid","thread_state_type","thread_state","thread_state_dur","thread_state_count" 188 34382,25505818197,492,34383,25505891588,1596,"binder_reply","R+",10030,1 189 34382,25505818197,492,34383,25505891588,1596,"binder_txn","Running",26597,2 190 34382,25505818197,492,34383,25505891588,1596,"binder_txn","R",38947,1 191 34382,25505818197,492,34383,25505891588,1596,"binder_reply","Running",533663,3 192 34382,25505818197,492,34383,25505891588,1596,"binder_reply","D",864664,1 193 34382,25505818197,492,34383,25505891588,1596,"binder_reply","R",1592392,1 194 34382,25505818197,492,34383,25505891588,1596,"binder_txn","S",3059863,1 195 """)) 196 197 def test_binder_sync_binder_blocked_function(self): 198 return DiffTestBlueprint( 199 trace=DataPath('android_binder_metric_trace.atr'), 200 query=""" 201 INCLUDE PERFETTO MODULE android.binder; 202 SELECT 203 binder_txn_id, 204 client_ts, 205 client_tid, 206 binder_reply_id, 207 server_ts, 208 server_tid, 209 thread_state_type, 210 blocked_function, 211 blocked_function_dur, 212 blocked_function_count 213 FROM android_sync_binder_blocked_functions_by_txn 214 WHERE binder_txn_id = 34382 215 ORDER BY blocked_function_dur; 216 """, 217 out=Csv(""" 218 "binder_txn_id","client_ts","client_tid","binder_reply_id","server_ts","server_tid","thread_state_type","blocked_function","blocked_function_dur","blocked_function_count" 219 34382,25505818197,492,34383,25505891588,1596,"binder_reply","filemap_fault",864664,1 220 """)) 221 222 def test_android_slices_standardization_for_aggregation(self): 223 return DiffTestBlueprint( 224 trace=Path('android_slice_standardization.py'), 225 query=""" 226 INCLUDE PERFETTO MODULE android.slices; 227 SELECT ANDROID_STANDARDIZE_SLICE_NAME(slice.name) name 228 FROM slice 229 """, 230 out=Csv(""" 231 "name" 232 "Lock contention on thread list lock <...>" 233 "Lock contention on thread suspend count lock <...>" 234 "Lock contention on a monitor lock <...>" 235 "monitor contention with <...>" 236 "SuspendThreadByThreadId <...>" 237 "LoadApkAssetsFd <...>" 238 "relayoutWindow <...>" 239 "CoroutineContinuation" 240 "Choreographer#doFrame" 241 "DrawFrames" 242 "APK load" 243 "OpenDexFilesFromOat" 244 "Open oat file" 245 "CoroutineContinuation" 246 "Garbage Collector" 247 "Handler: android.view.View" 248 "Handler: android.os.AsyncTask" 249 "Handler: com.android.systemui.broadcast.ActionReceiver" 250 "Handler: com.android.keyguard.KeyguardUpdateMonitor" 251 "Handler: com.android.systemui.qs.TileServiceManager" 252 """)) 253 254 def test_monitor_contention_extraction(self): 255 return DiffTestBlueprint( 256 trace=DataPath('android_monitor_contention_trace.atr'), 257 query=""" 258 INCLUDE PERFETTO MODULE android.monitor_contention; 259 SELECT 260 blocking_method, 261 blocked_method, 262 short_blocking_method, 263 short_blocked_method 264 FROM android_monitor_contention 265 WHERE binder_reply_id IS NOT NULL 266 ORDER BY dur DESC 267 LIMIT 1; 268 """, 269 out=Csv(""" 270 "blocking_method","blocked_method","short_blocking_method","short_blocked_method" 271 "boolean com.android.server.am.ActivityManagerService.forceStopPackageLocked(java.lang.String, int, boolean, boolean, boolean, boolean, boolean, int, java.lang.String)","boolean com.android.server.am.ActivityManagerService.isUidActive(int, java.lang.String)","com.android.server.am.ActivityManagerService.forceStopPackageLocked","com.android.server.am.ActivityManagerService.isUidActive" 272 """)) 273 274 def test_monitor_contention_chain_blocked_functions(self): 275 return DiffTestBlueprint( 276 trace=DataPath('android_monitor_contention_trace.atr'), 277 query=""" 278 INCLUDE PERFETTO MODULE android.monitor_contention; 279 SELECT 280 * 281 FROM android_monitor_contention_chain_blocked_functions_by_txn 282 WHERE id = 13934 283 ORDER BY blocked_function_dur; 284 """, 285 out=Csv(""" 286 "id","blocked_function","blocked_function_dur","blocked_function_count" 287 13934,"blkdev_issue_flush",11950576,1 288 """)) 289 290 def test_monitor_contention_chain_thread_states(self): 291 return DiffTestBlueprint( 292 trace=DataPath('android_monitor_contention_trace.atr'), 293 query=""" 294 INCLUDE PERFETTO MODULE android.monitor_contention; 295 SELECT 296 * 297 FROM android_monitor_contention_chain_thread_state_by_txn 298 WHERE id = 13934 299 ORDER BY thread_state_dur; 300 """, 301 out=Csv(""" 302 "id","thread_state","thread_state_dur","thread_state_count" 303 13934,"R+",7649,1 304 13934,"R",300606,3 305 13934,"Running",649961,3 306 13934,"D",11950576,1 307 """)) 308 309 def test_monitor_contention_chain_extraction(self): 310 return DiffTestBlueprint( 311 trace=DataPath('android_monitor_contention_trace.atr'), 312 query=""" 313 INCLUDE PERFETTO MODULE android.monitor_contention; 314 SELECT * FROM android_monitor_contention_chain 315 WHERE parent_id IS NOT NULL 316 ORDER BY dur DESC 317 LIMIT 1; 318 """, 319 out=Csv(""" 320 "parent_id","blocking_method","blocked_method","short_blocking_method","short_blocked_method","blocking_src","blocked_src","waiter_count","blocked_utid","blocked_thread_name","blocking_utid","blocking_thread_name","blocking_tid","upid","process_name","id","ts","dur","monotonic_dur","track_id","is_blocked_thread_main","blocked_thread_tid","is_blocking_thread_main","blocking_thread_tid","binder_reply_id","binder_reply_ts","binder_reply_tid","pid","child_id" 321 949,"void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()","int com.android.server.am.ActivityManagerService.getMemoryTrimLevel()","com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied","com.android.server.am.ActivityManagerService.getMemoryTrimLevel","ActivityManagerService.java:1478","ActivityManagerService.java:9183",1,250,"system_server",656,"binder:642_12",2720,250,"system_server",956,1737123891932,17577143,17577143,1215,1,642,0,2720,"[NULL]","[NULL]","[NULL]",642,"[NULL]" 322 """)) 323 324 def test_monitor_contention_graph(self): 325 return DiffTestBlueprint( 326 trace=DataPath('android_monitor_contention_trace.atr'), 327 query=""" 328 INCLUDE PERFETTO MODULE android.monitor_contention; 329 330 SELECT HEX(pprof) FROM android_monitor_contention_graph(303) 331 """, 332 out=BinaryProto( 333 message_type="perfetto.third_party.perftools.profiles.Profile", 334 post_processing=PrintProfileProto, 335 contents=""" 336 Sample: 337 Values: 29604 338 Stack: 339 android.bg:android.os.MessageQueue.nativeWake (0x0) 340 fg:android.os.MessageQueue.next (0x0) 341 342 Sample: 343 Values: 66924 344 Stack: 345 android.bg:android.os.MessageQueue.enqueueMessage (0x0) 346 fg:android.os.MessageQueue.next (0x0) 347 348 Sample: 349 Values: 73265 350 Stack: 351 main:android.os.MessageQueue.enqueueMessage (0x0) 352 fg:android.os.MessageQueue.next (0x0) 353 """)) 354 355 def test_thread_creation_spam(self): 356 return DiffTestBlueprint( 357 trace=DataPath('android_monitor_contention_trace.atr'), 358 query=""" 359 INCLUDE PERFETTO MODULE android.thread; 360 SELECT * FROM _android_thread_creation_spam(1e9, 1e9); 361 """, 362 out=Csv(""" 363 "process_name","pid","thread_name_prefix","max_count_per_sec" 364 "com.android.providers.media.module",3487,"SharedPreferenc",3 365 "com.android.providers.media.module",3487,"MediaCodec_loop",2 366 "/apex/com.android.adbd/bin/adbd",527,"shell",1 367 "media.swcodec",563,"id.hevc.decoder",1 368 "system_server",642,"Thread",1 369 "sh",3474,"sh",1 370 "sh",3476,"sh",1 371 "sh",3478,"sh",1 372 "am",3480,"am",1 373 "cmd",3482,"binder",1 374 "cmd",3482,"cmd",1 375 "com.android.providers.media.module",3487,"CodecLooper",1 376 "sh",3517,"sh",1 377 "sgdisk",3521,"sgdisk",1 378 "blkid",3523,"blkid",1 379 "binder:243_4",3524,"binder",1 380 "fsck_msdos",3525,"fsck_msdos",1 381 "binder:243_4",3526,"binder",1 382 "sh",3532,"sh",1 383 "cut",3534,"cut",1 384 "sh",3536,"sh",1 385 "sh",3544,"sh",1 386 "sh",3546,"sh",1 387 "sh",3564,"sh",1 388 """)) 389 390 def test_f2fs_counter_stats(self): 391 return DiffTestBlueprint( 392 trace=DataPath('android_monitor_contention_trace.atr'), 393 query=""" 394 INCLUDE PERFETTO MODULE android.io; 395 SELECT * FROM _android_io_f2fs_counter_stats; 396 """, 397 out=Csv(""" 398 "name","sum","max","min","dur","count","avg" 399 "read_app_total",580966.000000,567184.000000,13782.000000,2515275969,2,290483.000000 400 "read_app_buffered",580966.000000,567184.000000,13782.000000,2515275969,2,290483.000000 401 "write_cp_node",94208.000000,94208.000000,0.000000,2515275969,2,47104.000000 402 "write_app_mapped",65536.000000,65536.000000,0.000000,2515275969,2,32768.000000 403 "write_fs_data",28672.000000,28672.000000,0.000000,2515275969,2,14336.000000 404 "write_cp_meta",28672.000000,28672.000000,0.000000,2515275969,2,14336.000000 405 "write_app_total",20616.000000,20616.000000,0.000000,2515275969,2,10308.000000 406 "write_app_buffered",20616.000000,20616.000000,0.000000,2515275969,2,10308.000000 407 "write_fs_node",8192.000000,8192.000000,0.000000,2515275969,2,4096.000000 408 "write_sync_meta_peak",8.000000,8.000000,0.000000,2515276848,2,4.000000 409 "write_sync_meta_cnt",5.000000,5.000000,0.000000,2515276848,2,2.500000 410 "write_sync_node_peak",4.000000,4.000000,0.000000,2515276848,2,2.000000 411 "write_sync_node_cnt",3.000000,3.000000,0.000000,2515276848,2,1.500000 412 "write_sync_data_cnt",3.000000,3.000000,0.000000,2515276848,2,1.500000 413 "write_sync_node_avg",1.000000,1.000000,0.000000,2515276848,2,0.500000 414 "write_sync_meta_avg",1.000000,1.000000,0.000000,2515276848,2,0.500000 415 "write_sync_data_peak",0.000000,0.000000,0.000000,2515276848,2,0.000000 416 "write_sync_data_avg",0.000000,0.000000,0.000000,2515276848,2,0.000000 417 "write_async_node_peak",0.000000,0.000000,0.000000,2515276848,2,0.000000 418 "write_async_node_cnt",0.000000,0.000000,0.000000,2515276848,2,0.000000 419 "write_async_node_avg",0.000000,0.000000,0.000000,2515276848,2,0.000000 420 "write_async_meta_peak",0.000000,0.000000,0.000000,2515276848,2,0.000000 421 "write_async_meta_cnt",0.000000,0.000000,0.000000,2515276848,2,0.000000 422 "write_async_meta_avg",0.000000,0.000000,0.000000,2515276848,2,0.000000 423 "write_async_data_peak",0.000000,0.000000,0.000000,2515276848,2,0.000000 424 "write_async_data_cnt",0.000000,0.000000,0.000000,2515276848,2,0.000000 425 "write_async_data_avg",0.000000,0.000000,0.000000,2515276848,2,0.000000 426 "read_node_peak",0.000000,0.000000,0.000000,2515276848,2,0.000000 427 "read_node_cnt",0.000000,0.000000,0.000000,2515276848,2,0.000000 428 "read_node_avg",0.000000,0.000000,0.000000,2515276848,2,0.000000 429 "read_meta_peak",0.000000,0.000000,0.000000,2515276848,2,0.000000 430 "read_meta_cnt",0.000000,0.000000,0.000000,2515276848,2,0.000000 431 "read_meta_avg",0.000000,0.000000,0.000000,2515276848,2,0.000000 432 "read_data_peak",0.000000,0.000000,0.000000,2515276848,2,0.000000 433 "read_data_cnt",0.000000,0.000000,0.000000,2515276848,2,0.000000 434 "read_data_avg",0.000000,0.000000,0.000000,2515276848,2,0.000000 435 "write_gc_node",0.000000,0.000000,0.000000,2515275969,2,0.000000 436 "write_gc_data",0.000000,0.000000,0.000000,2515275969,2,0.000000 437 "write_fs_meta",0.000000,0.000000,0.000000,2515275969,2,0.000000 438 "write_cp_data",0.000000,0.000000,0.000000,2515275969,2,0.000000 439 "write_app_direct",0.000000,0.000000,0.000000,2515275969,2,0.000000 440 "read_fs_node",0.000000,0.000000,0.000000,2515275969,2,0.000000 441 "read_fs_meta",0.000000,0.000000,0.000000,2515275969,2,0.000000 442 "read_fs_gdata",0.000000,0.000000,0.000000,2515275969,2,0.000000 443 "read_fs_data",0.000000,0.000000,0.000000,2515275969,2,0.000000 444 "read_fs_cdata",0.000000,0.000000,0.000000,2515275969,2,0.000000 445 "read_app_mapped",0.000000,0.000000,0.000000,2515275969,2,0.000000 446 "read_app_direct",0.000000,0.000000,0.000000,2515275969,2,0.000000 447 "other_fs_discard",0.000000,0.000000,0.000000,2515275969,2,0.000000 448 """)) 449 450 def test_f2fs_write_stats(self): 451 return DiffTestBlueprint( 452 trace=DataPath('android_monitor_contention_trace.atr'), 453 query=""" 454 INCLUDE PERFETTO MODULE android.io; 455 SELECT tid, thread_name, pid, process_name, ino, dev, bytes, write_count FROM _android_io_f2fs_write_stats; 456 """, 457 out=Csv(""" 458 "tid","thread_name","pid","process_name","ino","dev","bytes","write_count" 459 3548,"AsyncTask #1",3487,"com.android.providers.media.module",2636,65077,135168,33 460 3516,"fg",3487,"com.android.providers.media.module",2409,65077,98304,24 461 3548,"AsyncTask #1",3487,"com.android.providers.media.module",2642,65077,78280,57 462 3516,"fg",3487,"com.android.providers.media.module",2424,65077,37112,28 463 3487,"rs.media.module",3487,"com.android.providers.media.module",2366,65077,16480,12 464 3515,"ackgroundThread",3487,"com.android.providers.media.module",2642,65077,8272,7 465 282,"f2fs_ckpt-254:5",282,"f2fs_ckpt-254:5",4,65077,432,6 466 282,"f2fs_ckpt-254:5",282,"f2fs_ckpt-254:5",5,65077,432,6 467 3548,"AsyncTask #1",3487,"com.android.providers.media.module",3145,65077,233,2 468 743,"StorageManagerS",642,"system_server",3144,65077,227,1 469 282,"f2fs_ckpt-254:5",282,"f2fs_ckpt-254:5",6,65077,216,3 470 3487,"rs.media.module",3487,"com.android.providers.media.module",2367,65077,8,8 471 3516,"fg",3487,"com.android.providers.media.module",2425,65077,8,8 472 3548,"AsyncTask #1",3487,"com.android.providers.media.module",2643,65077,8,8 473 """)) 474 475 def test_f2fs_aggregate_write_stats(self): 476 return DiffTestBlueprint( 477 trace=DataPath('android_monitor_contention_trace.atr'), 478 query=""" 479 INCLUDE PERFETTO MODULE android.io; 480 SELECT total_write_count, distinct_processes, total_bytes_written, 481 distinct_device_count, distinct_inode_count, distinct_thread_count 482 FROM _android_io_f2fs_aggregate_write_stats 483 """, 484 out=Csv(""" 485 "total_write_count","distinct_processes","total_bytes_written","distinct_device_count","distinct_inode_count","distinct_thread_count" 486 203,3,375180,1,13,6 487 """)) 488 489 def test_binder_async_txns(self): 490 return DiffTestBlueprint( 491 trace=DataPath('android_binder_metric_trace.atr'), 492 query=""" 493 INCLUDE PERFETTO MODULE android.binder; 494 SELECT 495 aidl_name, 496 client_process, 497 server_process, 498 client_thread, 499 client_tid, 500 server_tid, 501 is_main_thread, 502 client_oom_score, 503 server_oom_score, 504 client_ts, 505 server_ts, 506 aidl_ts, 507 aidl_dur 508 FROM android_binder_txns 509 WHERE aidl_name IS NOT NULL AND is_sync = 0 510 ORDER BY client_ts 511 LIMIT 10; 512 """, 513 out=Csv(""" 514 "aidl_name","client_process","server_process","client_thread","client_tid","server_tid","is_main_thread","client_oom_score","server_oom_score","client_ts","server_ts","aidl_ts","aidl_dur" 515 "AIDL::cpp::IClientCallback::onClients::cppServer","/system/bin/servicemanager","/system/bin/apexd","servicemanager",243,386,1,-1000,-1000,22213481492,22213517474,22213598784,322601 516 "AIDL::cpp::IMediaMetricsService::submitBuffer::cppServer","/system/bin/audioserver","media.metrics","audioserver",492,1262,1,-1000,-1000,25512325446,25512488255,25512708792,9677878 517 "AIDL::cpp::IMediaMetricsService::submitBuffer::cppServer","/system/bin/audioserver","media.metrics","audioserver",492,1262,1,-1000,-1000,25512842465,25522410505,25522418582,58044 518 "AIDL::cpp::IDisplayEventConnection::stealReceiveChannel::cppServer","/vendor/bin/hw/android.hardware.graphics.composer3-service.ranchu","/system/bin/surfaceflinger","binder:446_1",553,522,0,-1000,-1000,25847718645,25847734867,25849056936,10493 519 "AIDL::cpp::ITunnelModeEnabledListener::onTunnelModeEnabledChanged::cppServer","/system/bin/surfaceflinger","system_server","binder:496_2",522,1600,0,-1000,-900,25854181504,25854195485,25854205007,214767 520 "AIDL::cpp::IDisplayEventConnection::requestNextVsync::cppServer","system_server","/system/bin/surfaceflinger","android.anim",662,522,0,-900,-1000,25855697394,25855710732,25855721528,81461 521 "AIDL::cpp::IDisplayEventConnection::requestNextVsync::cppServer","system_server","/system/bin/surfaceflinger","android.anim",662,522,0,-900,-1000,25873210999,25873224961,25873232951,3493 522 "AIDL::cpp::IDisplayEventConnection::requestNextVsync::cppServer","system_server","/system/bin/surfaceflinger","android.anim",662,522,0,-900,-1000,25951278287,25952242397,25952255710,30672 523 "AIDL::cpp::IDisplayEventConnection::requestNextVsync::cppServer","system_server","/system/bin/surfaceflinger","android.anim",662,1575,0,-900,-1000,25965452828,25965590137,25965596757,2631 524 "AIDL::cpp::IDisplayEventConnection::requestNextVsync::cppServer","system_server","/system/bin/surfaceflinger","android.anim",662,1575,0,-900,-1000,26046376252,26046544680,26046553099,53452 525 """)) 526 527 def test_binder_txns(self): 528 return DiffTestBlueprint( 529 trace=DataPath('sched_wakeup_trace.atr'), 530 query=""" 531 INCLUDE PERFETTO MODULE android.binder; 532 SELECT 533 aidl_name, 534 client_process, 535 server_process, 536 client_thread, 537 client_tid, 538 server_tid, 539 is_main_thread, 540 client_oom_score, 541 server_oom_score, 542 client_ts, 543 server_ts, 544 client_dur, 545 server_dur, 546 client_monotonic_dur, 547 server_monotonic_dur, 548 aidl_ts, 549 aidl_dur, 550 is_sync, 551 client_package_version_code, 552 server_package_version_code, 553 is_client_package_debuggable, 554 is_server_package_debuggable 555 FROM android_binder_txns 556 WHERE aidl_name IS NOT NULL AND client_package_version_code IS NOT NULL 557 ORDER BY client_ts 558 LIMIT 10; 559 """, 560 out=Csv(""" 561 "aidl_name","client_process","server_process","client_thread","client_tid","server_tid","is_main_thread","client_oom_score","server_oom_score","client_ts","server_ts","client_dur","server_dur","client_monotonic_dur","server_monotonic_dur","aidl_ts","aidl_dur","is_sync","client_package_version_code","server_package_version_code","is_client_package_debuggable","is_server_package_debuggable" 562 "AIDL::java::INetworkStatsService::getMobileIfaces::server","com.android.phone","system_server","m.android.phone",1469,657,1,-800,-900,1736110278076,1736110435876,765487,462664,765487,462664,1736110692464,135281,1,33,"[NULL]",0,"[NULL]" 563 "AIDL::java::INetworkStatsService::getIfaceStats::server","com.android.phone","system_server","m.android.phone",1469,657,1,-800,-900,1736111274404,1736111340019,481038,361607,481038,361607,1736111417370,249758,1,33,"[NULL]",0,"[NULL]" 564 "AIDL::java::INetworkStatsService::getMobileIfaces::server","com.android.phone","system_server","m.android.phone",1469,657,1,-800,-900,1736111874030,1736111923740,254494,159330,254494,159330,1736111994038,64535,1,33,"[NULL]",0,"[NULL]" 565 "AIDL::java::INetworkStatsService::getIfaceStats::server","com.android.phone","system_server","m.android.phone",1469,657,1,-800,-900,1736112257185,1736112301639,309870,220751,309870,220751,1736112361927,133727,1,33,"[NULL]",0,"[NULL]" 566 "AIDL::java::IPackageManager::isProtectedBroadcast::server","com.android.systemui","system_server","ndroid.systemui",1253,657,1,-800,-900,1737108493015,1737125387579,17949987,163732,17949987,163732,1737125511194,24959,1,33,"[NULL]",0,"[NULL]" 567 "AIDL::java::IActivityManager::checkPermission::server","com.android.phone","system_server","m.android.phone",1469,2721,1,-800,-900,1737110161286,1737110746980,12677155,147315,12677155,147315,1737110799860,75563,1,33,"[NULL]",0,"[NULL]" 568 "AIDL::java::INetworkStatsService::getMobileIfaces::server","com.android.phone","system_server","m.android.phone",1469,2721,1,-800,-900,1737123460104,1737123475761,447621,137704,447621,137704,1737123532124,48775,1,33,"[NULL]",0,"[NULL]" 569 "AIDL::java::INetworkStatsService::getIfaceStats::server","com.android.phone","system_server","m.android.phone",1469,2721,1,-800,-900,1737123982140,1737123994640,191006,164185,191006,164185,1737124033555,109797,1,33,"[NULL]",0,"[NULL]" 570 "AIDL::java::INetworkStatsService::getMobileIfaces::server","com.android.phone","system_server","m.android.phone",1469,2721,1,-800,-900,1737124228451,1737124238356,88522,66721,88522,66721,1737124269922,24911,1,33,"[NULL]",0,"[NULL]" 571 "AIDL::java::INetworkStatsService::getIfaceStats::server","com.android.phone","system_server","m.android.phone",1469,2721,1,-800,-900,1737124369273,1737124378273,957260,95254,957260,95254,1737124406331,54810,1,33,"[NULL]",0,"[NULL]" 572 """)) 573 574 def test_binder_outgoing_graph(self): 575 return DiffTestBlueprint( 576 trace=DataPath('android_binder_metric_trace.atr'), 577 query=""" 578 INCLUDE PERFETTO MODULE android.binder; 579 SELECT HEX(pprof) FROM ANDROID_BINDER_OUTGOING_GRAPH(259) 580 """, 581 out=BinaryProto( 582 message_type="perfetto.third_party.perftools.profiles.Profile", 583 post_processing=PrintProfileProto, 584 contents=""" 585 Sample: 586 Values: 0 587 Stack: 588 /system/bin/surfaceflinger (0x0) 589 binder:446_1 (0x0) 590 591 Sample: 592 Values: 0 593 Stack: 594 stealReceiveChannel (0x0) 595 IDisplayEventConnection (0x0) 596 /system/bin/surfaceflinger (0x0) 597 binder:446_1 (0x0) 598 """)) 599 600 def test_binder_incoming_graph(self): 601 return DiffTestBlueprint( 602 trace=DataPath('android_binder_metric_trace.atr'), 603 query=""" 604 INCLUDE PERFETTO MODULE android.binder; 605 SELECT HEX(pprof) FROM ANDROID_BINDER_INCOMING_GRAPH(296) 606 """, 607 out=BinaryProto( 608 message_type="perfetto.third_party.perftools.profiles.Profile", 609 post_processing=PrintProfileProto, 610 contents=""" 611 Sample: 612 Values: 1764197 613 Stack: 614 fixupAppData (0x0) 615 IInstalld (0x0) 616 system_server (0x0) 617 618 Sample: 619 Values: 202423 620 Stack: 621 rmdex (0x0) 622 IInstalld (0x0) 623 system_server (0x0) 624 625 Sample: 626 Values: 438512 627 Stack: 628 cleanupInvalidPackageDirs (0x0) 629 IInstalld (0x0) 630 system_server (0x0) 631 632 Sample: 633 Values: 4734897 634 Stack: 635 invalidateMounts (0x0) 636 IInstalld (0x0) 637 system_server (0x0) 638 639 Sample: 640 Values: 7448312 641 Stack: 642 prepareAppProfile (0x0) 643 IInstalld (0x0) 644 system_server (0x0) 645 646 Sample: 647 Values: 91238713 648 Stack: 649 createAppDataBatched (0x0) 650 IInstalld (0x0) 651 system_server (0x0) 652 """)) 653 654 def test_binder_graph_invalid_oom(self): 655 return DiffTestBlueprint( 656 trace=DataPath('android_binder_metric_trace.atr'), 657 query=""" 658 INCLUDE PERFETTO MODULE android.binder; 659 SELECT HEX(pprof) FROM ANDROID_BINDER_GRAPH(2000, 2000, 2000, 2000) 660 """, 661 out=BinaryProto( 662 message_type="perfetto.third_party.perftools.profiles.Profile", 663 post_processing=PrintProfileProto, 664 contents=""" 665 """)) 666 667 def test_binder_graph_valid_oom(self): 668 return DiffTestBlueprint( 669 trace=DataPath('android_binder_metric_trace.atr'), 670 query=""" 671 INCLUDE PERFETTO MODULE android.binder; 672 SELECT HEX(pprof) FROM ANDROID_BINDER_GRAPH(-1000, 1000, -1000, 1000) 673 """, 674 out=BinaryProto( 675 message_type="perfetto.third_party.perftools.profiles.Profile", 676 post_processing=PrintProfileProto, 677 contents=""" 678 Sample: 679 Values: 0 680 Stack: 681 /system/bin/apexd (0x0) 682 /system/bin/servicemanager (0x0) 683 684 Sample: 685 Values: 0 686 Stack: 687 /system/bin/bootanimation (0x0) 688 /system/bin/surfaceflinger (0x0) 689 690 Sample: 691 Values: 0 692 Stack: 693 /system/bin/cameraserver (0x0) 694 system_server (0x0) 695 696 Sample: 697 Values: 0 698 Stack: 699 /system/bin/storaged (0x0) 700 /vendor/bin/hw/android.hardware.health-service.cuttlefish (0x0) 701 702 Sample: 703 Values: 0 704 Stack: 705 /system/bin/surfaceflinger (0x0) 706 /system/bin/bootanimation (0x0) 707 708 Sample: 709 Values: 0 710 Stack: 711 /system/bin/surfaceflinger (0x0) 712 /vendor/bin/hw/android.hardware.graphics.composer3-service.ranchu (0x0) 713 714 Sample: 715 Values: 0 716 Stack: 717 media.metrics (0x0) 718 /system/bin/audioserver (0x0) 719 720 Sample: 721 Values: 0 722 Stack: 723 system_server (0x0) 724 /system/bin/servicemanager (0x0) 725 726 Sample: 727 Values: 0 728 Stack: 729 system_server (0x0) 730 /system/bin/surfaceflinger (0x0) 731 732 Sample: 733 Values: 1004933 734 Stack: 735 /vendor/bin/hw/android.hardware.sensors-service.example (0x0) 736 system_server (0x0) 737 738 Sample: 739 Values: 105827054 740 Stack: 741 /system/bin/installd (0x0) 742 system_server (0x0) 743 744 Sample: 745 Values: 11316 746 Stack: 747 system_server (0x0) 748 /apex/com.android.os.statsd/bin/statsd (0x0) 749 750 Sample: 751 Values: 12567639 752 Stack: 753 /system/bin/servicemanager (0x0) 754 system_server (0x0) 755 756 Sample: 757 Values: 137623 758 Stack: 759 /vendor/bin/hw/android.hardware.lights-service.example (0x0) 760 system_server (0x0) 761 762 Sample: 763 Values: 140719 764 Stack: 765 system_server (0x0) 766 /system/bin/storaged (0x0) 767 768 Sample: 769 Values: 150044 770 Stack: 771 /vendor/bin/hw/android.hardware.input.processor-service.example (0x0) 772 system_server (0x0) 773 774 Sample: 775 Values: 1877718 776 Stack: 777 /system/bin/surfaceflinger (0x0) 778 system_server (0x0) 779 780 Sample: 781 Values: 19303 782 Stack: 783 system_server (0x0) 784 /vendor/bin/hw/android.hardware.sensors-service.example (0x0) 785 786 Sample: 787 Values: 210889 788 Stack: 789 /system/bin/servicemanager (0x0) 790 /apex/com.android.os.statsd/bin/statsd (0x0) 791 792 Sample: 793 Values: 21505514 794 Stack: 795 /system/bin/idmap2d (0x0) 796 system_server (0x0) 797 798 Sample: 799 Values: 2221699 800 Stack: 801 /vendor/bin/hw/android.hardware.health-service.cuttlefish (0x0) 802 system_server (0x0) 803 804 Sample: 805 Values: 25394 806 Stack: 807 /system/bin/servicemanager (0x0) 808 /system/bin/surfaceflinger (0x0) 809 810 Sample: 811 Values: 2552696 812 Stack: 813 /system/bin/hwservicemanager (0x0) 814 /system/bin/cameraserver (0x0) 815 816 Sample: 817 Values: 28045 818 Stack: 819 /apex/com.android.os.statsd/bin/statsd (0x0) 820 system_server (0x0) 821 822 Sample: 823 Values: 297647 824 Stack: 825 /system/bin/hwservicemanager (0x0) 826 system_server (0x0) 827 828 Sample: 829 Values: 3483649 830 Stack: 831 system_server (0x0) 832 /system/bin/audioserver (0x0) 833 834 Sample: 835 Values: 3677545 836 Stack: 837 /system/bin/servicemanager (0x0) 838 /system/bin/audioserver (0x0) 839 840 Sample: 841 Values: 3991341 842 Stack: 843 /system/bin/servicemanager (0x0) 844 /system/bin/cameraserver (0x0) 845 846 Sample: 847 Values: 41164 848 Stack: 849 system_server (0x0) 850 /vendor/bin/hw/android.hardware.health-service.cuttlefish (0x0) 851 852 Sample: 853 Values: 4948091 854 Stack: 855 system_server (0x0) 856 /system/bin/cameraserver (0x0) 857 858 Sample: 859 Values: 629626 860 Stack: 861 /apex/com.android.hardware.vibrator/bin/hw/android.hardware.vibrator-service.example (0x0) 862 system_server (0x0) 863 864 Sample: 865 Values: 78428525 866 Stack: 867 /vendor/bin/hw/android.hardware.graphics.composer3-service.ranchu (0x0) 868 /system/bin/surfaceflinger (0x0) 869 870 Sample: 871 Values: 81216 872 Stack: 873 /system/bin/vold (0x0) 874 system_server (0x0) 875 876 Sample: 877 Values: 837989 878 Stack: 879 /system/bin/servicemanager (0x0) 880 /system/bin/storaged (0x0) 881 """)) 882 883 def test_android_dvfs_counters(self): 884 return DiffTestBlueprint( 885 trace=TextProto(r""" 886 packet { 887 ftrace_events { 888 cpu: 0 889 event { 890 timestamp: 200001000000 891 pid: 2 892 clock_set_rate { 893 name : "domain@1" 894 state: 400000 895 } 896 } 897 event { 898 timestamp: 200003000000 899 pid: 2 900 clock_set_rate { 901 name: "domain@1" 902 state: 1024000 903 } 904 } 905 event { 906 timestamp: 200005000000 907 pid: 2 908 clock_set_rate { 909 name: "domain@1" 910 state: 1024000 911 } 912 } 913 } 914 trusted_uid: 9999 915 trusted_packet_sequence_id: 2 916 } 917 """), 918 query=""" 919 INCLUDE PERFETTO MODULE android.dvfs; 920 SELECT * FROM android_dvfs_counters; 921 """, 922 out=Csv(""" 923 "name","ts","value","dur" 924 "domain@1 Frequency",200001000000,400000.000000,2000000 925 "domain@1 Frequency",200003000000,1024000.000000,2000000 926 "domain@1 Frequency",200005000000,1024000.000000,0 927 """)) 928 929 def test_android_dvfs_counter_stats(self): 930 return DiffTestBlueprint( 931 trace=TextProto(r""" 932 packet { 933 ftrace_events { 934 cpu: 0 935 event { 936 timestamp: 200001000000 937 pid: 2 938 clock_set_rate { 939 name : "domain@1" 940 state: 400000 941 } 942 } 943 event { 944 timestamp: 200001000000 945 pid: 2 946 clock_set_rate { 947 name : "bus_throughput" 948 state: 1014000 949 } 950 } 951 event { 952 timestamp: 200003000000 953 pid: 2 954 clock_set_rate { 955 name: "domain@1" 956 state: 1024000 957 } 958 } 959 event { 960 timestamp: 200003000000 961 pid: 2 962 clock_set_rate { 963 name: "bus_throughput" 964 state: 553000 965 } 966 } 967 event { 968 timestamp: 200005000000 969 pid: 2 970 clock_set_rate { 971 name: "domain@1" 972 state: 1024000 973 } 974 } 975 event { 976 timestamp: 200005000000 977 pid: 527 978 clock_set_rate { 979 name: "bus_throughput" 980 state: 553000 981 } 982 } 983 } 984 trusted_uid: 9999 985 trusted_packet_sequence_id: 2 986 } 987 """), 988 query=""" 989 INCLUDE PERFETTO MODULE android.dvfs; 990 SELECT * FROM android_dvfs_counter_stats; 991 """, 992 out=Csv(""" 993 "name","max","min","dur","wgt_avg" 994 "bus_throughput Frequency",1014000.000000,553000.000000,2000000,783500.000000 995 "domain@1 Frequency",1024000.000000,400000.000000,2000000,712000.000000 996 """)) 997 998 def test_android_dvfs_counter_residency(self): 999 return DiffTestBlueprint( 1000 trace=TextProto(r""" 1001 packet { 1002 ftrace_events { 1003 cpu: 0 1004 event { 1005 timestamp: 200001000000 1006 pid: 2 1007 clock_set_rate { 1008 name : "bus_throughput" 1009 state: 1014000 1010 } 1011 } 1012 event { 1013 timestamp: 200003000000 1014 pid: 2 1015 clock_set_rate { 1016 name: "bus_throughput" 1017 state: 553000 1018 } 1019 } 1020 event { 1021 timestamp: 200005000000 1022 pid: 527 1023 clock_set_rate { 1024 name: "bus_throughput" 1025 state: 553000 1026 } 1027 } 1028 } 1029 trusted_uid: 9999 1030 trusted_packet_sequence_id: 2 1031 } 1032 """), 1033 query=""" 1034 INCLUDE PERFETTO MODULE android.dvfs; 1035 SELECT * FROM android_dvfs_counter_residency; 1036 """, 1037 out=Csv(""" 1038 "name","value","dur","pct" 1039 "bus_throughput Frequency",553000.000000,2000000,50.000000 1040 "bus_throughput Frequency",1014000.000000,2000000,50.000000 1041 """)) 1042 1043 def test_app_process_starts(self): 1044 return DiffTestBlueprint( 1045 trace=DataPath('sched_wakeup_trace.atr'), 1046 query=""" 1047 INCLUDE PERFETTO MODULE android.app_process_starts; 1048 SELECT 1049 process_name, 1050 pid, 1051 intent, 1052 reason, 1053 proc_start_ts, 1054 proc_start_dur, 1055 bind_app_ts, 1056 bind_app_dur, 1057 intent_ts, 1058 intent_dur, 1059 total_dur 1060 FROM android_app_process_starts 1061 ORDER BY proc_start_ts 1062 """, 1063 out=Csv(""" 1064 "process_name","pid","intent","reason","proc_start_ts","proc_start_dur","bind_app_ts","bind_app_dur","intent_ts","intent_dur","total_dur" 1065 "com.android.providers.media.module",3487,"com.android.providers.media.fuse.ExternalStorageServiceImpl","service",1737343157905,6527831,1737386174098,156129409,1737542356088,2114114,201312297 1066 "com.android.externalstorage",3549," android.os.storage.action.VOLUME_STATE_CHANGED","broadcast",1739987238947,9277039,1740045665263,20602351,1740066288912,1480586,80530551 1067 """)) 1068 1069 def test_garbage_collection(self): 1070 return DiffTestBlueprint( 1071 trace=DataPath('sched_wakeup_trace.atr'), 1072 query=""" 1073 INCLUDE PERFETTO MODULE android.garbage_collection; 1074 SELECT 1075 tid, 1076 pid, 1077 thread_name, 1078 process_name, 1079 gc_type, 1080 is_mark_compact, 1081 reclaimed_mb, 1082 min_heap_mb, 1083 max_heap_mb 1084 gc_ts, 1085 gc_dur, 1086 gc_running_dur, 1087 gc_runnable_dur, 1088 gc_unint_io_dur, 1089 gc_unint_non_io_dur, 1090 gc_int_dur 1091 FROM android_garbage_collection_events 1092 ORDER BY tid, gc_ts 1093 """, 1094 out=Csv(""" 1095 "tid","pid","thread_name","process_name","gc_type","is_mark_compact","reclaimed_mb","min_heap_mb","gc_ts","gc_dur","gc_running_dur","gc_runnable_dur","gc_unint_io_dur","gc_unint_non_io_dur","gc_int_dur" 1096 2013,2003,"HeapTaskDaemon","android.process.media","collector_transition",0,0.670000,2.153000,2.823000,326468170,80326441,11087787,0,0,10056086 1097 3494,3487,"HeapTaskDaemon","com.android.providers.media.module","young",0,"[NULL]","[NULL]","[NULL]",213263593,55205035,10429437,0,0,1208604 1098 3494,3487,"HeapTaskDaemon","com.android.providers.media.module","collector_transition",0,1.248000,2.201000,3.449000,169735717,65828710,20965673,0,0,0 1099 3556,3549,"HeapTaskDaemon","com.android.externalstorage","collector_transition",0,0.450000,2.038000,2.488000,166379142,52906367,7881722,0,0,0 1100 """)) 1101 1102 def test_input_events(self): 1103 return DiffTestBlueprint( 1104 trace=DataPath('post_boot_trace.atr'), 1105 query=""" 1106 INCLUDE PERFETTO MODULE android.input; 1107 SELECT 1108 total_latency_dur, 1109 handling_latency_dur, 1110 dispatch_latency_dur, 1111 tid, 1112 thread_name, 1113 pid, 1114 process_name, 1115 event_type, 1116 event_seq, 1117 event_channel, 1118 dispatch_ts, 1119 dispatch_dur, 1120 receive_ts, 1121 receive_dur 1122 FROM android_input_events 1123 ORDER BY dispatch_ts 1124 LIMIT 10 1125 """, 1126 out=Csv(""" 1127 "total_latency_dur","handling_latency_dur","dispatch_latency_dur","tid","thread_name","pid","process_name","event_type","event_seq","event_channel","dispatch_ts","dispatch_dur","receive_ts","receive_dur" 1128 377149054,77503,377032734,7493,"ndroid.systemui",7493,"com.android.systemui","0x3","0x1","4325794 NotificationShade (server)",578307771330,1292,578684804064,1412 1129 1684318,772908,48433,7493,"ndroid.systemui",7493,"com.android.systemui","0x1","0x2","a0526ca NavigationBar0 (server)",581956322279,1299,581956370712,1806 1130 22069988,12614508,804831,7493,"ndroid.systemui",7493,"com.android.systemui","0x1","0x3","4325794 NotificationShade (server)",581956391308,1212,581957196139,1362 1131 1603522,645723,75328,7964,"droid.launcher3",7964,"com.android.launcher3","0x1","0x4","[Gesture Monitor] swipe-up (server)",581956445376,1232,581956520704,1708 1132 1583707,644313,208973,7310,"android.ui",7288,"system_server","0x1","0x5","PointerEventDispatcher0 (server)",581956495788,1208,581956704761,1281 1133 22622740,22582066,25729,7493,"ndroid.systemui",7493,"com.android.systemui","0x1","0x6","4325794 NotificationShade (server)",582019627670,1230,582019653399,1607 1134 20228399,20116160,95263,7964,"droid.launcher3",7964,"com.android.launcher3","0x1","0x7","[Gesture Monitor] swipe-up (server)",582019685639,1309,582019780902,1942 1135 459763,287436,27342,7310,"android.ui",7288,"system_server","0x1","0x8","PointerEventDispatcher0 (server)",582019737156,1192,582019764498,1664 1136 9848456,9806401,22714,7493,"ndroid.systemui",7493,"com.android.systemui","0x1","0x9","4325794 NotificationShade (server)",582051061377,1227,582051084091,1596 1137 5533919,5487703,25013,7964,"droid.launcher3",7964,"com.android.launcher3","0x1","0xa","[Gesture Monitor] swipe-up (server)",582051112236,1258,582051137249,1771 1138 """)) 1139 1140 def test_job_scheduler_events(self): 1141 return DiffTestBlueprint( 1142 trace=DataPath('post_boot_trace.atr'), 1143 query=""" 1144 INCLUDE PERFETTO MODULE android.job_scheduler; 1145 SELECT job_id, uid, package_name, job_service_name, ts, dur FROM android_job_scheduler_events ORDER BY ts 1146 """, 1147 out=Csv(""" 1148 "job_id","uid","package_name","job_service_name","ts","dur" 1149 237039804,1000,"android","com.android.server.notification.NotificationHistoryJobService$system",575488743679,10909825 1150 201,10060,"com.android.dialer","com.android.voicemail.impl.StatusCheckJobService",579210443477,15650722 1151 -300,10089,"com.android.providers.media.module","com.android.providers.media.MediaService",579448376938,1716731633 1152 7,10085,"com.android.devicelockcontroller","androidx.work.impl.background.systemjob.SystemJobService",579645356805,148784109 1153 2,10058,"com.android.imsserviceentitlement",".fcm.FcmRegistrationService",580025518616,47458225 1154 1000,10071,"com.android.messaging",".datamodel.action.ActionServiceImpl",581680366145,327541238 1155 1001,10071,"com.android.messaging",".datamodel.action.BackgroundWorkerService",581948976360,90502706 1156 1000,10071,"com.android.messaging",".datamodel.action.ActionServiceImpl",582038224048,65747884 1157 7,10088,"com.android.rkpdapp","androidx.work.impl.background.systemjob.SystemJobService",582582119592,103911382 1158 7,10037,"com.android.statementservice","androidx.work.impl.background.systemjob.SystemJobService",583151483122,115767494 1159 27950934,10022,"com.android.providers.calendar",".CalendarProviderJobService",587237955847,37434516 1160 """)) 1161 1162 def test_freezer_events(self): 1163 return DiffTestBlueprint( 1164 trace=DataPath('freezer_trace.atr'), 1165 query=""" 1166 INCLUDE PERFETTO MODULE android.freezer; 1167 SELECT pid, ts, dur, unfreeze_reason_int, unfreeze_reason_str FROM android_freezer_events ORDER BY ts 1168 """, 1169 out=Csv(""" 1170 "pid","ts","dur","unfreeze_reason_int","unfreeze_reason_str" 1171 6506,91266310231819,94699935803,"[NULL]","[NULL]" 1172 3804,91266322277324,94687890298,"[NULL]","[NULL]" 1173 3299,91281767065245,78699885147,6,"start_service" 1174 5782,91296291190245,64718977377,"[NULL]","[NULL]" 1175 6533,91296292403211,64717764411,"[NULL]","[NULL]" 1176 4044,91296293188372,64716979250,"[NULL]","[NULL]" 1177 4002,91296294215356,64715952266,"[NULL]","[NULL]" 1178 3981,91296294804650,64715362972,"[NULL]","[NULL]" 1179 """)) 1180 1181 def test_service_bindings(self): 1182 return DiffTestBlueprint( 1183 trace=DataPath('post_boot_trace.atr'), 1184 query=""" 1185 INCLUDE PERFETTO MODULE android.services; 1186 SELECT 1187 client_oom_score, 1188 client_process, 1189 client_thread, 1190 client_pid, 1191 client_tid, 1192 client_ts, 1193 client_dur, 1194 server_oom_score, 1195 server_process, 1196 server_thread, 1197 server_tid, 1198 server_pid, 1199 server_ts, 1200 server_dur, 1201 token, 1202 act, 1203 cmp, 1204 flg, 1205 bind_seq 1206 FROM android_service_bindings 1207 ORDER BY client_tid, client_ts 1208 LIMIT 10 1209 """, 1210 out=Csv(""" 1211 "client_oom_score","client_process","client_thread","client_pid","client_tid","client_ts","client_dur","server_oom_score","server_process","server_thread","server_tid","server_pid","server_ts","server_dur","token","act","cmp","flg","bind_seq" 1212 -900,"system_server","system_server",7288,7288,577830735575,0,0,"android.ext.services","binder:7732_3",7764,7732,577866081720,9755069,"android.os.BinderProxy@a0dc800","android.service.notification.NotificationAssistantService","android.ext.services/.notification.Assistant","[NULL]",21 1213 -900,"system_server","eduling.default",7288,7366,579204777498,0,0,"com.android.dialer","binder:8075_2",8097,8075,579207718770,13090141,"android.os.BinderProxy@9a28fdf","[NULL]","com.android.dialer/com.android.voicemail.impl.StatusCheckJobService","0x4",29 1214 -900,"system_server","eduling.default",7288,7366,580022869386,0,0,"com.android.imsserviceentitlement","binder:8647_1",8667,8647,580027477378,1982139,"android.os.BinderProxy@27f8e83","[NULL]","com.android.imsserviceentitlement/.fcm.FcmRegistrationService","0x4",35 1215 -900,"system_server","StorageManagerS",7288,7397,587754918358,0,-700,"com.android.providers.media.module","binder:8294_1",8327,8294,587757305854,2691423,"android.os.BinderProxy@73b68b5","[NULL]","com.android.providers.media.module/com.android.providers.media.fuse.ExternalStorageServiceImpl","[NULL]",44 1216 -800,"com.android.systemui","ndroid.systemui",7493,7493,572995972978,8071106,-800,"com.android.systemui","binder:7493_4",7682,7493,573131280194,17181314,"android.os.BinderProxy@1c2ac60","android.service.wallpaper.WallpaperService","com.android.systemui/.wallpapers.ImageWallpaper","[NULL]",14 1217 -800,"com.android.systemui","ndroid.systemui",7493,7493,572995972978,8071106,-800,"com.android.systemui","binder:7493_4",7682,7493,577000518511,6977972,"android.os.BinderProxy@b18137","[NULL]","com.android.systemui/.keyguard.KeyguardService","0x100",15 1218 -800,"com.android.networkstack.process","rkstack.process",7610,7610,571078334504,7552850,-800,"com.android.networkstack.process","binder:7610_1",7633,7610,571090652307,74610898,"android.os.BinderProxy@ee1090b","android.net.INetworkStackConnector","com.android.networkstack/com.android.server.NetworkStackService","[NULL]",2 1219 -800,"com.android.networkstack.process","rkstack.process",7610,7610,571078334504,7552850,-800,"com.android.networkstack.process","binder:7610_1",7633,7610,571489537275,1570460,"android.os.BinderProxy@a0dc800","android.net.ITetheringConnector","com.android.networkstack.tethering/.TetheringService","[NULL]",3 1220 0,"com.android.bluetooth","droid.bluetooth",7639,7639,571248973750,9874358,-700,"com.android.bluetooth","binder:7639_2",7672,7639,571871169647,6460322,"android.os.BinderProxy@7482132","android.bluetooth.IBluetooth","com.android.bluetooth/.btservice.AdapterService","[NULL]",4 1221 -700,"com.android.bluetooth","droid.bluetooth",7639,7639,572342110044,4874276,-700,"com.android.bluetooth","binder:7639_2",7672,7639,572466393291,1404185,"android.os.BinderProxy@ce5a6fc","android.media.browse.MediaBrowserService","com.android.bluetooth/.avrcpcontroller.BluetoothMediaBrowserService","[NULL]",10 1222 """)) 1223 1224 def test_oom_adjuster_transitions(self): 1225 return DiffTestBlueprint( 1226 trace=DataPath('sched_wakeup_trace.atr'), 1227 query=""" 1228 INCLUDE PERFETTO MODULE android.oom_adjuster; 1229 SELECT 1230 ts, 1231 dur, 1232 score, 1233 bucket, 1234 process_name, 1235 oom_adj_ts, 1236 oom_adj_dur, 1237 oom_adj_thread_name, 1238 oom_adj_reason, 1239 oom_adj_trigger 1240 FROM android_oom_adj_intervals 1241 WHERE oom_adj_reason IS NOT NULL 1242 ORDER BY ts 1243 LIMIT 10 1244 """, 1245 out=Csv(""" 1246 "ts","dur","score","bucket","process_name","oom_adj_ts","oom_adj_dur","oom_adj_thread_name","oom_adj_reason","oom_adj_trigger" 12471737065264829,701108081,925,"cached","com.android.providers.calendar",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12481737066678827,3470211742,935,"cached","com.android.imsserviceentitlement",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12491737066873002,3470017567,945,"cached","com.android.carrierconfig",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12501737067058812,3469831757,955,"cached","com.android.messaging",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12511737067246975,699224817,955,"cached","android.process.acore",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12521737068421919,3468468650,965,"cached","com.android.shell",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12531737068599673,697908135,965,"cached","android.process.media",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12541737068933602,3467956967,975,"cached","com.android.gallery3d",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12551737069091010,3467799559,975,"cached","com.android.packageinstaller",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 12561737069240534,3467650035,985,"cached","com.android.managedprovisioning",1737064421516,29484835,"binder:642_1","processEnd","IActivityManager#1598246212" 1257 """)) 1258 1259 def test_broadcast_minsdk_u(self): 1260 return DiffTestBlueprint( 1261 trace=DataPath('freezer_trace.atr'), 1262 query=""" 1263 INCLUDE PERFETTO MODULE android.broadcasts; 1264 SELECT intent_action, process_name, pid, queue_id, ts, dur FROM _android_broadcasts_minsdk_u 1265 ORDER BY ts LIMIT 10 1266 """, 1267 out=Csv(""" 1268 "intent_action","process_name","pid","queue_id","ts","dur" 1269 "android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED","system",2519,0,91286297271477,221619 1270 "android.intent.action.TIME_TICK","com.android.systemui",2762,0,91295942589896,469216 1271 "android.intent.action.TIME_TICK","com.android.systemui",2762,0,91295943366025,313104 1272 "android.intent.action.TIME_TICK","com.android.systemui",2762,0,91295943943713,356194 1273 "android.intent.action.TIME_TICK","com.android.systemui",2762,0,91355941417856,444189 1274 "android.intent.action.TIME_TICK","com.android.systemui",2762,0,91355942543001,405369 1275 "android.intent.action.TIME_TICK","com.android.systemui",2762,0,91355943262781,339640 1276 "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION","system",2519,0,91359865607938,862534 1277 "android.content.pm.action.SESSION_COMMITTED","com.android.launcher3",3219,0,91360380556725,15221753 1278 "android.intent.action.PACKAGE_ADDED","system",2519,0,91360396877398,107502 1279 """)) 1280