Extract all libimobiledevice invocations to IMobileDevice class (#10793)
Moves all remaining calls to tools that are part of the libimobiledevice
suite of tools to the IMobileDevice class. This allows for better
tracking of this dependency, and easier mocking in tests.
diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart
index 106174c..bb3eca7 100644
--- a/packages/flutter_tools/lib/src/ios/devices.dart
+++ b/packages/flutter_tools/lib/src/ios/devices.dart
@@ -43,8 +43,6 @@
IOSDevice(String id, { this.name }) : super(id) {
_installerPath = _checkForCommand('ideviceinstaller');
_iproxyPath = _checkForCommand('iproxy');
- _loggerPath = _checkForCommand('idevicesyslog');
- _screenshotPath = _checkForCommand('idevicescreenshot');
_pusherPath = _checkForCommand(
'ios-deploy',
'To copy files to iOS devices, please install ios-deploy. To install, run:\n'
@@ -55,8 +53,6 @@
String _installerPath;
String _iproxyPath;
- String _loggerPath;
- String _screenshotPath;
String _pusherPath;
@override
@@ -335,12 +331,10 @@
}
@override
- bool get supportsScreenshot => _screenshotPath != null && _screenshotPath.isNotEmpty;
+ bool get supportsScreenshot => iMobileDevice.isInstalled;
@override
- Future<Null> takeScreenshot(File outputFile) {
- return runCheckedAsync(<String>[_screenshotPath, outputFile.path]);
- }
+ Future<Null> takeScreenshot(File outputFile) => iMobileDevice.takeScreenshot(outputFile);
}
class _IOSDeviceLogReader extends DeviceLogReader {
@@ -372,7 +366,7 @@
String get name => device.name;
void _start() {
- runCommand(<String>[device._loggerPath]).then<Null>((Process process) {
+ iMobileDevice.startLogger().then<Null>((Process process) {
_process = process;
_process.stdout.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
_process.stderr.transform(UTF8.decoder).transform(const LineSplitter()).listen(_onLine);
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart
index a646650..7d1bfa6 100644
--- a/packages/flutter_tools/lib/src/ios/mac.dart
+++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -84,6 +84,14 @@
String getInfoForDevice(String deviceID, String key) {
return runSync(<String>['ideviceinfo', '-k', key, '-u', deviceID]).trim();
}
+
+ /// Starts `idevicesyslog` and returns the running process.
+ Future<Process> startLogger() => runCommand(<String>['idevicesyslog']);
+
+ /// Captures a screenshot to the specified outputfile.
+ Future<Null> takeScreenshot(File outputFile) {
+ return runCheckedAsync(<String>['idevicescreenshot', outputFile.path]);
+ }
}
class Xcode {