1-- 2-- Copyright 2024 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-- 16INCLUDE PERFETTO MODULE android.broadcasts; 17 18DROP VIEW IF EXISTS android_broadcasts_output; 19CREATE PERFETTO VIEW android_broadcasts_output AS 20SELECT AndroidBroadcastsMetric( 21 'process_count_by_intent', ( 22 SELECT RepeatedField( 23 AndroidBroadcastsMetric_BroadcastCountAggregation( 24 'name', intent_action, 25 'count', process_name_counts 26 ) 27 ) 28 FROM ( 29 SELECT 30 intent_action, 31 COUNT(process_name) as process_name_counts 32 FROM _android_broadcasts_minsdk_u 33 GROUP BY intent_action 34 ) 35 ), 36 'broadcast_count_by_process', ( 37 SELECT RepeatedField( 38 AndroidBroadcastsMetric_BroadcastCountAggregation( 39 'name', process_name, 40 'count', broadcast_counts 41 ) 42 ) 43 FROM ( 44 SELECT 45 process_name, 46 COUNT(id) as broadcast_counts 47 FROM _android_broadcasts_minsdk_u 48 GROUP BY process_name 49 ) 50 ), 51 'brodcast_duration_agg_by_intent', ( 52 SELECT RepeatedField( 53 AndroidBroadcastsMetric_BroadcastDurationAggregation( 54 'name', intent_action, 55 'avg_duration', avg_duration, 56 'max_duration', max_duration, 57 'sum_duration', sum_duration 58 ) 59 ) 60 FROM ( 61 SELECT 62 intent_action, 63 AVG(dur) as avg_duration, 64 SUM(dur) as sum_duration, 65 MAX(dur) as max_duration 66 FROM _android_broadcasts_minsdk_u 67 GROUP BY intent_action 68 ) 69 ), 'brodcast_duration_agg_by_process', ( 70 SELECT RepeatedField( 71 AndroidBroadcastsMetric_BroadcastDurationAggregation( 72 'name', process_name, 73 'avg_duration', avg_duration, 74 'max_duration', max_duration, 75 'sum_duration', sum_duration 76 ) 77 ) 78 FROM ( 79 SELECT 80 process_name, 81 AVG(dur) as avg_duration, 82 SUM(dur) as sum_duration, 83 MAX(dur) as max_duration 84 FROM _android_broadcasts_minsdk_u 85 GROUP BY process_name 86 ) 87 ) 88)