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 16-- Extract name of the device based on metadata from the trace. 17CREATE PERFETTO TABLE android_device_name( 18 -- Device name. 19 name STRING 20) 21AS 22WITH 23 -- Example str_value: 24 -- Android/aosp_raven/raven:VanillaIceCream/UDC/11197703:userdebug/test-keys 25 -- Gets substring after first slash; 26 after_first_slash(str) AS ( 27 SELECT SUBSTR(str_value, INSTR(str_value, '/') + 1) 28 FROM metadata 29 WHERE name = 'android_build_fingerprint' 30 ), 31 -- Gets substring after second slash 32 after_second_slash(str) AS ( 33 SELECT SUBSTR(str, INSTR(str, '/') + 1) 34 FROM after_first_slash 35 ), 36 -- Gets substring after second slash and before the colon 37 before_colon(str) AS ( 38 SELECT SUBSTR(str, 0, INSTR(str, ':')) 39 FROM after_second_slash 40 ) 41SELECT str AS name FROM before_colon; 42 43