Unverified Commit 08e3ed9e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] prevent creation of android devices if adb is not located (#65184)

More work to prevent current #2 crash issue on stable. If adb is not located do not list/create android devices.
parent 33c619c9
......@@ -58,13 +58,18 @@ class AndroidWorkflow implements Workflow {
bool get appliesToHostPlatform => _featureFlags.isAndroidEnabled;
@override
bool get canListDevices => _androidSdk != null && _androidSdk.adbPath != null;
bool get canListDevices => _androidSdk != null
&& _androidSdk.adbPath != null;
@override
bool get canLaunchDevices => _androidSdk != null && _androidSdk.validateSdkWellFormed().isEmpty;
bool get canLaunchDevices => _androidSdk != null
&& _androidSdk.adbPath != null
&& _androidSdk.validateSdkWellFormed().isEmpty;
@override
bool get canListEmulators => _androidSdk != null && _androidSdk.emulatorPath != null;
bool get canListEmulators => _androidSdk != null
&& _androidSdk.adbPath != null
&& _androidSdk.emulatorPath != null;
}
class AndroidValidator extends DoctorValidator {
......
......@@ -68,6 +68,20 @@ void main() {
expect(androidWorkflow.canListEmulators, false);
});
testWithoutContext('AndroidWorkflow handles a null adb', () {
final MockAndroidSdk androidSdk = MockAndroidSdk();
when(androidSdk.adbPath).thenReturn(null);
final AndroidWorkflow androidWorkflow = AndroidWorkflow(
featureFlags: TestFeatureFlags(),
androidSdk: androidSdk,
);
expect(androidWorkflow.canLaunchDevices, false);
expect(androidWorkflow.canListDevices, false);
expect(androidWorkflow.canListEmulators, false);
});
testUsingContext('licensesAccepted returns LicensesAccepted.unknown if cannot find sdkmanager', () async {
processManager.canRunSucceeds = false;
when(sdk.sdkManagerPath).thenReturn('/foo/bar/sdkmanager');
......
......@@ -58,6 +58,7 @@ void main() {
when(mockSdk.avdManagerPath).thenReturn('avdmanager');
when(mockSdk.getAvdManagerPath()).thenReturn('avdmanager');
when(mockSdk.emulatorPath).thenReturn('emulator');
when(mockSdk.adbPath).thenReturn('adb');
});
group('EmulatorManager', () {
......
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