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 17TMP_OUTDIR="/tmp/rotary" 18ME=`basename "$0"` 19 20function help { 21 echo "A simple helper script that runs the Trade Federation unit tests" 22 echo "to print this message: packages/apps/Car/tests/tools/$ME" 23 echo "to build: packages/apps/Car/tests/tools/$ME b" 24 echo "to install: packages/apps/Car/tests/tools/$ME i" 25 echo "to run only: packages/apps/Car/tests/tools/$ME r" 26 echo "the apks and jar are in $TMP_OUTDIR" 27} 28 29function build { 30 echo 31 echo "Building the apks" 32 . build/envsetup.sh ; lunch aosp_car_x86-userdebug; make CarRotaryController RotaryPlayground android.car -j32 33 ANDROID_OUT=$ANDROID_BUILD_TOP/out 34 rm -r $TMP_OUTDIR 35 mkdir -p $TMP_OUTDIR 36 cp $ANDROID_PRODUCT_OUT/system/app/CarRotaryController/CarRotaryController.apk $TMP_OUTDIR 37 cp $ANDROID_PRODUCT_OUT/system/app/RotaryPlayground/RotaryPlayground.apk $TMP_OUTDIR 38 cp $ANDROID_OUT/target/common/obj/JAVA_LIBRARIES/android.car_intermediates/classes.jar $TMP_OUTDIR/android.car.jar 39} 40 41function install { 42 echo 43 echo "Installing the apks" 44 adb install -g $TMP_OUTDIR/CarRotaryController.apk 45 adb install -g $TMP_OUTDIR/RotaryPlayground.apk 46} 47 48function run { 49 echo 50 echo "Starting Rotary service and playground app" 51 adb shell settings put secure enabled_accessibility_services com.android.car.rotary/com.android.car.rotary.RotaryService 52 adb shell am start -n com.android.car.rotaryplayground/com.android.car.rotaryplayground.RotaryActivity 53} 54 55ACTION=$1 56 57if [[ $ACTION == "b" ]]; then 58 SECONDS=0 59 build 60 echo "Build time: $SECONDS sec." 61 ACTION="i" 62fi 63 64if [[ $ACTION == "i" ]]; then 65 install 66 ACTION="r" 67fi 68 69if [[ $ACTION == "r" ]]; then 70 run 71 exit 72fi 73 74help 75