1-- 2-- Copyright 2022 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-- https://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-- 16 17SELECT IMPORT('android.binder'); 18 19-- Count Binder transactions per process 20DROP VIEW IF EXISTS binder_metrics_by_process; 21CREATE VIEW binder_metrics_by_process AS 22SELECT * FROM android_binder_metrics_by_process; 23 24DROP VIEW IF EXISTS android_binder_output; 25CREATE VIEW android_binder_output AS 26SELECT AndroidBinderMetric( 27 'process_breakdown', ( 28 SELECT RepeatedField( 29 AndroidBinderMetric_PerProcessBreakdown( 30 'process_name', process_name, 31 'pid', pid, 32 'slice_name', slice_name, 33 'count', event_count 34 ) 35 ) 36 FROM android_binder_metrics_by_process 37 ), 38 'unaggregated_txn_breakdown', ( 39 SELECT RepeatedField( 40 AndroidBinderMetric_UnaggregatedTxnBreakdown( 41 'aidl_name', aidl_name, 42 'client_process', client_process, 43 'client_thread', client_thread, 44 'is_main_thread', is_main_thread, 45 'client_ts', client_ts, 46 'client_dur', client_dur, 47 'client_tid', client_tid, 48 'client_pid', client_pid, 49 'server_process', server_process, 50 'server_thread', server_thread, 51 'server_ts', server_ts, 52 'server_dur', server_dur, 53 'server_tid', server_tid, 54 'server_pid', server_pid, 55 'thread_states', ( 56 SELECT RepeatedField( 57 AndroidBinderMetric_ThreadStateBreakdown( 58 'thread_state_type', thread_state_type, 59 'thread_state', thread_state, 60 'thread_state_dur', thread_state_dur, 61 'thread_state_count', thread_state_count 62 ) 63 ) FROM android_sync_binder_thread_state_by_txn t WHERE t.binder_txn_id = android_sync_binder_metrics_by_txn.binder_txn_id 64 ), 65 'blocked_functions', ( 66 SELECT RepeatedField( 67 AndroidBinderMetric_BlockedFunctionBreakdown( 68 'thread_state_type', thread_state_type, 69 'blocked_function', blocked_function, 70 'blocked_function_dur', blocked_function_dur, 71 'blocked_function_count', blocked_function_count 72 ) 73 ) FROM android_sync_binder_blocked_functions_by_txn b WHERE b.binder_txn_id = android_sync_binder_metrics_by_txn.binder_txn_id 74 ) 75 ) 76 ) 77 FROM android_sync_binder_metrics_by_txn 78 ) 79); 80