Only set flutter run usage values for targeted device platforms (#46931)
This commit is contained in:
@@ -228,30 +228,55 @@ class RunCommand extends RunCommandBase {
|
||||
Future<Map<CustomDimensions, String>> get usageValues async {
|
||||
String deviceType, deviceOsVersion;
|
||||
bool isEmulator;
|
||||
bool anyAndroidDevices = false;
|
||||
bool anyIOSDevices = false;
|
||||
|
||||
if (devices == null || devices.isEmpty) {
|
||||
deviceType = 'none';
|
||||
deviceOsVersion = 'none';
|
||||
isEmulator = false;
|
||||
} else if (devices.length == 1) {
|
||||
deviceType = getNameForTargetPlatform(await devices[0].targetPlatform);
|
||||
final TargetPlatform platform = await devices[0].targetPlatform;
|
||||
anyAndroidDevices = platform == TargetPlatform.android;
|
||||
anyIOSDevices = platform == TargetPlatform.ios;
|
||||
deviceType = getNameForTargetPlatform(platform);
|
||||
deviceOsVersion = await devices[0].sdkNameAndVersion;
|
||||
isEmulator = await devices[0].isLocalEmulator;
|
||||
} else {
|
||||
deviceType = 'multiple';
|
||||
deviceOsVersion = 'multiple';
|
||||
isEmulator = false;
|
||||
for (Device device in devices) {
|
||||
final TargetPlatform platform = await device.targetPlatform;
|
||||
anyAndroidDevices = anyAndroidDevices || (platform == TargetPlatform.android);
|
||||
anyIOSDevices = anyIOSDevices || (platform == TargetPlatform.ios);
|
||||
if (anyAndroidDevices && anyIOSDevices) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
final String modeName = getBuildInfo().modeName;
|
||||
final AndroidProject androidProject = FlutterProject.current().android;
|
||||
final IosProject iosProject = FlutterProject.current().ios;
|
||||
final List<String> hostLanguage = <String>[
|
||||
if (androidProject != null && androidProject.existsSync())
|
||||
if (androidProject.isKotlin) 'kotlin' else 'java',
|
||||
if (iosProject != null && iosProject.exists)
|
||||
if (await iosProject.isSwift) 'swift' else 'objc',
|
||||
];
|
||||
|
||||
String androidEmbeddingVersion;
|
||||
final List<String> hostLanguage = <String>[];
|
||||
if (anyAndroidDevices) {
|
||||
final AndroidProject androidProject = FlutterProject.current().android;
|
||||
if (androidProject != null && androidProject.existsSync()) {
|
||||
hostLanguage.add(androidProject.isKotlin ? 'kotlin' : 'java');
|
||||
androidEmbeddingVersion = androidProject.getEmbeddingVersion().toString().split('.').last;
|
||||
}
|
||||
}
|
||||
if (anyIOSDevices) {
|
||||
final IosProject iosProject = FlutterProject.current().ios;
|
||||
if (iosProject != null && iosProject.exists) {
|
||||
final Iterable<File> swiftFiles = iosProject.hostAppRoot
|
||||
.listSync(recursive: true, followLinks: false)
|
||||
.whereType<File>()
|
||||
.where((File file) => fs.path.extension(file.path) == '.swift');
|
||||
hostLanguage.add(swiftFiles.isNotEmpty ? 'swift' : 'objc');
|
||||
}
|
||||
}
|
||||
|
||||
final String modeName = getBuildInfo().modeName;
|
||||
return <CustomDimensions, String>{
|
||||
CustomDimensions.commandRunIsEmulator: '$isEmulator',
|
||||
CustomDimensions.commandRunTargetName: deviceType,
|
||||
@@ -259,7 +284,8 @@ class RunCommand extends RunCommandBase {
|
||||
CustomDimensions.commandRunModeName: modeName,
|
||||
CustomDimensions.commandRunProjectModule: '${FlutterProject.current().isModule}',
|
||||
CustomDimensions.commandRunProjectHostLanguage: hostLanguage.join(','),
|
||||
CustomDimensions.commandRunAndroidEmbeddingVersion: androidProject.getEmbeddingVersion().toString().split('.').last,
|
||||
if (androidEmbeddingVersion != null)
|
||||
CustomDimensions.commandRunAndroidEmbeddingVersion: androidEmbeddingVersion,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject, String buildDir
|
||||
final bool didPodInstall = await cocoaPods.processPods(
|
||||
xcodeProject: xcodeProject,
|
||||
engineDir: flutterFrameworkDir(buildMode),
|
||||
isSwift: await xcodeProject.isSwift,
|
||||
dependenciesChanged: !fingerprinter.doesFingerprintMatch(),
|
||||
);
|
||||
if (didPodInstall) {
|
||||
|
||||
@@ -138,7 +138,6 @@ class CocoaPods {
|
||||
@required XcodeBasedProject xcodeProject,
|
||||
// For backward compatibility with previously created Podfile only.
|
||||
@required String engineDir,
|
||||
bool isSwift = false,
|
||||
bool dependenciesChanged = true,
|
||||
}) async {
|
||||
if (!xcodeProject.podfile.existsSync()) {
|
||||
|
||||
@@ -292,9 +292,6 @@ abstract class XcodeBasedProject {
|
||||
/// The CocoaPods 'Manifest.lock'.
|
||||
File get podManifestLock;
|
||||
|
||||
/// True if the host app project is using Swift.
|
||||
Future<bool> get isSwift;
|
||||
|
||||
/// Directory containing symlinks to pub cache plugins source generated on `pod install`.
|
||||
Directory get symlinks;
|
||||
}
|
||||
@@ -410,10 +407,6 @@ class IosProject implements XcodeBasedProject {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> get isSwift async =>
|
||||
(await buildSettings)?.containsKey('SWIFT_VERSION') ?? false;
|
||||
|
||||
/// The build settings for the host app of this project, as a detached map.
|
||||
///
|
||||
/// Returns null, if iOS tooling is unavailable.
|
||||
@@ -820,9 +813,6 @@ class MacOSProject implements XcodeBasedProject {
|
||||
@override
|
||||
Directory get symlinks => ephemeralDirectory.childDirectory('.symlinks');
|
||||
|
||||
@override
|
||||
Future<bool> get isSwift async => true;
|
||||
|
||||
/// The file where the Xcode build will write the name of the built app.
|
||||
///
|
||||
/// Ideally this will be replaced in the future with inspection of the Runner
|
||||
|
||||
Reference in New Issue
Block a user