OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """ A simple device interface for build steps. | 5 """ A simple device interface for build steps. |
6 | 6 |
7 """ | 7 """ |
8 | 8 |
9 import logging | 9 import logging |
10 import os | 10 import os |
11 import re | 11 import re |
12 import sys | 12 import sys |
13 | 13 |
14 from util import build_utils | 14 from util import build_utils |
15 | 15 |
16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..', '..') | 16 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..', '..') |
17 sys.path.append(BUILD_ANDROID_DIR) | 17 sys.path.append(BUILD_ANDROID_DIR) |
18 | 18 |
19 from pylib import android_commands | 19 from pylib import android_commands |
20 from pylib.device import device_errors | 20 from pylib.device import device_errors |
21 from pylib.device import device_utils | 21 from pylib.device import device_utils |
22 | 22 |
23 GetAttachedDevices = android_commands.GetAttachedDevices | 23 GetAttachedDevices = android_commands.GetAttachedDevices |
24 | 24 |
25 | 25 |
26 class BuildDevice(object): | 26 class BuildDevice(object): |
perezju
2015/04/17 09:16:43
not sure if this falls under our scope, but maybe
jbudorick
2015/04/17 13:32:24
This is a question for +cjhopman.
cjhopman
2015/04/17 18:44:37
So, it's complicated.
This is used for a bunch of
| |
27 def __init__(self, configuration): | 27 def __init__(self, configuration): |
28 self.id = configuration['id'] | 28 self.id = configuration['id'] |
29 self.description = configuration['description'] | 29 self.description = configuration['description'] |
30 self.install_metadata = configuration['install_metadata'] | 30 self.install_metadata = configuration['install_metadata'] |
31 self.device = device_utils.DeviceUtils(self.id) | 31 self.device = device_utils.DeviceUtils(self.id) |
32 | 32 |
33 def RunShellCommand(self, *args, **kwargs): | 33 def RunShellCommand(self, *args, **kwargs): |
34 return self.device.RunShellCommand(*args, **kwargs) | 34 return self.device.RunShellCommand(*args, **kwargs) |
35 | 35 |
36 def PushChangedFiles(self, *args, **kwargs): | 36 def PushChangedFiles(self, *args, **kwargs): |
37 return self.device.PushChangedFiles(*args, **kwargs) | 37 return self.device.PushChangedFiles(*args, **kwargs) |
38 | 38 |
39 def GetSerialNumber(self): | 39 def GetSerialNumber(self): |
40 return self.id | 40 return self.id |
41 | 41 |
42 def Install(self, *args, **kwargs): | 42 def Install(self, *args, **kwargs): |
43 return self.device.old_interface.Install(*args, **kwargs) | 43 return self.device.Install(*args, **kwargs) |
44 | 44 |
45 def GetInstallMetadata(self, apk_package): | 45 def GetInstallMetadata(self, apk_package): |
46 """Gets the metadata on the device for the apk_package apk.""" | 46 """Gets the metadata on the device for the apk_package apk.""" |
47 # Matches lines like: | 47 # Matches lines like: |
48 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ | 48 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
49 # org.chromium.chrome.shell.apk | 49 # org.chromium.chrome.shell.apk |
50 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ | 50 # -rw-r--r-- system system 7376582 2013-04-19 16:34 \ |
51 # org.chromium.chrome.shell-1.apk | 51 # org.chromium.chrome.shell-1.apk |
52 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s) | 52 apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?.apk$' % apk_package, s) |
53 matches = filter(apk_matcher, self.install_metadata) | 53 matches = filter(apk_matcher, self.install_metadata) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 assert len(configurations) == 1 | 96 assert len(configurations) == 1 |
97 return BuildDevice(configurations[0]) | 97 return BuildDevice(configurations[0]) |
98 | 98 |
99 | 99 |
100 def GetBuildDeviceFromPath(path): | 100 def GetBuildDeviceFromPath(path): |
101 configurations = ReadConfigurations(path) | 101 configurations = ReadConfigurations(path) |
102 if len(configurations) > 0: | 102 if len(configurations) > 0: |
103 return GetBuildDevice(ReadConfigurations(path)) | 103 return GetBuildDevice(ReadConfigurations(path)) |
104 return None | 104 return None |
105 | 105 |
OLD | NEW |