Commit cc5d1adc authored by Devon Carew's avatar Devon Carew

handle an exit code from android n (#3914)

* handle an exit code from android n

* review comments
parent 15decfca
...@@ -54,13 +54,19 @@ class AndroidDevice extends Device { ...@@ -54,13 +54,19 @@ class AndroidDevice extends Device {
String _getProperty(String name) { String _getProperty(String name) {
if (_properties == null) { if (_properties == null) {
_properties = <String, String>{};
try {
String getpropOutput = runCheckedSync(adbCommandForDevice(<String>['shell', 'getprop'])); String getpropOutput = runCheckedSync(adbCommandForDevice(<String>['shell', 'getprop']));
RegExp propertyExp = new RegExp(r'\[(.*?)\]: \[(.*?)\]'); RegExp propertyExp = new RegExp(r'\[(.*?)\]: \[(.*?)\]');
_properties = <String, String>{}; for (Match m in propertyExp.allMatches(getpropOutput))
for (Match m in propertyExp.allMatches(getpropOutput)) {
_properties[m.group(1)] = m.group(2); _properties[m.group(1)] = m.group(2);
} catch (error, trace) {
printError('Error retrieving device properties: $error');
printTrace(trace.toString());
} }
} }
return _properties[name]; return _properties[name];
} }
......
...@@ -6,6 +6,8 @@ import 'dart:async'; ...@@ -6,6 +6,8 @@ import 'dart:async';
final AppContext _defaultContext = new AppContext(); final AppContext _defaultContext = new AppContext();
typedef void ErrorHandler(dynamic error);
/// A singleton for application functionality. This singleton can be different /// A singleton for application functionality. This singleton can be different
/// on a per-Zone basis. /// on a per-Zone basis.
AppContext get context { AppContext get context {
...@@ -56,7 +58,11 @@ class AppContext { ...@@ -56,7 +58,11 @@ class AppContext {
} }
} }
dynamic runInZone(dynamic method()) { dynamic runInZone(dynamic method(), { ErrorHandler onError }) {
return runZoned(method, zoneValues: <String, dynamic>{'context': this}); return runZoned(
method,
zoneValues: <String, dynamic>{ 'context': this },
onError: onError
);
} }
} }
...@@ -64,7 +64,7 @@ class DaemonCommand extends FlutterCommand { ...@@ -64,7 +64,7 @@ class DaemonCommand extends FlutterCommand {
}, daemonCommand: this, notifyingLogger: notifyingLogger); }, daemonCommand: this, notifyingLogger: notifyingLogger);
return daemon.onExit; return daemon.onExit;
}); }, onError: _handleError);
} }
dynamic _jsonEncodeObject(dynamic object) { dynamic _jsonEncodeObject(dynamic object) {
...@@ -72,6 +72,10 @@ class DaemonCommand extends FlutterCommand { ...@@ -72,6 +72,10 @@ class DaemonCommand extends FlutterCommand {
return _deviceToMap(object); return _deviceToMap(object);
return object; return object;
} }
void _handleError(dynamic error) {
printError('Error from flutter daemon: $error');
}
} }
typedef void DispatchComand(Map<String, dynamic> command); typedef void DispatchComand(Map<String, dynamic> command);
......
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