OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 # A collection of functions useful for maintaining android devices | 7 # A collection of functions useful for maintaining android devices |
8 | 8 |
9 | 9 |
10 # Run an adb command on all connected device in parallel. | 10 # Run an adb command on all connected device in parallel. |
(...skipping 24 matching lines...) Expand all Loading... |
35 # adb_all | 35 # adb_all |
36 # Usage: adb_device_loop 'command line to eval' | 36 # Usage: adb_device_loop 'command line to eval' |
37 adb_device_loop() { | 37 adb_device_loop() { |
38 if [[ $# == 0 ]]; then | 38 if [[ $# == 0 ]]; then |
39 echo "Intended for more complex one-liners that cannot be done with" \ | 39 echo "Intended for more complex one-liners that cannot be done with" \ |
40 "adb_all." | 40 "adb_all." |
41 echo 'Usage: adb_device_loop "echo $DEVICE: $(adb root &&' \ | 41 echo 'Usage: adb_device_loop "echo $DEVICE: $(adb root &&' \ |
42 'adb shell cat /data/local.prop)"' | 42 'adb shell cat /data/local.prop)"' |
43 return 1 | 43 return 1 |
44 fi | 44 fi |
45 local DEVICES=$(adb_get_devices -b) | 45 local DEVICES=$(adb_get_devices) |
| 46 if [[ -z $DEVICES ]]; then |
| 47 return |
| 48 fi |
46 # Do not change DEVICE variable name - part of api | 49 # Do not change DEVICE variable name - part of api |
47 for DEVICE in $DEVICES; do | 50 for DEVICE in $DEVICES; do |
48 DEV_TYPE=$(adb -s $DEVICE shell getprop ro.product.device | sed 's/\r//') | 51 DEV_TYPE=$(adb -s $DEVICE shell getprop ro.product.device | sed 's/\r//') |
49 echo "Running on $DEVICE ($DEV_TYPE)" | 52 echo "Running on $DEVICE ($DEV_TYPE)" |
50 ANDROID_SERIAL=$DEVICE eval "$*" | 53 ANDROID_SERIAL=$DEVICE eval "$*" |
51 done | 54 done |
52 } | 55 } |
53 | 56 |
54 # Erases data from any devices visible on adb. To preserve a device, | 57 # Erases data from any devices visible on adb. To preserve a device, |
55 # disconnect it or: | 58 # disconnect it or: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 _adb_multi() { | 130 _adb_multi() { |
128 local DEVICES=$1 | 131 local DEVICES=$1 |
129 local ADB_ARGS=$2 | 132 local ADB_ARGS=$2 |
130 ( | 133 ( |
131 for DEVICE in $DEVICES; do | 134 for DEVICE in $DEVICES; do |
132 adb -s $DEVICE $ADB_ARGS & | 135 adb -s $DEVICE $ADB_ARGS & |
133 done | 136 done |
134 wait | 137 wait |
135 ) | 138 ) |
136 } | 139 } |
OLD | NEW |