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) AS 21WITH 22 -- Example str_value: 23 -- Android/aosp_raven/raven:VanillaIceCream/UDC/11197703:userdebug/test-keys 24 -- Gets substring after first slash; 25 after_first_slash(str) AS ( 26 SELECT 27 substr(str_value, instr(str_value, '/') + 1) 28 FROM metadata 29 WHERE 30 name = 'android_build_fingerprint' 31 ), 32 -- Gets substring after second slash 33 after_second_slash(str) AS ( 34 SELECT 35 substr(str, instr(str, '/') + 1) 36 FROM after_first_slash 37 ), 38 -- Gets substring after second slash and before the colon 39 before_colon(str) AS ( 40 SELECT 41 substr(str, 0, instr(str, ':')) 42 FROM after_second_slash 43 ) 44SELECT 45 str AS name 46FROM before_colon; 47