OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import os as real_os | 4 import os |
5 import subprocess as real_subprocess | |
6 import logging | 5 import logging |
7 import re | 6 import re |
| 7 import subprocess |
8 | 8 |
| 9 from chrome_remote_control import adb_commands |
9 from chrome_remote_control import android_browser_backend | 10 from chrome_remote_control import android_browser_backend |
10 import chrome_remote_control.adb_commands as real_adb_commands | |
11 from chrome_remote_control import browser | 11 from chrome_remote_control import browser |
12 from chrome_remote_control import possible_browser | 12 from chrome_remote_control import possible_browser |
13 | 13 |
14 | 14 |
15 """Finds android browsers that can be controlled by chrome_remote_control.""" | 15 """Finds android browsers that can be controlled by chrome_remote_control.""" |
16 | 16 |
17 ALL_BROWSER_TYPES = ','.join([ | 17 ALL_BROWSER_TYPES = ','.join([ |
18 'android-content-shell', | 18 'android-content-shell', |
19 'android-chrome', | 19 'android-chrome', |
20 'android-jb-system-chrome', | 20 'android-jb-system-chrome', |
(...skipping 27 matching lines...) Expand all Loading... |
48 self._args = args | 48 self._args = args |
49 | 49 |
50 def __repr__(self): | 50 def __repr__(self): |
51 return 'PossibleAndroidBrowser(browser_type=%s)' % self.browser_type | 51 return 'PossibleAndroidBrowser(browser_type=%s)' % self.browser_type |
52 | 52 |
53 def Create(self): | 53 def Create(self): |
54 backend = android_browser_backend.AndroidBrowserBackend( | 54 backend = android_browser_backend.AndroidBrowserBackend( |
55 self._options, *self._args) | 55 self._options, *self._args) |
56 return browser.Browser(backend) | 56 return browser.Browser(backend) |
57 | 57 |
58 def FindAllAvailableBrowsers(options, | 58 def FindAllAvailableBrowsers(options): |
59 subprocess=real_subprocess, | |
60 adb_commands=real_adb_commands): | |
61 """Finds all the desktop browsers available on this machine.""" | 59 """Finds all the desktop browsers available on this machine.""" |
62 if not adb_commands.IsAndroidSupported(): | 60 if not adb_commands.IsAndroidSupported(): |
63 return [] | 61 return [] |
64 | 62 |
65 # See if adb even works. | 63 # See if adb even works. |
66 try: | 64 try: |
67 with open(real_os.devnull, 'w') as devnull: | 65 with open(os.devnull, 'w') as devnull: |
68 proc = subprocess.Popen(['adb', 'devices'], | 66 proc = subprocess.Popen(['adb', 'devices'], |
69 stdout=subprocess.PIPE, | 67 stdout=subprocess.PIPE, |
70 stderr=subprocess.PIPE, | 68 stderr=subprocess.PIPE, |
71 stdin=devnull) | 69 stdin=devnull) |
72 stdout, _ = proc.communicate() | 70 stdout, _ = proc.communicate() |
73 if re.search(re.escape('????????????\tno permissions'), stdout) != None: | 71 if re.search(re.escape('????????????\tno permissions'), stdout) != None: |
74 logging.warning( | 72 logging.warning( |
75 ('adb devices reported a permissions error. Consider ' | 73 ('adb devices reported a permissions error. Consider ' |
76 'restarting adb as root:')) | 74 'restarting adb as root:')) |
77 logging.warning(' adb kill-server') | 75 logging.warning(' adb kill-server') |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 logging.warn('chrome_remote_control detected an android device. However,') | 139 logging.warn('chrome_remote_control detected an android device. However,') |
142 logging.warn('Chrome\'s port-forwarder app is not installed on the device.') | 140 logging.warn('Chrome\'s port-forwarder app is not installed on the device.') |
143 logging.warn('To build:') | 141 logging.warn('To build:') |
144 logging.warn(' make -j16 out/$BUILDTYPE/forwarder') | 142 logging.warn(' make -j16 out/$BUILDTYPE/forwarder') |
145 logging.warn('And then install it:') | 143 logging.warn('And then install it:') |
146 logging.warn(' %s', adb_commands.HowToInstallForwarder()) | 144 logging.warn(' %s', adb_commands.HowToInstallForwarder()) |
147 logging.warn('') | 145 logging.warn('') |
148 logging.warn('') | 146 logging.warn('') |
149 return [] | 147 return [] |
150 return possible_browsers | 148 return possible_browsers |
OLD | NEW |