1#!/bin/bash 2 3# Copyright (C) 2020 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License 16 17readme() { 18 echo ' 19This gets the time to initial display for an app for a few times. 20e.g. 21PKG_NAME="com.android.car.dialer" \ 22 ACT_NAME=".ui.TelecomActivity" \ 23 LOOPS=3 \ 24 SLEEP_SEC=3 \ 25 ./time_to_init_disp.sh 26 27Notes: 28 - This will not work on User builds. 29' 30 exit 31} 32 33stop_pkg() { 34 echo "Force-stop $PKG_NAME" 35 adb shell am force-stop "$PKG_NAME" 36 sleep $SLEEP_SEC 37} 38 39if [[ -z $PKG_NAME ]]; then 40 PKG_NAME="com.android.car.media" 41fi 42 43if [[ -z $ACT_NAME ]]; then 44 ACT_NAME=".MediaActivity" 45fi 46ACTIVITY="$PKG_NAME/$ACT_NAME" 47 48if [[ -z $LOOPS ]]; then 49 LOOPS=3 50fi 51 52if [[ -z $SLEEP_SEC ]]; then 53 SLEEP_SEC=3 54fi 55 56echo "Time $ACTIVITY to Initial Display for $LOOPS times." 57adb shell getprop ro.build.fingerprint 58stop_pkg 59 60START=1 61 62adb root 63adb logcat -c 64for (( l=$START; l<=$LOOPS; l++ )); do 65 echo "Dropping caches" 66 adb shell "echo 3 > /proc/sys/vm/drop_caches" 67 68 echo "Loop: $l" 69 # -S: Force stop the target app before starting the activity. 70 # -W: Wait for launch to complete. 71 adb shell am start -S -W -n "$ACTIVITY" 72 sleep $SLEEP_SEC 73 stop_pkg 74done 75 76echo 77adb logcat -d | grep Displayed 78