| OLD | NEW |
| 1 # Copyright 2016 Google Inc. | 1 # Copyright 2016 Google Inc. |
| 2 # | 2 # |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from __future__ import print_function | 6 from __future__ import print_function |
| 7 from _hardware import Hardware | 7 from _hardware import Hardware |
| 8 import sys | 8 import sys |
| 9 import time | 9 import time |
| 10 | 10 |
| 11 class HardwareAndroid(Hardware): | 11 class HardwareAndroid(Hardware): |
| 12 def __init__(self, adb): | 12 def __init__(self, adb): |
| 13 Hardware.__init__(self) | 13 Hardware.__init__(self) |
| 14 self.kick_in_time = 5 | 14 self.warmup_time = 5 |
| 15 self._adb = adb | 15 self._adb = adb |
| 16 self._is_root = self._adb.attempt_root() | 16 self._is_root = self._adb.attempt_root() |
| 17 if self._is_root: | 17 if self._is_root: |
| 18 self._adb.remount() | 18 self._adb.remount() |
| 19 self._initial_airplane_mode = None | 19 self._initial_airplane_mode = None |
| 20 self._initial_location_providers = None | 20 self._initial_location_providers = None |
| 21 self._initial_ASLR = None | 21 self._initial_ASLR = None |
| 22 | 22 |
| 23 def __enter__(self): | 23 def __enter__(self): |
| 24 # turn on airplane mode. | 24 # turn on airplane mode. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 settings put secure location_providers_allowed +$PROVIDER | 82 settings put secure location_providers_allowed +$PROVIDER |
| 83 done''' % self._initial_location_providers) | 83 done''' % self._initial_location_providers) |
| 84 | 84 |
| 85 # restore airplane mode (doesn't seem to work if we killed the gui). | 85 # restore airplane mode (doesn't seem to work if we killed the gui). |
| 86 self._adb.shell('settings put global airplane_mode_on %s' % | 86 self._adb.shell('settings put global airplane_mode_on %s' % |
| 87 self._initial_airplane_mode) | 87 self._initial_airplane_mode) |
| 88 | 88 |
| 89 def sanity_check(self): | 89 def sanity_check(self): |
| 90 Hardware.sanity_check(self) | 90 Hardware.sanity_check(self) |
| 91 | 91 |
| 92 def print_debug_diagnostics(self): |
| 93 # search for and print thermal trip points that may have been exceeded. |
| 94 self._adb.shell('''\ |
| 95 THERMALDIR=/sys/class/thermal |
| 96 if [ -e $THERMALDIR ]; then |
| 97 for ZONE in $(cd $THERMALDIR; echo thermal_zone*); do |
| 98 cd $THERMALDIR/$ZONE |
| 99 if [ -e mode ] && grep -Fxq enabled mode; then |
| 100 TEMP=$(cat temp) |
| 101 TRIPPOINT= |
| 102 let i=0 |
| 103 while [ -e trip_point_${i}_temp ] && |
| 104 [ $TEMP -gt $(cat trip_point_${i}_temp) ]; do |
| 105 TRIPPOINT=trip_point_${i}_temp |
| 106 let i=i+1 |
| 107 done |
| 108 if [ $TRIPPOINT ]; then |
| 109 echo "$ZONE ($(cat type)): temp=$TEMP > $TRIPPOINT=$(cat $TRIPPOIN
T)" |
| 110 fi |
| 111 fi |
| 112 done |
| 113 fi''') |
| 114 |
| 115 Hardware.print_debug_diagnostics(self) |
| 116 |
| 92 def sleep(self, sleeptime): | 117 def sleep(self, sleeptime): |
| 93 Hardware.sleep(self, sleeptime) | 118 Hardware.sleep(self, sleeptime) |
| OLD | NEW |