xref: /aosp_15_r20/system/extras/app-launcher/app-launcher.sh (revision 288bf5226967eb3dac5cce6c939ccc2a7f2b4fe5)
1*288bf522SAndroid Build Coastguard Worker#!/bin/bash
2*288bf522SAndroid Build Coastguard Worker
3*288bf522SAndroid Build Coastguard Workerparseoptions() {
4*288bf522SAndroid Build Coastguard Worker    verbose=false
5*288bf522SAndroid Build Coastguard Worker    user_experience=false
6*288bf522SAndroid Build Coastguard Worker    little_cores_off=false
7*288bf522SAndroid Build Coastguard Worker    iterations=0
8*288bf522SAndroid Build Coastguard Worker    pagecached=false
9*288bf522SAndroid Build Coastguard Worker
10*288bf522SAndroid Build Coastguard Worker    adb="adb"
11*288bf522SAndroid Build Coastguard Worker    while [ $# -gt 1 ]
12*288bf522SAndroid Build Coastguard Worker    do
13*288bf522SAndroid Build Coastguard Worker        case $1 in
14*288bf522SAndroid Build Coastguard Worker            -a)
15*288bf522SAndroid Build Coastguard Worker                ;;
16*288bf522SAndroid Build Coastguard Worker            -b)
17*288bf522SAndroid Build Coastguard Worker                little_cores_off=true
18*288bf522SAndroid Build Coastguard Worker                ;;
19*288bf522SAndroid Build Coastguard Worker            -c)
20*288bf522SAndroid Build Coastguard Worker                pagecached=true
21*288bf522SAndroid Build Coastguard Worker                ;;
22*288bf522SAndroid Build Coastguard Worker            -h)
23*288bf522SAndroid Build Coastguard Worker                usage
24*288bf522SAndroid Build Coastguard Worker                ;;
25*288bf522SAndroid Build Coastguard Worker            -s)
26*288bf522SAndroid Build Coastguard Worker                if [ -z "$2" ]; then
27*288bf522SAndroid Build Coastguard Worker                    usage
28*288bf522SAndroid Build Coastguard Worker                fi
29*288bf522SAndroid Build Coastguard Worker                adb="adb -s $2"
30*288bf522SAndroid Build Coastguard Worker                shift
31*288bf522SAndroid Build Coastguard Worker                ;;
32*288bf522SAndroid Build Coastguard Worker            -u)
33*288bf522SAndroid Build Coastguard Worker                user_experience=true
34*288bf522SAndroid Build Coastguard Worker                ;;
35*288bf522SAndroid Build Coastguard Worker            -v)
36*288bf522SAndroid Build Coastguard Worker                verbose=true
37*288bf522SAndroid Build Coastguard Worker                ;;
38*288bf522SAndroid Build Coastguard Worker            *)
39*288bf522SAndroid Build Coastguard Worker                usage
40*288bf522SAndroid Build Coastguard Worker                ;;
41*288bf522SAndroid Build Coastguard Worker            esac
42*288bf522SAndroid Build Coastguard Worker        shift
43*288bf522SAndroid Build Coastguard Worker    done
44*288bf522SAndroid Build Coastguard Worker
45*288bf522SAndroid Build Coastguard Worker    iterations=$1
46*288bf522SAndroid Build Coastguard Worker    if [ "$iterations" -lt 100 ]; then
47*288bf522SAndroid Build Coastguard Worker        usage
48*288bf522SAndroid Build Coastguard Worker    fi
49*288bf522SAndroid Build Coastguard Worker}
50*288bf522SAndroid Build Coastguard Worker
51*288bf522SAndroid Build Coastguard Workergetstats () {
52*288bf522SAndroid Build Coastguard Worker    infile=$1
53*288bf522SAndroid Build Coastguard Worker    app=$2
54*288bf522SAndroid Build Coastguard Worker    echo "Data for $app :"
55*288bf522SAndroid Build Coastguard Worker
56*288bf522SAndroid Build Coastguard Worker    # Activity Manager reports ThisTime and TotalTime. TotalTime seems to be
57*288bf522SAndroid Build Coastguard Worker    # a more measure of the launch from the users perspective. So using TotalTime
58*288bf522SAndroid Build Coastguard Worker    # as our metric for launch latency
59*288bf522SAndroid Build Coastguard Worker
60*288bf522SAndroid Build Coastguard Worker    # From Activity Manager
61*288bf522SAndroid Build Coastguard Worker    echo "Launch Time (TotalTime) :"
62*288bf522SAndroid Build Coastguard Worker    grep -F TotalTime "$infile" | awk '{print $2}' | computestats
63*288bf522SAndroid Build Coastguard Worker
64*288bf522SAndroid Build Coastguard Worker    # Data from simpleperf
65*288bf522SAndroid Build Coastguard Worker    echo "cpu-cycles :"
66*288bf522SAndroid Build Coastguard Worker    grep -F cpu-cycles "$infile" | awk '{print $1}' | sed s/,//g | computestats
67*288bf522SAndroid Build Coastguard Worker
68*288bf522SAndroid Build Coastguard Worker    # CPU util% Data from /proc/stat
69*288bf522SAndroid Build Coastguard Worker    echo "cpu-util% :"
70*288bf522SAndroid Build Coastguard Worker    grep -F 'Total CPU util' "$infile" | awk '{print $5}' | computestatsf
71*288bf522SAndroid Build Coastguard Worker    echo "user-cpu-util% :"
72*288bf522SAndroid Build Coastguard Worker    grep -F 'User CPU util' "$infile" | awk '{print $5}' | computestatsf
73*288bf522SAndroid Build Coastguard Worker    echo "sys-cpu-util% (incl hardirq/softirq) :"
74*288bf522SAndroid Build Coastguard Worker    grep -F 'Sys CPU util' "$infile" | awk '{print $5}' | computestatsf
75*288bf522SAndroid Build Coastguard Worker
76*288bf522SAndroid Build Coastguard Worker    if [ $verbose == true ]; then
77*288bf522SAndroid Build Coastguard Worker        echo "instructions : "
78*288bf522SAndroid Build Coastguard Worker        grep -F instructions "$infile" | awk '{print $1}' | sed s/,//g | computestats
79*288bf522SAndroid Build Coastguard Worker
80*288bf522SAndroid Build Coastguard Worker        echo "cycles per instruction : "
81*288bf522SAndroid Build Coastguard Worker        grep -F instructions "$infile" | awk '{print $4}' | sed s/,//g | computestatsf
82*288bf522SAndroid Build Coastguard Worker
83*288bf522SAndroid Build Coastguard Worker        echo "branch-misses : "
84*288bf522SAndroid Build Coastguard Worker        grep -F branch-misses "$infile" | awk '{print $1}' | sed s/,//g | computestats
85*288bf522SAndroid Build Coastguard Worker
86*288bf522SAndroid Build Coastguard Worker        echo "context-switches : "
87*288bf522SAndroid Build Coastguard Worker        grep -F context-switches "$infile" | awk '{print $1}' | sed s/,//g | computestats
88*288bf522SAndroid Build Coastguard Worker
89*288bf522SAndroid Build Coastguard Worker        echo "page-faults : "
90*288bf522SAndroid Build Coastguard Worker        grep -F page-faults "$infile" | awk '{print $1}' | sed s/,//g | computestats
91*288bf522SAndroid Build Coastguard Worker    fi
92*288bf522SAndroid Build Coastguard Worker
93*288bf522SAndroid Build Coastguard Worker    if [ "$system_bdev_set" == true ]; then
94*288bf522SAndroid Build Coastguard Worker        # (Storage) Data from /proc we've collected
95*288bf522SAndroid Build Coastguard Worker        echo "KB read for $system_block_device blkdev :"
96*288bf522SAndroid Build Coastguard Worker        grep -F KB "$infile" | grep system | awk '{print $5}' | computestats
97*288bf522SAndroid Build Coastguard Worker
98*288bf522SAndroid Build Coastguard Worker        echo "iowait% :"
99*288bf522SAndroid Build Coastguard Worker        grep -F IOwait "$infile" | awk '{print $3}' | computestatsf
100*288bf522SAndroid Build Coastguard Worker
101*288bf522SAndroid Build Coastguard Worker        echo "Device util% for $system_block_device blkdev :"
102*288bf522SAndroid Build Coastguard Worker        grep -F 'Device util' "$infile" | awk '{print $4}' | computestatsf
103*288bf522SAndroid Build Coastguard Worker    fi
104*288bf522SAndroid Build Coastguard Worker}
105*288bf522SAndroid Build Coastguard Worker
106*288bf522SAndroid Build Coastguard Workercpufreq_volantis() {
107*288bf522SAndroid Build Coastguard Worker    echo "Setting Governor to performance"
108*288bf522SAndroid Build Coastguard Worker    if [ $little_cores_off == true ]; then
109*288bf522SAndroid Build Coastguard Worker        echo "Cannot turn off Little cores on $model"
110*288bf522SAndroid Build Coastguard Worker        exit 1
111*288bf522SAndroid Build Coastguard Worker    fi
112*288bf522SAndroid Build Coastguard Worker    i=0
113*288bf522SAndroid Build Coastguard Worker    num_cores=2
114*288bf522SAndroid Build Coastguard Worker    while [ $i -lt  $num_cores ]
115*288bf522SAndroid Build Coastguard Worker    do
116*288bf522SAndroid Build Coastguard Worker        $adb shell "echo performance  > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_g\
117*288bf522SAndroid Build Coastguard Workerovernor"
118*288bf522SAndroid Build Coastguard Worker        $adb shell "echo 2499000 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_fr\
119*288bf522SAndroid Build Coastguard Workereq"
120*288bf522SAndroid Build Coastguard Worker        i=$((i + 1))
121*288bf522SAndroid Build Coastguard Worker    done
122*288bf522SAndroid Build Coastguard Worker    # Lock the GPU frequencies
123*288bf522SAndroid Build Coastguard Worker    echo -n 852000000 > /d/clock/override.gbus/rate
124*288bf522SAndroid Build Coastguard Worker    echo -n 1 > /d/clock/override.gbus/state
125*288bf522SAndroid Build Coastguard Worker}
126*288bf522SAndroid Build Coastguard Worker
127*288bf522SAndroid Build Coastguard Workercpufreq_fugu() {
128*288bf522SAndroid Build Coastguard Worker    echo "Setting Governor to performance"
129*288bf522SAndroid Build Coastguard Worker    if [ $little_cores_off == true ]; then
130*288bf522SAndroid Build Coastguard Worker        echo "Cannot turn off Little cores on $model"
131*288bf522SAndroid Build Coastguard Worker        exit 1
132*288bf522SAndroid Build Coastguard Worker    fi
133*288bf522SAndroid Build Coastguard Worker    i=0
134*288bf522SAndroid Build Coastguard Worker    num_cores=4
135*288bf522SAndroid Build Coastguard Worker    while [ $i -lt  $num_cores ]
136*288bf522SAndroid Build Coastguard Worker    do
137*288bf522SAndroid Build Coastguard Worker        $adb shell "echo performance  > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
138*288bf522SAndroid Build Coastguard Worker        $adb shell "echo 1833000 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
139*288bf522SAndroid Build Coastguard Worker        i=$((i + 1))
140*288bf522SAndroid Build Coastguard Worker    done
141*288bf522SAndroid Build Coastguard Worker}
142*288bf522SAndroid Build Coastguard Worker
143*288bf522SAndroid Build Coastguard Workercpufreq_taimen_walleye () {
144*288bf522SAndroid Build Coastguard Worker    echo "Setting Governor to performance"
145*288bf522SAndroid Build Coastguard Worker    # GPU Governor and Frequency
146*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor'
147*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo 624000000 > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq'
148*288bf522SAndroid Build Coastguard Worker    if [ $little_cores_off == true ]; then
149*288bf522SAndroid Build Coastguard Worker        # Disable Little Cores, force app to run on big cores
150*288bf522SAndroid Build Coastguard Worker        echo "Disabling Little Cores"
151*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu0/online'
152*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu1/online'
153*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu2/online'
154*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu3/online'
155*288bf522SAndroid Build Coastguard Worker    else
156*288bf522SAndroid Build Coastguard Worker        echo "Enabling All Cores"
157*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu0/online'
158*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu1/online'
159*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu2/online'
160*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu3/online'
161*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'
162*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1900800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'
163*288bf522SAndroid Build Coastguard Worker    fi
164*288bf522SAndroid Build Coastguard Worker    # Set Governor to performance, up scaling_max_frequency to highest
165*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo performance  > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor'
166*288bf522SAndroid Build Coastguard Worker    # Only necessary to set max_freq on cpu4, cpu5-7 are in same cluster and will
167*288bf522SAndroid Build Coastguard Worker    # automatically get the same settings
168*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo 2457600 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq'
169*288bf522SAndroid Build Coastguard Worker}
170*288bf522SAndroid Build Coastguard Worker
171*288bf522SAndroid Build Coastguard Workercpufreq_marlin_sailfish () {
172*288bf522SAndroid Build Coastguard Worker    echo "Setting Governor to performance"
173*288bf522SAndroid Build Coastguard Worker    # GPU Governor and Frequency
174*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor'
175*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo 624000000 > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq'
176*288bf522SAndroid Build Coastguard Worker    if [ $little_cores_off == true ]; then
177*288bf522SAndroid Build Coastguard Worker        # Disable Little Cores, force app to run on big cores
178*288bf522SAndroid Build Coastguard Worker        echo "Disabling Little Cores"
179*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu0/online'
180*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu1/online'
181*288bf522SAndroid Build Coastguard Worker    else
182*288bf522SAndroid Build Coastguard Worker        echo "Enabling All Cores"
183*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu0/online'
184*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu1/online'
185*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'
186*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1996800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'
187*288bf522SAndroid Build Coastguard Worker        # cpu1 needed ?
188*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor'
189*288bf522SAndroid Build Coastguard Worker        $adb shell 'echo 1996800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq'
190*288bf522SAndroid Build Coastguard Worker    fi
191*288bf522SAndroid Build Coastguard Worker    # Set Governor to performance, up scaling_max_frequency to highest
192*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo performance  > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor'
193*288bf522SAndroid Build Coastguard Worker    # Only necessary to set max_freq on cpu2, cpu3 is in same cluster and will
194*288bf522SAndroid Build Coastguard Worker    # automatically get the same settings
195*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo 2150400 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq'
196*288bf522SAndroid Build Coastguard Worker}
197*288bf522SAndroid Build Coastguard Worker
198*288bf522SAndroid Build Coastguard Workercpufreq_angler () {
199*288bf522SAndroid Build Coastguard Worker    echo "Setting Governor and Frequency"
200*288bf522SAndroid Build Coastguard Worker    # GPU Governor and Frequency
201*288bf522SAndroid Build Coastguard Worker    $adb shell "echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor"
202*288bf522SAndroid Build Coastguard Worker    $adb shell "echo 0 > /sys/class/kgsl/kgsl-3d0/bus_split"
203*288bf522SAndroid Build Coastguard Worker    $adb shell "echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on"
204*288bf522SAndroid Build Coastguard Worker    $adb shell "echo 10000 > /sys/class/kgsl/kgsl-3d0/idle_timer"
205*288bf522SAndroid Build Coastguard Worker    if [ $little_cores_off == true ]; then
206*288bf522SAndroid Build Coastguard Worker        # Disable Little Cores, force app to run on big cores
207*288bf522SAndroid Build Coastguard Worker        echo "Disabling Little Cores"
208*288bf522SAndroid Build Coastguard Worker        i=0
209*288bf522SAndroid Build Coastguard Worker        num_cores=4
210*288bf522SAndroid Build Coastguard Worker        while [ $i -lt $num_cores ]
211*288bf522SAndroid Build Coastguard Worker        do
212*288bf522SAndroid Build Coastguard Worker            $adb shell "echo 0 > /sys/devices/system/cpu/cpu$i/online"
213*288bf522SAndroid Build Coastguard Worker            i=$((i + 1))
214*288bf522SAndroid Build Coastguard Worker        done
215*288bf522SAndroid Build Coastguard Worker    else
216*288bf522SAndroid Build Coastguard Worker        echo "Enabling All Cores"
217*288bf522SAndroid Build Coastguard Worker        # Enable Little cores here, set governor to performance
218*288bf522SAndroid Build Coastguard Worker        # Lock frequency of little cores
219*288bf522SAndroid Build Coastguard Worker        i=0
220*288bf522SAndroid Build Coastguard Worker        num_cores=4
221*288bf522SAndroid Build Coastguard Worker        while [ $i -lt $num_cores ]
222*288bf522SAndroid Build Coastguard Worker        do
223*288bf522SAndroid Build Coastguard Worker            $adb shell "echo 1 > /sys/devices/system/cpu/cpu$i/online"
224*288bf522SAndroid Build Coastguard Worker            $adb shell "echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
225*288bf522SAndroid Build Coastguard Worker            # Lock frequency of little cores
226*288bf522SAndroid Build Coastguard Worker            $adb shell "echo 1555200 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
227*288bf522SAndroid Build Coastguard Worker            i=$((i + 1))
228*288bf522SAndroid Build Coastguard Worker        done
229*288bf522SAndroid Build Coastguard Worker    fi
230*288bf522SAndroid Build Coastguard Worker    i=4
231*288bf522SAndroid Build Coastguard Worker    num_cores=8
232*288bf522SAndroid Build Coastguard Worker    while [ $i -lt $num_cores ]
233*288bf522SAndroid Build Coastguard Worker    do
234*288bf522SAndroid Build Coastguard Worker        $adb shell "echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
235*288bf522SAndroid Build Coastguard Worker        # Lock frequency of big cores
236*288bf522SAndroid Build Coastguard Worker        $adb shell "echo 1958400 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
237*288bf522SAndroid Build Coastguard Worker        i=$((i + 1))
238*288bf522SAndroid Build Coastguard Worker    done
239*288bf522SAndroid Build Coastguard Worker}
240*288bf522SAndroid Build Coastguard Worker
241*288bf522SAndroid Build Coastguard Workercpufreq_go() {
242*288bf522SAndroid Build Coastguard Worker    echo "Setting Governor to performance"
243*288bf522SAndroid Build Coastguard Worker    $adb shell 'echo 0 > /proc/hps/enabled'
244*288bf522SAndroid Build Coastguard Worker    for i in 0 1 2 3
245*288bf522SAndroid Build Coastguard Worker    do
246*288bf522SAndroid Build Coastguard Worker	$adb shell "echo 1 > /sys/devices/system/cpu/cpu$i/online"
247*288bf522SAndroid Build Coastguard Worker	$adb shell "echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
248*288bf522SAndroid Build Coastguard Worker	$adb shell "echo 1092000 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
249*288bf522SAndroid Build Coastguard Worker    done
250*288bf522SAndroid Build Coastguard Worker}
251*288bf522SAndroid Build Coastguard Worker
252*288bf522SAndroid Build Coastguard Workerget_taimen_walleye_devnames () {
253*288bf522SAndroid Build Coastguard Worker    # This bit of code required to get the block dev for /system and /vendor
254*288bf522SAndroid Build Coastguard Worker    # Suffix can be _a or _b, depending on what the active /system partition is
255*288bf522SAndroid Build Coastguard Worker#    suffix=`$adb shell getprop ro.boot.slot_suffix`
256*288bf522SAndroid Build Coastguard Worker    # Get the blockdevice using the suffix we got above
257*288bf522SAndroid Build Coastguard Worker#    system_block_device=`$adb shell ls -l /dev/block/platform/soc/*ufs*/by-name/system$suffix | awk '{ print $10 }' `
258*288bf522SAndroid Build Coastguard Worker    # Vendor is more straightforward, but we don't use it right now
259*288bf522SAndroid Build Coastguard Worker#    vendor_block_device=`$adb shell df /vendor | grep -v Filesystem | awk '{print $1}' `
260*288bf522SAndroid Build Coastguard Worker    # finally extract the last component of the absolute device pathname we got above
261*288bf522SAndroid Build Coastguard Worker#    system_block_device=`echo $system_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
262*288bf522SAndroid Build Coastguard Worker#    vendor_block_device=`echo $vendor_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
263*288bf522SAndroid Build Coastguard Worker    system_bdev_set=true
264*288bf522SAndroid Build Coastguard Worker#   For now, hardcode sda for Marlin/Sailfish block device
265*288bf522SAndroid Build Coastguard Worker#   XXX - We'll get stats for entire device
266*288bf522SAndroid Build Coastguard Worker    system_block_device=sda
267*288bf522SAndroid Build Coastguard Worker    echo Block Device $system_block_device
268*288bf522SAndroid Build Coastguard Worker}
269*288bf522SAndroid Build Coastguard Worker
270*288bf522SAndroid Build Coastguard Worker#
271*288bf522SAndroid Build Coastguard Worker# This strange bit of logic is needed to get the underlying block devices for /system
272*288bf522SAndroid Build Coastguard Worker# for Marlin/Sailfish
273*288bf522SAndroid Build Coastguard Worker#
274*288bf522SAndroid Build Coastguard Workerget_marlin_sailfish_devnames () {
275*288bf522SAndroid Build Coastguard Worker    # This bit of code required to get the block dev for /system and /vendor
276*288bf522SAndroid Build Coastguard Worker    # Suffix can be _a or _b, depending on what the active /system partition is
277*288bf522SAndroid Build Coastguard Worker#    suffix=`$adb shell getprop ro.boot.slot_suffix`
278*288bf522SAndroid Build Coastguard Worker    # Get the blockdevice using the suffix we got above
279*288bf522SAndroid Build Coastguard Worker#    system_block_device=`$adb shell ls -l /dev/block/platform/soc/*ufs*/by-name/system$suffix | awk '{ print $10 }' `
280*288bf522SAndroid Build Coastguard Worker    # Vendor is more straightforward, but we don't use it right now
281*288bf522SAndroid Build Coastguard Worker#    vendor_block_device=`$adb shell df /vendor | grep -v Filesystem | awk '{print $1}' `
282*288bf522SAndroid Build Coastguard Worker    # finally extract the last component of the absolute device pathname we got above
283*288bf522SAndroid Build Coastguard Worker#    system_block_device=`echo $system_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
284*288bf522SAndroid Build Coastguard Worker#    vendor_block_device=`echo $vendor_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
285*288bf522SAndroid Build Coastguard Worker    system_bdev_set=true
286*288bf522SAndroid Build Coastguard Worker#   For now, hardcode sda for Marlin/Sailfish block device
287*288bf522SAndroid Build Coastguard Worker#   XXX - We'll get stats for entire device
288*288bf522SAndroid Build Coastguard Worker    system_block_device=sda
289*288bf522SAndroid Build Coastguard Worker    echo Block Device $system_block_device
290*288bf522SAndroid Build Coastguard Worker}
291*288bf522SAndroid Build Coastguard Worker
292*288bf522SAndroid Build Coastguard Workerget_angler_devnames () {
293*288bf522SAndroid Build Coastguard Worker    # Get the underlying bdev from the "by-name" mapping
294*288bf522SAndroid Build Coastguard Worker    system_block_device=$($adb shell 'find /dev/block/platform -name by-name | xargs ls -l' | grep system | awk '{ print $10 }')
295*288bf522SAndroid Build Coastguard Worker    # extract the last component of the absolute device pathname we got above
296*288bf522SAndroid Build Coastguard Worker    system_block_device=$(echo "$system_block_device" | awk 'BEGIN { FS ="/" } ; { print $4 }')
297*288bf522SAndroid Build Coastguard Worker    # vendor is unused right now, but get the bdev anyway in case we decide to use it
298*288bf522SAndroid Build Coastguard Worker    # Get the underlying bdev from the "by-name" mapping
299*288bf522SAndroid Build Coastguard Worker    vendor_block_device=$($adb shell 'find /dev/block/platform -name by-name | xargs ls -l' | grep vendor | awk '{ print $10 }')
300*288bf522SAndroid Build Coastguard Worker    # extract the last component of the absolute device pathname we got above
301*288bf522SAndroid Build Coastguard Worker    vendor_block_device=$(echo "$vendor_block_device" | awk 'BEGIN { FS ="/" } ; { print $4 }')
302*288bf522SAndroid Build Coastguard Worker    system_bdev_set=true
303*288bf522SAndroid Build Coastguard Worker}
304*288bf522SAndroid Build Coastguard Worker
305*288bf522SAndroid Build Coastguard Workerget_fugu_devnames () {
306*288bf522SAndroid Build Coastguard Worker    system_block_device=$($adb shell ls -l /dev/block/by-name/system | awk '{ print $10 }')
307*288bf522SAndroid Build Coastguard Worker    system_block_device=$(echo "$system_block_device" | awk 'BEGIN { FS ="/" } ; { print $4 }')
308*288bf522SAndroid Build Coastguard Worker    system_bdev_set=true
309*288bf522SAndroid Build Coastguard Worker}
310*288bf522SAndroid Build Coastguard Worker
311*288bf522SAndroid Build Coastguard Workerdev_name_default_mmc () {
312*288bf522SAndroid Build Coastguard Worker    system_block_device=mmcblk0
313*288bf522SAndroid Build Coastguard Worker    system_bdev_set=true
314*288bf522SAndroid Build Coastguard Worker}
315*288bf522SAndroid Build Coastguard Worker
316*288bf522SAndroid Build Coastguard Workerget_volantis_devnames () {
317*288bf522SAndroid Build Coastguard Worker    dev_name_default_mmc
318*288bf522SAndroid Build Coastguard Worker}
319*288bf522SAndroid Build Coastguard Worker
320*288bf522SAndroid Build Coastguard Workerget_go_devnames () {
321*288bf522SAndroid Build Coastguard Worker    dev_name_default_mmc
322*288bf522SAndroid Build Coastguard Worker}
323*288bf522SAndroid Build Coastguard Worker
324*288bf522SAndroid Build Coastguard Workersystem_stats_before() {
325*288bf522SAndroid Build Coastguard Worker    if [ $system_bdev_set == true ]; then
326*288bf522SAndroid Build Coastguard Worker        # Get BEFORE read stats for /system
327*288bf522SAndroid Build Coastguard Worker        system=$($adb shell 'cat /proc/diskstats' | grep -w $system_block_device)
328*288bf522SAndroid Build Coastguard Worker        BEFORE_RD_IOS_SYSTEM=$(echo "$system" | awk '{ print $4 }')
329*288bf522SAndroid Build Coastguard Worker        BEFORE_RD_SECTORS_SYSTEM=$(echo "$system" | awk '{ print $6 }')
330*288bf522SAndroid Build Coastguard Worker        # iowait% computation
331*288bf522SAndroid Build Coastguard Worker        procstat=$($adb shell 'cat /proc/stat' | grep -w cpu)
332*288bf522SAndroid Build Coastguard Worker        user_ticks_before=$(echo "$procstat" | awk '{ print ($2 + $3) }')
333*288bf522SAndroid Build Coastguard Worker        sys_ticks_before=$(echo "$procstat" | awk '{ print ($4 + $7 + $8) }')
334*288bf522SAndroid Build Coastguard Worker        cpubusy_ticks_before=$(echo "$procstat" | awk '{ print ($2 + $3 + $4 + $7 + $8) }')
335*288bf522SAndroid Build Coastguard Worker        iowait_ticks_before=$(echo "$procstat" | awk '{ print $6 }')
336*288bf522SAndroid Build Coastguard Worker        total_ticks_before=$(echo "$procstat" | awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }')
337*288bf522SAndroid Build Coastguard Worker        # Device util% computation
338*288bf522SAndroid Build Coastguard Worker        uptime=$($adb shell 'cat /proc/uptime')
339*288bf522SAndroid Build Coastguard Worker        uptime_before_ms=$(echo "$uptime" | awk '{ print ($1 * 1000) }')
340*288bf522SAndroid Build Coastguard Worker        device_util_before_ms=$(echo "$system" | awk '{ print ($13) }')
341*288bf522SAndroid Build Coastguard Worker    fi
342*288bf522SAndroid Build Coastguard Worker}
343*288bf522SAndroid Build Coastguard Worker
344*288bf522SAndroid Build Coastguard Workersystem_stats_after() {
345*288bf522SAndroid Build Coastguard Worker    if [ $system_bdev_set == true ]; then
346*288bf522SAndroid Build Coastguard Worker        # Get AFTER read stats for /system
347*288bf522SAndroid Build Coastguard Worker        system=$($adb shell 'cat /proc/diskstats' | grep -w $system_block_device)
348*288bf522SAndroid Build Coastguard Worker        AFTER_RD_IOS_SYSTEM=$(echo "$system" | awk '{ print $4 }')
349*288bf522SAndroid Build Coastguard Worker        AFTER_RD_SECTORS_SYSTEM=$(echo "$system" | awk '{ print $6 }')
350*288bf522SAndroid Build Coastguard Worker        # iowait% computation
351*288bf522SAndroid Build Coastguard Worker        procstat=$($adb shell 'cat /proc/stat' | grep -w cpu)
352*288bf522SAndroid Build Coastguard Worker        user_ticks_after=$(echo "$procstat" | awk '{ print ($2 + $3) }')
353*288bf522SAndroid Build Coastguard Worker        sys_ticks_after=$(echo "$procstat" | awk '{ print ($4 + $7 + $8) }')
354*288bf522SAndroid Build Coastguard Worker        cpubusy_ticks_after=$(echo "$procstat" | awk '{ print ($2 + $3 + $4 + $7 + $8) }')
355*288bf522SAndroid Build Coastguard Worker        iowait_ticks_after=$(echo "$procstat" | awk '{ print $6 }')
356*288bf522SAndroid Build Coastguard Worker        total_ticks_after=$(echo "$procstat" | awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }')
357*288bf522SAndroid Build Coastguard Worker        # Device util% computation
358*288bf522SAndroid Build Coastguard Worker        uptime=$($adb shell 'cat /proc/uptime')
359*288bf522SAndroid Build Coastguard Worker        uptime_after_ms=$(echo "$uptime" | awk '{ print ($1 * 1000) }')
360*288bf522SAndroid Build Coastguard Worker        device_util_after_ms=$(echo "$system" | awk '{ print ($13) }')
361*288bf522SAndroid Build Coastguard Worker    fi
362*288bf522SAndroid Build Coastguard Worker}
363*288bf522SAndroid Build Coastguard Worker
364*288bf522SAndroid Build Coastguard Workersystem_stats_delta() {
365*288bf522SAndroid Build Coastguard Worker    if [ $system_bdev_set == true ]; then
366*288bf522SAndroid Build Coastguard Worker        # Sectors to KB
367*288bf522SAndroid Build Coastguard Worker        READ_KB_SYSTEM=$((AFTER_RD_SECTORS_SYSTEM - BEFORE_RD_SECTORS_SYSTEM))
368*288bf522SAndroid Build Coastguard Worker        READ_KB_SYSTEM=$((READ_KB_SYSTEM / 2))
369*288bf522SAndroid Build Coastguard Worker        echo Read IOs /system = $((AFTER_RD_IOS_SYSTEM - BEFORE_RD_IOS_SYSTEM))
370*288bf522SAndroid Build Coastguard Worker        echo Read KB /system = $READ_KB_SYSTEM
371*288bf522SAndroid Build Coastguard Worker        echo "$iowait_ticks_before" "$iowait_ticks_after" "$total_ticks_before" "$total_ticks_after" | awk '{ printf "IOwait = %.2f\n", (($2 - $1) * 100.0) / ($4 - $3) }'
372*288bf522SAndroid Build Coastguard Worker        echo "$device_util_before_ms" "$device_util_after_ms" "$uptime_before_ms" "$uptime_after_ms" | awk '{ printf "Device util% = %.2f\n", (($2 - $1) * 100.0) / ($4 - $3) }'
373*288bf522SAndroid Build Coastguard Worker        echo "$user_ticks_after" "$user_ticks_before" "$total_ticks_after" "$total_ticks_before" | awk '{ printf "User CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
374*288bf522SAndroid Build Coastguard Worker        echo "$sys_ticks_after" "$sys_ticks_before" "$total_ticks_after" "$total_ticks_before" | awk '{ printf "Sys CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
375*288bf522SAndroid Build Coastguard Worker        echo "$cpubusy_ticks_after" "$cpubusy_ticks_before" "$total_ticks_after" "$total_ticks_before" | awk '{ printf "Total CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
376*288bf522SAndroid Build Coastguard Worker    fi
377*288bf522SAndroid Build Coastguard Worker}
378*288bf522SAndroid Build Coastguard Worker
379*288bf522SAndroid Build Coastguard Workerlaunch_app() {
380*288bf522SAndroid Build Coastguard Worker    package=$1
381*288bf522SAndroid Build Coastguard Worker    activity=$2
382*288bf522SAndroid Build Coastguard Worker    $adb shell "am force-stop $package"
383*288bf522SAndroid Build Coastguard Worker    sleep 1
384*288bf522SAndroid Build Coastguard Worker
385*288bf522SAndroid Build Coastguard Worker    printf "Testing %s: \n" "$package" 1>&2
386*288bf522SAndroid Build Coastguard Worker    i=0
387*288bf522SAndroid Build Coastguard Worker    while [ $i -lt "$iterations" ]
388*288bf522SAndroid Build Coastguard Worker    do
389*288bf522SAndroid Build Coastguard Worker        if [ $pagecached == false ]; then
390*288bf522SAndroid Build Coastguard Worker            $adb shell 'echo 3 > /proc/sys/vm/drop_caches'
391*288bf522SAndroid Build Coastguard Worker        fi
392*288bf522SAndroid Build Coastguard Worker        printf '[ %d%% ]\r' "$((i * 100 / iterations))" 1>&2
393*288bf522SAndroid Build Coastguard Worker        # The -W argument to am start forces am start to wait till the launch completes.
394*288bf522SAndroid Build Coastguard Worker        # The -S argument forces it to kill any existing app that is running first
395*288bf522SAndroid Build Coastguard Worker        # eg. adb shell 'am start -W -S -n com.android.chrome/com.google.android.apps.chrome.Main'
396*288bf522SAndroid Build Coastguard Worker        system_stats_before
397*288bf522SAndroid Build Coastguard Worker        $adb shell "simpleperf stat -a am start -W -n $package/$activity"
398*288bf522SAndroid Build Coastguard Worker        system_stats_after
399*288bf522SAndroid Build Coastguard Worker        system_stats_delta
400*288bf522SAndroid Build Coastguard Worker        sleep 1
401*288bf522SAndroid Build Coastguard Worker        $adb shell "am force-stop $package"
402*288bf522SAndroid Build Coastguard Worker        sleep 1
403*288bf522SAndroid Build Coastguard Worker        i=$((i + 1))
404*288bf522SAndroid Build Coastguard Worker    done
405*288bf522SAndroid Build Coastguard Worker    printf "\n" 1>&2
406*288bf522SAndroid Build Coastguard Worker}
407*288bf522SAndroid Build Coastguard Worker
408*288bf522SAndroid Build Coastguard Workerlaunch_fugu_apps() {
409*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.youtube.tv com.google.android.apps.youtube.tv.activity.TvGuideActivity > "$BASHPID-youtube-$model"
410*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-youtube-$model" YouTube
411*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.play.games com.google.android.gms.games.pano.activity.PanoGamesOnboardHostActivity > "$BASHPID-games-$model"
412*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-games-$model" Games
413*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.music com.android.music.activitymanagement.TopLevelActivity > "$BASHPID-music-$model"
414*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-music-$model" Music
415*288bf522SAndroid Build Coastguard Worker}
416*288bf522SAndroid Build Coastguard Worker
417*288bf522SAndroid Build Coastguard Workerlaunch_phone_apps() {
418*288bf522SAndroid Build Coastguard Worker    launch_app com.android.chrome com.google.android.apps.chrome.Main > "$BASHPID-chrome-$model"
419*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-chrome-$model" Chrome
420*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.GoogleCamera com.android.camera.CameraActivity > "$BASHPID-camera-$model"
421*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-camera-$model" Camera
422*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.apps.maps com.google.android.maps.MapsActivity > "$BASHPID-maps-$model"
423*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-maps-$model" Maps
424*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.youtube com.google.android.apps.youtube.app.WatchWhileActivity > "$BASHPID-youtube-$model"
425*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-youtube-$model" YouTube
426*288bf522SAndroid Build Coastguard Worker}
427*288bf522SAndroid Build Coastguard Worker
428*288bf522SAndroid Build Coastguard Workerlaunch_go_apps() {
429*288bf522SAndroid Build Coastguard Worker    launch_app com.android.chrome com.google.android.apps.chrome.Main > "$BASHPID-chrome-$model"
430*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-chrome-$model" Chrome
431*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.gm.lite com.google.android.gm.ConversationListActivityGmail > "$BASHPID-gmailgo-$model"
432*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-gmailgo-$model" GmailGo
433*288bf522SAndroid Build Coastguard Worker    launch_app com.google.android.apps.youtube.mango com.google.android.apps.youtube.lite.frontend.activities.SplashActivity > "$BASHPID-youtubego-$model"
434*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-youtubego-$model" YouTubeGo
435*288bf522SAndroid Build Coastguard Worker    launch_app com.android.vending com.google.android.finsky.activities.MainActivity > "$BASHPID-play-$model"
436*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-play-$model" Play
437*288bf522SAndroid Build Coastguard Worker    launch_app com.android.settings com.android.settings.Settings > "$BASHPID-settings-$model"
438*288bf522SAndroid Build Coastguard Worker    getstats "$BASHPID-settings-$model" Settings
439*288bf522SAndroid Build Coastguard Worker}
440*288bf522SAndroid Build Coastguard Worker
441*288bf522SAndroid Build Coastguard Workerusage() {
442*288bf522SAndroid Build Coastguard Worker    echo 'Usage: app-launcher [-c|-v|-s <serial num>] -a|-b|-u num-iterations'
443*288bf522SAndroid Build Coastguard Worker    echo 'where num-iterations >= 100'
444*288bf522SAndroid Build Coastguard Worker    echo '-v (optional) for verbose stats dump'
445*288bf522SAndroid Build Coastguard Worker    echo '-s <serial num> (optional) run test on specific device'
446*288bf522SAndroid Build Coastguard Worker    echo '-a|-b|-u required:'
447*288bf522SAndroid Build Coastguard Worker    echo '        -a:all cores'
448*288bf522SAndroid Build Coastguard Worker    echo '        -b:only big cores'
449*288bf522SAndroid Build Coastguard Worker    echo '        -c:pagecached. Do not drop pagecache before each launch (not default)'
450*288bf522SAndroid Build Coastguard Worker    echo '        -h:Dump this help menu'
451*288bf522SAndroid Build Coastguard Worker    echo '        -u:user experience, no change to cpu/gpu frequencies or governors'
452*288bf522SAndroid Build Coastguard Worker    echo '        -a/-b locks CPU/GPU freqs to max, performance governor, thermal/perfd off'
453*288bf522SAndroid Build Coastguard Worker    echo '        -u runs with default device configs, as users would see it'
454*288bf522SAndroid Build Coastguard Worker    exit 1
455*288bf522SAndroid Build Coastguard Worker}
456*288bf522SAndroid Build Coastguard Worker
457*288bf522SAndroid Build Coastguard Workersetup() {
458*288bf522SAndroid Build Coastguard Worker    echo "Setting up device"
459*288bf522SAndroid Build Coastguard Worker    # Set developer options, will automatically 'Stay Awake'
460*288bf522SAndroid Build Coastguard Worker    $adb shell 'am start -n com.android.settings/.DevelopmentSettings'
461*288bf522SAndroid Build Coastguard Worker    # Set screen timeout to 30 minutes
462*288bf522SAndroid Build Coastguard Worker    $adb shell 'settings put system screen_off_timeout 1800000'
463*288bf522SAndroid Build Coastguard Worker
464*288bf522SAndroid Build Coastguard Worker    # TODO: Consider rebooting device to start with a clean state
465*288bf522SAndroid Build Coastguard Worker
466*288bf522SAndroid Build Coastguard Worker    # Disable automatic rotation and NFC
467*288bf522SAndroid Build Coastguard Worker    # This works on OC, but haven't tested on NYC or earlier
468*288bf522SAndroid Build Coastguard Worker    $adb shell 'content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0'
469*288bf522SAndroid Build Coastguard Worker    $adb shell 'svc nfc disable'
470*288bf522SAndroid Build Coastguard Worker
471*288bf522SAndroid Build Coastguard Worker    # Clear all notifications
472*288bf522SAndroid Build Coastguard Worker    $adb shell 'service call notification 1'
473*288bf522SAndroid Build Coastguard Worker    # Go to home screen
474*288bf522SAndroid Build Coastguard Worker    $adb shell 'input keyevent KEYCODE_WAKEUP' && sleep 0.5
475*288bf522SAndroid Build Coastguard Worker    $adb shell 'input keyevent KEYCODE_MENU'   && sleep 0.5
476*288bf522SAndroid Build Coastguard Worker    $adb shell 'input keyevent KEYCODE_HOME'   && sleep 0.5
477*288bf522SAndroid Build Coastguard Worker    sleep 2
478*288bf522SAndroid Build Coastguard Worker    # TODO: kill all background apps
479*288bf522SAndroid Build Coastguard Worker    # TODO: clear popups
480*288bf522SAndroid Build Coastguard Worker}
481*288bf522SAndroid Build Coastguard Worker
482*288bf522SAndroid Build Coastguard Worker#
483*288bf522SAndroid Build Coastguard Worker# The main() part of the script follows :
484*288bf522SAndroid Build Coastguard Worker#
485*288bf522SAndroid Build Coastguard Worker
486*288bf522SAndroid Build Coastguard Workerif [ $# -lt 2 ]; then
487*288bf522SAndroid Build Coastguard Worker    usage
488*288bf522SAndroid Build Coastguard Workerfi
489*288bf522SAndroid Build Coastguard Worker
490*288bf522SAndroid Build Coastguard Workerif ! which computestats > /dev/null ; then
491*288bf522SAndroid Build Coastguard Worker    echo "ERROR: Please add computestats utiliy to your PATH"
492*288bf522SAndroid Build Coastguard Worker    exit 1
493*288bf522SAndroid Build Coastguard Workerfi
494*288bf522SAndroid Build Coastguard Worker
495*288bf522SAndroid Build Coastguard Workerif ! which computestatsf > /dev/null ; then
496*288bf522SAndroid Build Coastguard Worker    echo "Error: Please add computestatsf utility to your PATH"
497*288bf522SAndroid Build Coastguard Worker    exit 1
498*288bf522SAndroid Build Coastguard Workerfi
499*288bf522SAndroid Build Coastguard Worker
500*288bf522SAndroid Build Coastguard Workerparseoptions "$@"
501*288bf522SAndroid Build Coastguard Worker
502*288bf522SAndroid Build Coastguard Worker$adb root && $adb wait-for-device
503*288bf522SAndroid Build Coastguard Worker
504*288bf522SAndroid Build Coastguard Workerif [ $user_experience == false ]; then
505*288bf522SAndroid Build Coastguard Worker    # Important to stop the thermal-engine to prevent throttling while test is running
506*288bf522SAndroid Build Coastguard Worker    # and stop perfd
507*288bf522SAndroid Build Coastguard Worker    $adb shell 'stop thermal-engine'
508*288bf522SAndroid Build Coastguard Worker    $adb shell 'stop perfd'
509*288bf522SAndroid Build Coastguard Workerelse
510*288bf522SAndroid Build Coastguard Worker    echo "User Experience: Default Configs. No changes to cpufreq settings"
511*288bf522SAndroid Build Coastguard Workerfi
512*288bf522SAndroid Build Coastguard Worker
513*288bf522SAndroid Build Coastguard Worker# Releases are inconsistent with various trailing characters, remove them all
514*288bf522SAndroid Build Coastguard Workermodel=$($adb shell getprop ro.product.name | sed 's/[ \t\r\n]*$//')
515*288bf522SAndroid Build Coastguard Worker
516*288bf522SAndroid Build Coastguard Workerecho "Found $model Device"
517*288bf522SAndroid Build Coastguard Worker
518*288bf522SAndroid Build Coastguard Workersystem_bdev_set=false
519*288bf522SAndroid Build Coastguard Workercase $model in
520*288bf522SAndroid Build Coastguard Worker    # Android Go
521*288bf522SAndroid Build Coastguard Worker    aosp_gobo | full_k37_y33_gms | gobo | gobo_512)
522*288bf522SAndroid Build Coastguard Worker	if [ $user_experience == false ]; then
523*288bf522SAndroid Build Coastguard Worker	    cpufreq_go
524*288bf522SAndroid Build Coastguard Worker        fi
525*288bf522SAndroid Build Coastguard Worker	get_go_devnames
526*288bf522SAndroid Build Coastguard Worker        ;;
527*288bf522SAndroid Build Coastguard Worker    taimen | muskie | walleye)
528*288bf522SAndroid Build Coastguard Worker        if [ $user_experience == false ]; then
529*288bf522SAndroid Build Coastguard Worker            cpufreq_taimen_walleye
530*288bf522SAndroid Build Coastguard Worker        fi
531*288bf522SAndroid Build Coastguard Worker        get_taimen_walleye_devnames
532*288bf522SAndroid Build Coastguard Worker        ;;
533*288bf522SAndroid Build Coastguard Worker    marlin | sailfish)
534*288bf522SAndroid Build Coastguard Worker        if [ $user_experience == false ]; then
535*288bf522SAndroid Build Coastguard Worker            cpufreq_marlin_sailfish
536*288bf522SAndroid Build Coastguard Worker        fi
537*288bf522SAndroid Build Coastguard Worker        get_marlin_sailfish_devnames
538*288bf522SAndroid Build Coastguard Worker        ;;
539*288bf522SAndroid Build Coastguard Worker    angler)
540*288bf522SAndroid Build Coastguard Worker        if [ $user_experience == false ]; then
541*288bf522SAndroid Build Coastguard Worker            cpufreq_angler
542*288bf522SAndroid Build Coastguard Worker        fi
543*288bf522SAndroid Build Coastguard Worker        get_angler_devnames
544*288bf522SAndroid Build Coastguard Worker        ;;
545*288bf522SAndroid Build Coastguard Worker    fugu)
546*288bf522SAndroid Build Coastguard Worker        if [ $user_experience == false ]; then
547*288bf522SAndroid Build Coastguard Worker            cpufreq_fugu
548*288bf522SAndroid Build Coastguard Worker        fi
549*288bf522SAndroid Build Coastguard Worker        get_fugu_devnames
550*288bf522SAndroid Build Coastguard Worker        ;;
551*288bf522SAndroid Build Coastguard Worker    volantis | volantisg)
552*288bf522SAndroid Build Coastguard Worker        if [ $user_experience == false ]; then
553*288bf522SAndroid Build Coastguard Worker            cpufreq_volantis
554*288bf522SAndroid Build Coastguard Worker        fi
555*288bf522SAndroid Build Coastguard Worker        get_volantis_devnames
556*288bf522SAndroid Build Coastguard Worker        ;;
557*288bf522SAndroid Build Coastguard Worker    *)
558*288bf522SAndroid Build Coastguard Worker        echo "Unknown Device $model"
559*288bf522SAndroid Build Coastguard Worker        exit 1
560*288bf522SAndroid Build Coastguard Worker        ;;
561*288bf522SAndroid Build Coastguard Workeresac
562*288bf522SAndroid Build Coastguard Worker
563*288bf522SAndroid Build Coastguard Workersetup
564*288bf522SAndroid Build Coastguard Worker
565*288bf522SAndroid Build Coastguard Worker#
566*288bf522SAndroid Build Coastguard Worker# launch each app in turn
567*288bf522SAndroid Build Coastguard Worker#
568*288bf522SAndroid Build Coastguard Workercase $model in
569*288bf522SAndroid Build Coastguard Worker    # Android Go
570*288bf522SAndroid Build Coastguard Worker    aosp_gobo | full_k37_y33_gms | gobo | gobo_512)
571*288bf522SAndroid Build Coastguard Worker	launch_go_apps
572*288bf522SAndroid Build Coastguard Worker	;;
573*288bf522SAndroid Build Coastguard Worker    fugu)
574*288bf522SAndroid Build Coastguard Worker	launch_fugu_apps
575*288bf522SAndroid Build Coastguard Worker        ;;
576*288bf522SAndroid Build Coastguard Worker    *)
577*288bf522SAndroid Build Coastguard Worker	launch_phone_apps
578*288bf522SAndroid Build Coastguard Worker        ;;
579*288bf522SAndroid Build Coastguard Workeresac
580*288bf522SAndroid Build Coastguard Worker
581*288bf522SAndroid Build Coastguard Worker# cleanup
582*288bf522SAndroid Build Coastguard Workerrm $BASHPID*
583