1-- 2-- Copyright 2020 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 RUN_METRIC('android/process_metadata.sql'); 18 19DROP VIEW IF EXISTS android_task_names_output; 20CREATE VIEW android_task_names_output AS 21WITH 22-- Process to thread name 23threads_by_upid AS ( 24 SELECT 25 upid, 26 RepeatedField(name) AS thread_names 27 FROM thread 28 WHERE name IS NOT NULL 29 GROUP BY 1 30), 31upid_packages AS ( 32 SELECT 33 upid, 34 RepeatedField(package_list.package_name) AS packages 35 FROM process 36 JOIN package_list ON process.android_appid = package_list.uid 37 GROUP BY 1 38) 39SELECT AndroidTaskNames( 40 'process', RepeatedField( 41 AndroidTaskNames_Process( 42 'pid', p.pid, 43 'process_name', p.name, 44 'thread_name', threads_by_upid.thread_names, 45 'uid', p.uid, 46 'uid_package_name', upid_packages.packages 47 ) 48 ) 49) 50FROM process p 51LEFT JOIN threads_by_upid USING (upid) 52LEFT JOIN upid_packages USING (upid) 53WHERE upid != 0; 54