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

Unified Diff: dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/mobile/AndroidDebugBridge.java

Issue 321583008: Merge to trunk cl - fixes/features for mobile support in the editor (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 6 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 | « no previous file | dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/mobile/AndroidDevice.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/mobile/AndroidDebugBridge.java
===================================================================
--- dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/mobile/AndroidDebugBridge.java (revision 37106)
+++ dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/mobile/AndroidDebugBridge.java (working copy)
@@ -35,6 +35,9 @@
private static String[] INSTALL_CMD = new String[] {"install"};
private static String[] DEVICES_CMD = new String[] {"devices"};
+ private static final String DEVICE_CONNECTED_SUFFIX = "\tdevice";
+ private static final String UNAUTHORIZED_SUFFIX = "\tunauthorized";
+
private static String[] LAUNCH_URL_IN_CC_CMD = new String[] {
"shell", "am", "start", "-n", "org.chromium.content_shell_apk/.ContentShellActivity", "-d"};
@@ -75,13 +78,15 @@
/**
* Gets the first device connected and detected by adb
*
- * @return the device id or {@code null} if no device detected
+ * @return the device or {@code null} if no device detected
*/
- public String getConnectedDevice() {
+ public AndroidDevice getConnectedDevice() {
List<String> args = buildAdbCommand(DEVICES_CMD);
if (runAdb(args)) {
//List of devices attached
//04f5385f95d80610 device
+ //T062873654 unauthorized
+ String unauthorized = null;
LineNumberReader reader = new LineNumberReader(new StringReader(runner.getStdOut()));
try {
while (true) {
@@ -90,13 +95,20 @@
break;
}
line = line.trim();
- if (line.endsWith("\tdevice")) {
- return line.substring(0, line.length() - 7).trim();
+ if (line.endsWith(DEVICE_CONNECTED_SUFFIX)) {
+ String id = line.substring(0, line.length() - DEVICE_CONNECTED_SUFFIX.length()).trim();
+ return new AndroidDevice(id, true);
}
+ if (line.endsWith(UNAUTHORIZED_SUFFIX)) {
+ unauthorized = line.substring(0, line.length() - UNAUTHORIZED_SUFFIX.length()).trim();
+ }
}
} catch (IOException e) {
//$FALL-THROUGH$
}
+ if (unauthorized != null) {
+ return new AndroidDevice(unauthorized, false);
+ }
}
return null;
}
@@ -135,6 +147,14 @@
}
/**
+ * Determine if a mobile device is connected and authorized.
+ */
+ public boolean isDeviceConnectedAndAuthorized() {
+ AndroidDevice device = getConnectedDevice();
+ return device != null && device.isAuthorized();
+ }
+
+ /**
* Open the url in the chrome browser on the device
* <p>
* adb shell am start com.android.chrome/com.google.android.apps.chrome.Main -d url
@@ -246,5 +266,4 @@
}
return exitCode == 0 ? true : false;
}
-
}
« no previous file with comments | « no previous file | dart/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/mobile/AndroidDevice.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698