1 #!/bin/bash 2 3 # The intents to launch 4 INTENTS="\ 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. 19 RAWLOGS_FILE=app-switch-rawlogs.txt 20 ANALYSIS_FILE=app-switch-analysis.txt 21 22 23 # Turn on the screen and unlock the device 24 # TODO: Power on 25 adb shell wm dismiss-keyguard 26 adb logcat -P "" 27 28 # Turn on airplane mode (to reduce background noise caught by other tests) 29 airplane_mode_was_on=$(adb shell settings get global airplane_mode_on) 30 if [ $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 34 fi 35 36 # Start the analysis process 37 $TOP/development/tools/logblame/analyze_logs.py --duration=10m --clear --rawlogs $RAWLOGS_FILE \ 38 | tee $ANALYSIS_FILE & 39 analyze_pid=$! 40 41 # Launch the intents with a 3s gap between them 42 for intent in $INTENTS 43 do 44 echo Starting: $intent 45 adb shell am start -a android.intent.action.MAIN $intent 46 sleep 4 47 done 48 49 # Turn the screen off and on 50 adb shell input keyevent 26 51 adb shell input keyevent 26 52 adb shell wm dismiss-keyguard 53 54 echo 55 echo 56 57 # Kill adb to disconnect logcat 58 adb kill-server 59 60 # Wait for the pyton process to exit 61 wait $analyze_pid 62 63 # Turn airplane mode back off 64 if [ $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 67 fi 68 69 echo "Wrote raw logs to $RAWLOGS_FILE" 70 echo "Wrote analysis to $ANALYSIS_FILE" 71 72 73