1#!/bin/bash 2 3# The intents to launch 4INTENTS="\ 5 com.google.android.googlequicksearchbox/.SearchActivity \ 6 com.android.settings/.Settings \ 7 com.google.android.apps.messaging/.ui.ConversationListActivity \ 8 com.google.android.calculator/com.android.calculator2.Calculator \ 9 com.google.android.deskclock/com.android.deskclock.DeskClock \ 10 com.google.android.contacts/com.android.contacts.activities.PeopleActivity \ 11 com.google.android.talk/.SigningInActivity \ 12 com.google.android.vr.home/com.google.android.apps.vr.home.app.MainActivity \ 13 com.android.documentsui/.Launcher \ 14 com.google.android.apps.nexuslauncher/.NexusLauncherActivity \ 15 " 16# com.google.android.GoogleCamera/com.android.camera.CameraActivity \ 17 18# The files to save output to. 19RAWLOGS_FILE=app-switch-rawlogs.txt 20ANALYSIS_FILE=app-switch-analysis.txt 21 22 23# Turn on the screen and unlock the device 24# TODO: Power on 25adb shell wm dismiss-keyguard 26adb logcat -P "" 27 28# Turn on airplane mode (to reduce background noise caught by other tests) 29airplane_mode_was_on=$(adb shell settings get global airplane_mode_on) 30if [ $airplane_mode_was_on != 1 ] ; then 31 adb shell settings put global airplane_mode_on 1 > /dev/null 32 adb shell am broadcast -a android.intent.action.AIRPLANE_MODE > /dev/null 33 sleep 15 34fi 35 36# Start the analysis process 37$TOP/development/tools/logblame/analyze_logs.py --duration=10m --clear --rawlogs $RAWLOGS_FILE \ 38 | tee $ANALYSIS_FILE & 39analyze_pid=$! 40 41# Launch the intents with a 3s gap between them 42for intent in $INTENTS 43do 44 echo Starting: $intent 45 adb shell am start -a android.intent.action.MAIN $intent 46 sleep 4 47done 48 49# Turn the screen off and on 50adb shell input keyevent 26 51adb shell input keyevent 26 52adb shell wm dismiss-keyguard 53 54echo 55echo 56 57# Kill adb to disconnect logcat 58adb kill-server 59 60# Wait for the pyton process to exit 61wait $analyze_pid 62 63# Turn airplane mode back off 64if [ $airplane_mode_was_on == 0 ] ; then 65 adb shell settings put global airplane_mode_on 0 > /dev/null 66 adb shell am broadcast -a android.intent.action.AIRPLANE_MODE > /dev/null 67fi 68 69echo "Wrote raw logs to $RAWLOGS_FILE" 70echo "Wrote analysis to $ANALYSIS_FILE" 71 72 73