Commit 4112f663 authored by Devon Carew's avatar Devon Carew

Merge pull request #52 from devoncarew/older_android

support older android devices (>= 17)
parents 9bc6e686 3b9862a5
...@@ -58,7 +58,7 @@ class MojoClient { ...@@ -58,7 +58,7 @@ class MojoClient {
} }
Future<Uint8List> readBytes(url, {Map<String, String> headers}) { Future<Uint8List> readBytes(url, {Map<String, String> headers}) {
return get(url, headers: headers).then((response) { return get(url, headers: headers).then((Response response) {
_checkResponseSuccess(url, response); _checkResponseSuccess(url, response);
return response.bodyBytes; return response.bodyBytes;
}); });
......
...@@ -533,16 +533,20 @@ class AndroidDevice extends Device { ...@@ -533,16 +533,20 @@ class AndroidDevice extends Device {
/// we don't have to rely on the test setup having adb available to it. /// we don't have to rely on the test setup having adb available to it.
static List<AndroidDevice> getAttachedDevices([AndroidDevice mockAndroid]) { static List<AndroidDevice> getAttachedDevices([AndroidDevice mockAndroid]) {
List<AndroidDevice> devices = []; List<AndroidDevice> devices = [];
String adbPath = String adbPath = (mockAndroid != null) ? mockAndroid.adbPath : _getAdbPath();
(mockAndroid != null) ? mockAndroid.adbPath : _getAdbPath(); List<String> output = runSync([adbPath, 'devices', '-l']).trim().split('\n');
List<String> output =
runSync([adbPath, 'devices', '-l']).trim().split('\n'); // 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
RegExp deviceInfo = new RegExp( RegExp deviceRegex1 = new RegExp(
r'^(\S+)\s+device\s+\S+\s+product:(\S+)\s+model:(\S+)\s+device:(\S+)$'); r'^(\S+)\s+device\s+\S+\s+product:(\S+)\s+model:(\S+)\s+device:(\S+)$');
// 0149947A0D01500C device usb:340787200X
RegExp deviceRegex2 = new RegExp(r'^(\S+)\s+device\s+\S+$');
// Skip first line, which is always 'List of devices attached'. // Skip first line, which is always 'List of devices attached'.
for (String line in output.skip(1)) { for (String line in output.skip(1)) {
Match match = deviceInfo.firstMatch(line); if (deviceRegex1.hasMatch(line)) {
if (match != null) { Match match = deviceRegex1.firstMatch(line);
String deviceID = match[1]; String deviceID = match[1];
String productID = match[2]; String productID = match[2];
String modelID = match[3]; String modelID = match[3];
...@@ -552,7 +556,12 @@ class AndroidDevice extends Device { ...@@ -552,7 +556,12 @@ class AndroidDevice extends Device {
id: deviceID, id: deviceID,
productID: productID, productID: productID,
modelID: modelID, modelID: modelID,
deviceCodeName: deviceCodeName)); deviceCodeName: deviceCodeName
));
} else if (deviceRegex2.hasMatch(line)) {
Match match = deviceRegex2.firstMatch(line);
String deviceID = match[1];
devices.add(new AndroidDevice(id: deviceID));
} else { } else {
_logging.warning('Unexpected failure parsing device information ' _logging.warning('Unexpected failure parsing device information '
'from adb output:\n$line\n' 'from adb output:\n$line\n'
...@@ -676,9 +685,9 @@ class AndroidDevice extends Device { ...@@ -676,9 +685,9 @@ class AndroidDevice extends Device {
_logging.severe('Unexpected response from getprop: "$sdkVersion"'); _logging.severe('Unexpected response from getprop: "$sdkVersion"');
return false; return false;
} }
if (sdkVersionParsed < 19) { if (sdkVersionParsed < 16) {
_logging.severe('Version "$sdkVersion" of the Android SDK is too old. ' _logging.severe('The Android version ($sdkVersion) on the target device '
'Please install Jelly Bean (version 19) or later.'); 'is too old. Please use a Jelly Bean (version 16 / 4.1.x) device or later.');
return false; return false;
} }
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment