forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Add an action to check/record attached devices
When doing a gyp_managed_install, we install APKs to the attached device. Currently this can fail in many ways (no device attached, multiple devices attached, device offline, device doesn't have root, etc.). In addition, we need to detect changes to the attached device (particularly when the device is switched, when an APK is uninstalled/updated). The current approach is to check all this information in the action interacting with the device. This means that when there is some problem we print the same warning messages for every APK that is built, and, in some cases, multiple times for each APK. Also, we have to run every install/push action every build because we detect changes to the attached device in that action. This change creates a new build action, "get device configurations". This action inspects the attached devices, filters out offline devices, filters out devices without root, and then writes a configuration file with the id+metadata for the first non-filtered device. This configuration is then used by each of the build steps that interacts with the device. This consolidates all the device checking to a single place, and the build actions don't need to do any checking. In addition, to detect changes in the attached device, we only need to run this single action every build and the install/push actions will only change when the device/metadata changes. Also, with this change we can now gracefully handle the case where multiple devices are attached (currently just write the configuration for the first valid device and install to that one). Review URL: https://chromiumcodereview.appspot.com/16831013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209582 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
cjhopman@chromium.org
committed
Jul 2, 2013
1 parent
172865b
commit 014d1ff
Showing
9 changed files
with
252 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2013 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
"""Gets and writes the configurations of the attached devices. | ||
This configuration is used by later build steps to determine which devices to | ||
install to and what needs to be installed to those devices. | ||
""" | ||
|
||
import logging | ||
import optparse | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
from util import build_utils | ||
from util import build_device | ||
|
||
BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') | ||
sys.path.append(BUILD_ANDROID_DIR) | ||
|
||
from pylib.utils import apk_helper | ||
|
||
|
||
def main(argv): | ||
parser = optparse.OptionParser() | ||
parser.add_option('--stamp', action='store') | ||
parser.add_option('--output', action='store') | ||
options, _ = parser.parse_args(argv) | ||
|
||
devices = build_device.GetAttachedDevices() | ||
|
||
device_configurations = [] | ||
for d in devices: | ||
configuration, is_online, has_root = ( | ||
build_device.GetConfigurationForDevice(d)) | ||
|
||
if not is_online: | ||
build_utils.PrintBigWarning( | ||
'%s is not online. Skipping managed install for this device. ' | ||
'Try rebooting the device to fix this warning.' % d) | ||
continue | ||
|
||
if not has_root: | ||
build_utils.PrintBigWarning( | ||
'"adb root" failed on device: %s\n' | ||
'Skipping managed install for this device.' | ||
% configuration['description']) | ||
continue | ||
|
||
device_configurations.append(configuration) | ||
|
||
if len(device_configurations) == 0: | ||
build_utils.PrintBigWarning( | ||
'No valid devices attached. Skipping managed install steps.') | ||
elif len(devices) > 1: | ||
# Note that this checks len(devices) and not len(device_configurations). | ||
# This way, any time there are multiple devices attached it is | ||
# explicitly stated which device we will install things to even if all but | ||
# one device were rejected for other reasons (e.g. two devices attached, | ||
# one w/o root). | ||
build_utils.PrintBigWarning( | ||
'Multiple devices attached. ' | ||
'Installing to the preferred device: ' | ||
'%(id)s (%(description)s)' % (device_configurations[0])) | ||
|
||
|
||
build_device.WriteConfigurations(device_configurations, options.output) | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main(sys.argv)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.