diff --git a/packages/flutter_tools/lib/src/android/adb.dart b/packages/flutter_tools/lib/src/android/adb.dart index bc4641dddbb..214845907fe 100644 --- a/packages/flutter_tools/lib/src/android/adb.dart +++ b/packages/flutter_tools/lib/src/android/adb.dart @@ -19,8 +19,6 @@ class Adb { final String adbPath; - final Map _idToNameCache = {}; - bool exists() { try { runCheckedSync([adbPath, 'version']); @@ -74,73 +72,6 @@ class Adb { ).toList(); } - /// Listen to device activations and deactivations via the adb server's - /// 'track-devices' command. Call cancel on the returned stream to stop - /// listening. - Stream> trackDevices() { - StreamController> controller; - Socket socket; - bool isFirstNotification = true; - - controller = new StreamController>( - onListen: () async { - socket = await Socket.connect(InternetAddress.LOOPBACK_IP_V4, adbServerPort); - printTrace('--> host:track-devices'); - socket.add(_createAdbRequest('host:track-devices')); - socket.listen((List data) async { - String stringResult = new String.fromCharCodes(data); - printTrace('<-- ${stringResult.trim()}'); - _AdbServerResponse response = new _AdbServerResponse( - stringResult, - noStatus: !isFirstNotification - ); - - String devicesText = response.message.trim(); - isFirstNotification = false; - - if (devicesText.isEmpty) { - controller.add([]); - } else { - List devices = devicesText.split('\n').map((String deviceInfo) { - return new AdbDevice(deviceInfo); - }).where((AdbDevice device) { - // Filter unauthorized devices - we can't connect to them. - return !device.isUnauthorized && !device.isOffline; - }).toList(); - - await _populateDeviceNames(devices); - - controller.add(devices); - } - }); - socket.done.then((_) => controller.close()); - }, - onCancel: () => socket?.destroy() - ); - - return controller.stream; - } - - Future _populateDeviceNames(List devices) async { - for (AdbDevice device in devices) { - if (device.modelID == null) { - // If we don't have a name of a device in our cache, call `device -l` to populate it. - if (_idToNameCache[device.id] == null) - await _populateDeviceCache(); - - // Set the device name from the cached name. Adb device notifications only - // have IDs, not names. We get the name by calling `listDevices()`. - device.modelID = _idToNameCache[device.id]; - } - } - } - - Future _populateDeviceCache() async { - List devices = await listDevices(); - for (AdbDevice device in devices) - _idToNameCache[device.id] = device.modelID; - } - Future _sendAdbServerCommand(String command) async { Socket socket = await Socket.connect(InternetAddress.LOOPBACK_IP_V4, adbServerPort); diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index 0acec8f16b5..981cc3da988 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -222,56 +222,6 @@ class SimControl { return getDevices().where((SimDevice device) => device.isBooted).toList(); } - StreamController> _trackDevicesControler; - - /// Listens to changes in the set of connected devices. The implementation - /// currently uses polling. Callers should be careful to call cancel() on any - /// stream subscription when finished. - /// - /// TODO(devoncarew): We could investigate using the usbmuxd protocol directly. - Stream> trackDevices() { - if (_trackDevicesControler == null) { - Timer timer; - Set deviceIds = new Set(); - _trackDevicesControler = new StreamController>.broadcast( - onListen: () { - timer = new Timer.periodic(new Duration(seconds: 4), (Timer timer) { - List devices = getConnectedDevices(); - if (_updateDeviceIds(devices, deviceIds)) - _trackDevicesControler.add(devices); - }); - }, onCancel: () { - timer?.cancel(); - deviceIds.clear(); - } - ); - } - - return _trackDevicesControler.stream; - } - - /// Update the cached set of device IDs and return whether there were any changes. - bool _updateDeviceIds(List devices, Set deviceIds) { - Set newIds = new Set.from(devices.map((SimDevice device) => device.udid)); - - bool changed = false; - - for (String id in newIds) { - if (!deviceIds.contains(id)) - changed = true; - } - - for (String id in deviceIds) { - if (!newIds.contains(id)) - changed = true; - } - - deviceIds.clear(); - deviceIds.addAll(newIds); - - return changed; - } - bool _isAnyConnected() => getConnectedDevices().isNotEmpty; bool isInstalled(String appId) {