Commit bad957d4 authored by Dan Rubel's avatar Dan Rubel Committed by GitHub

remove unused methods (#5837)

cleanup https://github.com/flutter/flutter/issues/5789
parent 157ffaac
......@@ -19,8 +19,6 @@ class Adb {
final String adbPath;
final Map<String, String> _idToNameCache = <String, String>{};
bool exists() {
try {
runCheckedSync(<String>[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<List<AdbDevice>> trackDevices() {
StreamController<List<AdbDevice>> controller;
Socket socket;
bool isFirstNotification = true;
controller = new StreamController<List<AdbDevice>>(
onListen: () async {
socket = await Socket.connect(InternetAddress.LOOPBACK_IP_V4, adbServerPort);
printTrace('--> host:track-devices');
socket.add(_createAdbRequest('host:track-devices'));
socket.listen((List<int> 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(<AdbDevice>[]);
} else {
List<AdbDevice> 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<Null> _populateDeviceNames(List<AdbDevice> 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<Null> _populateDeviceCache() async {
List<AdbDevice> devices = await listDevices();
for (AdbDevice device in devices)
_idToNameCache[device.id] = device.modelID;
}
Future<String> _sendAdbServerCommand(String command) async {
Socket socket = await Socket.connect(InternetAddress.LOOPBACK_IP_V4, adbServerPort);
......
......@@ -222,56 +222,6 @@ class SimControl {
return getDevices().where((SimDevice device) => device.isBooted).toList();
}
StreamController<List<SimDevice>> _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<List<SimDevice>> trackDevices() {
if (_trackDevicesControler == null) {
Timer timer;
Set<String> deviceIds = new Set<String>();
_trackDevicesControler = new StreamController<List<SimDevice>>.broadcast(
onListen: () {
timer = new Timer.periodic(new Duration(seconds: 4), (Timer timer) {
List<SimDevice> 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<SimDevice> devices, Set<String> deviceIds) {
Set<String> newIds = new Set<String>.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) {
......
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