Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: build/android/pylib/device/device_utils.py

Issue 1012383006: [Android] Fix usb charging re-enabling on KK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 def EnableBatteryUpdates(self, timeout=None, retries=None): 1547 def EnableBatteryUpdates(self, timeout=None, retries=None):
1548 """ Restarts device charging so that dumpsys no longer collects power data. 1548 """ Restarts device charging so that dumpsys no longer collects power data.
1549 1549
1550 Args: 1550 Args:
1551 timeout: timeout in seconds 1551 timeout: timeout in seconds
1552 retries: number of retries 1552 retries: number of retries
1553 """ 1553 """
1554 def battery_updates_enabled(): 1554 def battery_updates_enabled():
1555 return self.GetCharging() is True 1555 return self.GetCharging() is True
1556 1556
1557 self.RunShellCommand(['dumpsys', 'battery', 'set', 'usb', '1'],
1558 check_return=True)
1557 self.RunShellCommand(['dumpsys', 'battery', 'reset'], check_return=True) 1559 self.RunShellCommand(['dumpsys', 'battery', 'reset'], check_return=True)
1558 timeout_retry.WaitFor(battery_updates_enabled, wait_period=1) 1560 timeout_retry.WaitFor(battery_updates_enabled, wait_period=1)
1559 1561
1560 @contextlib.contextmanager 1562 @contextlib.contextmanager
1561 def BatteryMeasurement(self, timeout=None, retries=None): 1563 def BatteryMeasurement(self, timeout=None, retries=None):
1562 """Context manager that enables battery data collection. It makes 1564 """Context manager that enables battery data collection. It makes
1563 the device appear to stop charging so that dumpsys will start collecting 1565 the device appear to stop charging so that dumpsys will start collecting
1564 power data since last charge. Once the with block is exited, charging is 1566 power data since last charge. Once the with block is exited, charging is
1565 resumed and power data since last charge is no longer collected. 1567 resumed and power data since last charge is no longer collected.
1566 1568
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 """ 1641 """
1640 if not devices: 1642 if not devices:
1641 devices = adb_wrapper.AdbWrapper.GetDevices() 1643 devices = adb_wrapper.AdbWrapper.GetDevices()
1642 if not devices: 1644 if not devices:
1643 raise device_errors.NoDevicesError() 1645 raise device_errors.NoDevicesError()
1644 devices = [d if isinstance(d, cls) else cls(d) for d in devices] 1646 devices = [d if isinstance(d, cls) else cls(d) for d in devices]
1645 if async: 1647 if async:
1646 return parallelizer.Parallelizer(devices) 1648 return parallelizer.Parallelizer(devices)
1647 else: 1649 else:
1648 return parallelizer.SyncParallelizer(devices) 1650 return parallelizer.SyncParallelizer(devices)
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698