[flutter_tools] check if process manager can find adb (#74672)

This commit is contained in:
Jonah Williams
2021-01-25 14:15:23 -08:00
committed by GitHub
parent 6358f481f7
commit efcf2c664e
2 changed files with 34 additions and 2 deletions

View File

@@ -64,7 +64,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
@override
Future<List<Device>> pollingGetDevices({ Duration timeout }) async {
if (_androidSdk == null || _androidSdk.adbPath == null) {
if (_doesNotHaveAdb()) {
return <AndroidDevice>[];
}
String text;
@@ -88,7 +88,7 @@ class AndroidDevices extends PollingDeviceDiscovery {
@override
Future<List<String>> getDiagnostics() async {
if (_androidSdk == null || _androidSdk.adbPath == null) {
if (_doesNotHaveAdb()) {
return <String>[];
}
@@ -104,6 +104,12 @@ class AndroidDevices extends PollingDeviceDiscovery {
return diagnostics;
}
bool _doesNotHaveAdb() {
return _androidSdk == null ||
_androidSdk.adbPath == null ||
!_processManager.canRun(_androidSdk.adbPath);
}
// 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper
static final RegExp _kDeviceRegex = RegExp(r'^(\S+)\s+(\S+)(.*)');