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 17DROP VIEW IF EXISTS launch_async_events; 18CREATE VIEW launch_async_events AS 19SELECT 20 ts, 21 dur, 22 SUBSTR(name, 19) AS id 23FROM slice 24WHERE 25 name GLOB 'launchingActivity#*' 26 AND dur != 0 27 AND INSTR(name, ':') = 0; 28 29DROP VIEW IF EXISTS launch_complete_events; 30CREATE VIEW launch_complete_events AS 31SELECT 32 STR_SPLIT(completed, ':', 0) AS id, 33 STR_SPLIT(completed, ':', 2) AS package_name, 34 CASE 35 WHEN STR_SPLIT(completed, ':', 1) = 'completed-hot' THEN 'hot' 36 WHEN STR_SPLIT(completed, ':', 1) = 'completed-warm' THEN 'warm' 37 WHEN STR_SPLIT(completed, ':', 1) = 'completed-cold' THEN 'cold' 38 ELSE NULL 39 END AS launch_type, 40 MIN(ts) 41FROM ( 42 SELECT ts, SUBSTR(name, 19) AS completed 43 FROM slice 44 WHERE 45 dur = 0 46 -- Originally completed was unqualified, but at some point we introduced 47 -- the startup type as well 48 AND name GLOB 'launchingActivity#*:completed*:*' 49) 50GROUP BY 1, 2, 3; 51 52INSERT INTO launches(id, ts, ts_end, dur, package, launch_type) 53SELECT 54 id, 55 ts, 56 ts + dur AS ts_end, 57 dur, 58 package_name, 59 launch_type 60FROM launch_async_events 61JOIN launch_complete_events USING (id); 62