Unverified Commit fb68d074 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Migrate android_studio to null safety (#79504)

parent d5671739
......@@ -13,7 +13,7 @@ import '../base/platform.dart';
import '../base/process.dart';
import '../base/version.dart';
import '../convert.dart';
import '../globals.dart' as globals;
import '../globals_null_migrated.dart' as globals;
import 'android_studio.dart';
// ANDROID_HOME is deprecated.
......
......@@ -4,7 +4,6 @@
// @dart = 2.8
import '../android/android_studio.dart';
import '../base/common.dart';
import '../convert.dart';
import '../features.dart';
......@@ -176,8 +175,8 @@ class ConfigCommand extends FlutterCommand {
}
// Ensure we send any calculated ones, if overrides don't exist.
if (results['android-studio-dir'] == null && androidStudio != null) {
results['android-studio-dir'] = androidStudio.directory;
if (results['android-studio-dir'] == null && globals.androidStudio != null) {
results['android-studio-dir'] = globals.androidStudio.directory;
}
if (results['android-sdk'] == null && globals.androidSdk != null) {
results['android-sdk'] = globals.androidSdk.directory.path;
......
......@@ -5,7 +5,6 @@
// @dart = 2.8
import 'android/android_sdk.dart';
import 'android/android_studio.dart';
import 'android/gradle_utils.dart';
import 'artifacts.dart';
import 'base/bot_detector.dart';
......@@ -52,7 +51,6 @@ CocoaPodsValidator get cocoapodsValidator => context.get<CocoaPodsValidator>();
LocalEngineLocator get localEngineLocator => context.get<LocalEngineLocator>();
AndroidStudio get androidStudio => context.get<AndroidStudio>();
AndroidSdk get androidSdk => context.get<AndroidSdk>();
CocoaPods get cocoaPods => context.get<CocoaPods>();
FlutterVersion get flutterVersion => context.get<FlutterVersion>();
......
......@@ -4,6 +4,7 @@
import 'package:process/process.dart';
import 'android/android_studio.dart';
import 'base/config.dart';
import 'base/context.dart';
import 'base/error_handling_io.dart';
......@@ -26,6 +27,7 @@ HttpClientFactory get httpClientFactory => context.get<HttpClientFactory>()!;
Logger get logger => context.get<Logger>()!;
OperatingSystemUtils get os => context.get<OperatingSystemUtils>()!;
Signals get signals => context.get<Signals>() ?? LocalSignals.instance;
AndroidStudio? get androidStudio => context.get<AndroidStudio>();
/// Currently active implementation of the file system.
///
......
......@@ -174,6 +174,39 @@ void main() {
PlistParser: () => plistUtils,
});
testUsingContext('finds latest valid install', () {
final String applicationPlistFolder = globals.fs.path.join(
'/',
'Applications',
'Android Studio.app',
'Contents',
);
globals.fs.directory(applicationPlistFolder).createSync(recursive: true);
final String applicationsPlistFilePath = globals.fs.path.join(applicationPlistFolder, 'Info.plist');
plistUtils.fileContents[applicationsPlistFilePath] = macStudioInfoPlist;
final String homeDirectoryPlistFolder = globals.fs.path.join(
globals.fsUtils.homeDirPath,
'Applications',
'Android Studio.app',
'Contents',
);
globals.fs.directory(homeDirectoryPlistFolder).createSync(recursive: true);
final String homeDirectoryPlistFilePath = globals.fs.path.join(homeDirectoryPlistFolder, 'Info.plist');
plistUtils.fileContents[homeDirectoryPlistFilePath] = macStudioInfoPlist4_1;
expect(AndroidStudio.allInstalled().length, 2);
expect(AndroidStudio.latestValid().version, Version(4, 1, 0));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
FileSystemUtils: () => fsUtils,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => platform,
PlistParser: () => plistUtils,
});
testUsingContext('extracts custom paths for directly downloaded Android Studio on Mac', () {
final String studioInApplicationPlistFolder = globals.fs.path.join(
'/',
......
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