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

Unified Diff: build/android/provision_devices.py

Issue 204353011: If install of test apk fails because of storage, wipe device data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use constants.ADB_KEYS_FILE. Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | build/android/pylib/constants.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/provision_devices.py
diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py
index 5cf1cc5d5cd36a262244d06366ced7b78caf9fce..53eb373ef8c43aa492bd1677c7b35fbb58c15c20 100755
--- a/build/android/provision_devices.py
+++ b/build/android/provision_devices.py
@@ -21,6 +21,7 @@ import time
from pylib import android_commands
from pylib import constants
from pylib import device_settings
+from pylib.cmd_helper import GetCmdOutput
def KillHostHeartbeat():
@@ -83,6 +84,33 @@ def _ConfigureLocalProperties(adb):
android_commands.LOCAL_PROPERTIES_PATH)
+def WipeDeviceData(device):
+ """Wipes data from device, keeping only the adb_keys for authorization.
+
+ After wiping data on a device that has been authorized, adb can still
+ communicate with the device, but after reboot the device will need to be
+ re-authorized because the adb keys file is stored in /data/misc/adb/.
+ Thus, before reboot the adb_keys file is rewritten so the device does not need
+ to be re-authorized.
+
+ Arguments:
+ device: the device to wipe
+ """
+ android_cmd = android_commands.AndroidCommands(device)
+ device_authorized = android_cmd.FileExistsOnDevice(constants.ADB_KEYS_FILE)
+ if device_authorized:
+ adb_keys = android_cmd.RunShellCommandWithSU(
+ 'cat %s' % constants.ADB_KEYS_FILE)[0]
+ android_cmd.RunShellCommandWithSU('wipe data')
+ if device_authorized:
+ path_list = constants.ADB_KEYS_FILE.split('/')
+ dir_path = '/'.join(path_list[:len(path_list)-1])
+ android_cmd.RunShellCommandWithSU('mkdir -p %s' % dir_path)
+ adb_keys = android_cmd.RunShellCommand(
+ 'echo %s > %s' % (adb_keys, constants.ADB_KEYS_FILE))
+ android_cmd.Reboot()
+
+
def ProvisionDevices(options):
if options.device is not None:
devices = [options.device]
@@ -90,6 +118,14 @@ def ProvisionDevices(options):
devices = android_commands.GetAttachedDevices()
for device in devices:
android_cmd = android_commands.AndroidCommands(device)
+ install_output = GetCmdOutput(
+ ['%s/build/android/adb_install_apk.py' % constants.DIR_SOURCE_ROOT,
+ '--apk',
+ '%s/build/android/CheckInstallApk-debug.apk' % constants.DIR_SOURCE_ROOT
+ ])
+ failure_string = 'Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]'
+ if failure_string in install_output:
+ WipeDeviceData(device)
_ConfigureLocalProperties(android_cmd)
device_settings.ConfigureContentSettingsDict(
android_cmd, device_settings.DETERMINISTIC_DEVICE_SETTINGS)
« no previous file with comments | « build/android/buildbot/bb_device_status_check.py ('k') | build/android/pylib/constants.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698