Skip to content

Commit

Permalink
[tool] Remove some usages of deprecated usage package (#151359)
Browse files Browse the repository at this point in the history
Partially addresses flutter/flutter#150575 and flutter/flutter#150665

Will require a g3fix.
  • Loading branch information
andrewkolos authored Jul 9, 2024
1 parent 5ebc993 commit 5103d75
Show file tree
Hide file tree
Showing 26 changed files with 183 additions and 381 deletions.
3 changes: 1 addition & 2 deletions dev/bots/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,8 @@ Future<void> verifyNoTestImports(String workingDirectory) async {
}
// Fail if any errors
if (errors.isNotEmpty) {
final String s = errors.length == 1 ? '' : 's';
foundError(<String>[
'${bold}The following file$s import a test directly. Test utilities should be in their own file.$reset',
'${bold}The following file(s) import a test directly. Test utilities should be in their own file.$reset',
...errors,
]);
}
Expand Down
40 changes: 10 additions & 30 deletions packages/flutter_tools/lib/src/android/gradle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import '../convert.dart';
import '../flutter_manifest.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'android_builder.dart';
import 'android_studio.dart';
import 'gradle_errors.dart';
Expand Down Expand Up @@ -149,7 +148,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
required ProcessManager processManager,
required FileSystem fileSystem,
required Artifacts artifacts,
required Usage usage,
required Analytics analytics,
required GradleUtils gradleUtils,
required Platform platform,
Expand All @@ -158,7 +156,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
_logger = logger,
_fileSystem = fileSystem,
_artifacts = artifacts,
_usage = usage,
_analytics = analytics,
_gradleUtils = gradleUtils,
_androidStudio = androidStudio,
Expand All @@ -170,7 +167,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
final ProcessUtils _processUtils;
final FileSystem _fileSystem;
final Artifacts _artifacts;
final Usage _usage;
final Analytics _analytics;
final GradleUtils _gradleUtils;
final FileSystemUtils _fileSystemUtils;
Expand Down Expand Up @@ -304,7 +300,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
@visibleForTesting int? maxRetries,
}) async {
if (!project.android.isSupportedVersion) {
_exitWithUnsupportedProjectMessage(_usage, _logger.terminal, analytics: _analytics);
_exitWithUnsupportedProjectMessage(_logger.terminal, _analytics);
}

final List<ProjectMigrator> migrators = <ProjectMigrator>[
Expand All @@ -322,10 +318,8 @@ class AndroidGradleBuilder implements AndroidBuilder {

final bool usesAndroidX = isAppUsingAndroidX(project.android.hostAppGradleRoot);
if (usesAndroidX) {
BuildEvent('app-using-android-x', type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: 'app-using-android-x', buildType: 'gradle'));
} else if (!usesAndroidX) {
BuildEvent('app-not-using-android-x', type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: 'app-not-using-android-x', buildType: 'gradle'));

_logger.printStatus("${_logger.terminal.warningMark} Your app isn't using AndroidX.", emphasis: true);
Expand Down Expand Up @@ -485,7 +479,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
}

final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('build', 'gradle', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'build',
variableName: 'gradle',
Expand All @@ -494,7 +487,6 @@ class AndroidGradleBuilder implements AndroidBuilder {

if (exitCode != 0) {
if (detectedGradleError == null) {
BuildEvent('gradle-unknown-failure', type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: 'gradle-unknown-failure', buildType: 'gradle'));

throwToolExit(
Expand Down Expand Up @@ -529,7 +521,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
);
final String successEventLabel = 'gradle-${detectedGradleError!.eventLabel}-success';

BuildEvent(successEventLabel, type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: successEventLabel, buildType: 'gradle'));

return;
Expand All @@ -538,7 +529,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
}
}
final String usageLabel = 'gradle-${detectedGradleError?.eventLabel}-failure';
BuildEvent(usageLabel, type: 'gradle', flutterUsage: _usage).send();
_analytics.send(Event.flutterBuildInfo(label: usageLabel, buildType: 'gradle'));

throwToolExit(
Expand All @@ -548,7 +538,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
}

if (isBuildingBundle) {
final File bundleFile = findBundleFile(project, buildInfo, _logger, _usage, _analytics);
final File bundleFile = findBundleFile(project, buildInfo, _logger, _analytics);
final String appSize = (buildInfo.mode == BuildMode.debug)
? '' // Don't display the size when building a debug variant.
: ' (${getSizeAsPlatformMB(bundleFile.lengthSync())})';
Expand All @@ -566,7 +556,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
}
// Gradle produced APKs.
final Iterable<String> apkFilesPaths = project.isModule
? findApkFilesModule(project, androidBuildInfo, _logger, _usage, _analytics)
? findApkFilesModule(project, androidBuildInfo, _logger, _analytics)
: listApkPaths(androidBuildInfo);
final Directory apkDirectory = getApkDirectory(project);

Expand All @@ -577,7 +567,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
project: project,
fileExtension: '.apk',
logger: _logger,
usage: _usage,
analytics: _analytics,
);
}
Expand Down Expand Up @@ -608,7 +597,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
final SizeAnalyzer sizeAnalyzer = SizeAnalyzer(
fileSystem: _fileSystem,
logger: _logger,
flutterUsage: _usage,
analytics: _analytics,
);
final String archName = androidBuildInfo.targetArchs.single.archName;
Expand Down Expand Up @@ -759,7 +747,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
status.stop();
}
final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('build', 'gradle-aar', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'build',
variableName: 'gradle-aar',
Expand Down Expand Up @@ -801,7 +788,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
);

final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('print', 'android build variants', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'print',
variableName: 'android build variants',
Expand Down Expand Up @@ -840,7 +826,6 @@ class AndroidGradleBuilder implements AndroidBuilder {
project: project,
);
final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('outputs', 'app link settings', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'outputs',
variableName: 'app link settings',
Expand Down Expand Up @@ -927,8 +912,7 @@ String _calculateSha(File file) {
return _hex(sha1.convert(bytes).bytes);
}

void _exitWithUnsupportedProjectMessage(Usage usage, Terminal terminal, {required Analytics analytics}) {
BuildEvent('unsupported-project', type: 'gradle', eventError: 'gradle-plugin', flutterUsage: usage).send();
void _exitWithUnsupportedProjectMessage(Terminal terminal, Analytics analytics) {
analytics.send(Event.flutterBuildInfo(
label: 'unsupported-project',
buildType: 'gradle',
Expand Down Expand Up @@ -959,7 +943,6 @@ Iterable<String> findApkFilesModule(
FlutterProject project,
AndroidBuildInfo androidBuildInfo,
Logger logger,
Usage usage,
Analytics analytics,
) {
final Iterable<String> apkFileNames = _apkFilesFor(androidBuildInfo);
Expand Down Expand Up @@ -995,7 +978,6 @@ Iterable<String> findApkFilesModule(
project: project,
fileExtension: '.apk',
logger: logger,
usage: usage,
analytics: analytics,
);
}
Expand Down Expand Up @@ -1035,7 +1017,12 @@ Iterable<String> listApkPaths(
}

@visibleForTesting
File findBundleFile(FlutterProject project, BuildInfo buildInfo, Logger logger, Usage usage, Analytics analytics) {
File findBundleFile(
FlutterProject project,
BuildInfo buildInfo,
Logger logger,
Analytics analytics,
) {
final List<File> fileCandidates = <File>[
getBundleDirectory(project)
.childDirectory(camelCase(buildInfo.modeName))
Expand Down Expand Up @@ -1091,7 +1078,6 @@ File findBundleFile(FlutterProject project, BuildInfo buildInfo, Logger logger,
project: project,
fileExtension: '.aab',
logger: logger,
usage: usage,
analytics: analytics,
);
}
Expand All @@ -1101,7 +1087,6 @@ Never _exitWithExpectedFileNotFound({
required FlutterProject project,
required String fileExtension,
required Logger logger,
required Usage usage,
required Analytics analytics,
}) {

Expand All @@ -1110,11 +1095,6 @@ Never _exitWithExpectedFileNotFound({
final String gradleBuildSettings = 'androidGradlePluginVersion: $androidGradlePluginVersion, '
'fileExtension: $fileExtension';

BuildEvent('gradle-expected-file-not-found',
type: 'gradle',
settings: gradleBuildSettings,
flutterUsage: usage,
).send();
analytics.send(Event.flutterBuildInfo(
label: 'gradle-expected-file-not-found',
buildType: 'gradle',
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/android/gradle_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import '../base/process.dart';
import '../base/terminal.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'gradle_utils.dart';

typedef GradleErrorTest = bool Function(String);
Expand Down
6 changes: 0 additions & 6 deletions packages/flutter_tools/lib/src/android/gradle_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import '../build_info.dart';
import '../cache.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../reporting/reporting.dart';
import 'android_sdk.dart';

// These are the versions used in the project templates.
Expand Down Expand Up @@ -787,11 +786,6 @@ void writeLocalProperties(File properties) {
}

void exitWithNoSdkMessage() {
BuildEvent('unsupported-project',
type: 'gradle',
eventError: 'android-sdk-not-found',
flutterUsage: globals.flutterUsage)
.send();
globals.analytics.send(Event.flutterBuildInfo(
label: 'unsupported-project',
buildType: 'gradle',
Expand Down
14 changes: 4 additions & 10 deletions packages/flutter_tools/lib/src/base/analyze_size.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'package:unified_analytics/unified_analytics.dart';
import 'package:vm_snapshot_analysis/treemap.dart';

import '../convert.dart';
import '../reporting/reporting.dart';
import 'common.dart';
import 'file_system.dart';
import 'logger.dart';
Expand All @@ -20,19 +19,16 @@ class SizeAnalyzer {
SizeAnalyzer({
required FileSystem fileSystem,
required Logger logger,
required Usage flutterUsage,
required Analytics analytics,
Pattern appFilenamePattern = 'libapp.so',
}) : _flutterUsage = flutterUsage,
_analytics = analytics,
_fileSystem = fileSystem,
_logger = logger,
_appFilenamePattern = appFilenamePattern;
}) : _analytics = analytics,
_fileSystem = fileSystem,
_logger = logger,
_appFilenamePattern = appFilenamePattern;

final FileSystem _fileSystem;
final Logger _logger;
final Pattern _appFilenamePattern;
final Usage _flutterUsage;
final Analytics _analytics;
String? _appFilename;

Expand Down Expand Up @@ -91,7 +87,6 @@ class SizeAnalyzer {
);

assert(_appFilename != null);
CodeSizeEvent(type, flutterUsage: _flutterUsage).send();
_analytics.send(Event.codeSizeAnalysis(platform: type));
return apkAnalysisJson;
}
Expand Down Expand Up @@ -145,7 +140,6 @@ class SizeAnalyzer {
aotSnapshotJson: processedAotSnapshotJson,
precompilerTrace: json.decode(precompilerTrace.readAsStringSync()) as Map<String, Object?>? ?? <String, Object?>{},
);
CodeSizeEvent(kind, flutterUsage: _flutterUsage).send();
_analytics.send(Event.codeSizeAnalysis(platform: kind));
return apkAnalysisJson;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter_tools/lib/src/commands/build_ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,6 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
result,
analytics: globals.analytics,
fileSystem: globals.fs,
flutterUsage: globals.flutterUsage,
logger: globals.logger,
platform: SupportedPlatform.ios,
project: app.project.parent,
Expand All @@ -726,7 +725,6 @@ abstract class _BuildIOSSubCommand extends BuildSubCommand {
final SizeAnalyzer sizeAnalyzer = SizeAnalyzer(
fileSystem: globals.fs,
logger: globals.logger,
flutterUsage: globals.flutterUsage,
analytics: analytics,
appFilenamePattern: 'App'
);
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/commands/build_linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class BuildLinuxCommand extends BuildSubCommand {
sizeAnalyzer: SizeAnalyzer(
fileSystem: globals.fs,
logger: logger,
flutterUsage: globals.flutterUsage,
analytics: analytics,
),
needCrossBuild: needCrossBuild,
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/commands/build_macos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class BuildMacosCommand extends BuildSubCommand {
fileSystem: globals.fs,
logger: globals.logger,
appFilenamePattern: 'App',
flutterUsage: globals.flutterUsage,
analytics: analytics,
),
usingCISystem: usingCISystem,
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/commands/build_windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class BuildWindowsCommand extends BuildSubCommand {
fileSystem: globals.fs,
logger: globals.logger,
appFilenamePattern: 'app.so',
flutterUsage: globals.flutterUsage,
analytics: analytics,
),
);
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/context_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ Future<T> runInContext<T>(
processManager: globals.processManager,
fileSystem: globals.fs,
artifacts: globals.artifacts!,
usage: globals.flutterUsage,
analytics: globals.analytics,
gradleUtils: globals.gradleUtils!,
platform: globals.platform,
Expand Down
1 change: 0 additions & 1 deletion packages/flutter_tools/lib/src/ios/devices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ class IOSDevice extends Device {
buildResult,
analytics: globals.analytics,
fileSystem: globals.fs,
flutterUsage: globals.flutterUsage,
logger: globals.logger,
platform: SupportedPlatform.ios,
project: package.project.parent,
Expand Down
12 changes: 1 addition & 11 deletions packages/flutter_tools/lib/src/ios/mac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import '../migrations/xcode_script_build_phase_migration.dart';
import '../migrations/xcode_thin_binary_build_phase_input_paths_migration.dart';
import '../plugins.dart';
import '../project.dart';
import '../reporting/reporting.dart';
import 'application_package.dart';
import 'code_signing.dart';
import 'migrations/host_app_info_plist_migration.dart';
Expand Down Expand Up @@ -155,7 +154,7 @@ Future<XcodeBuildResult> buildXcodeProject({
final FlutterProject project = FlutterProject.current();

final List<ProjectMigrator> migrators = <ProjectMigrator>[
RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.flutterUsage, globals.analytics),
RemoveFrameworkLinkAndEmbeddingMigration(app.project, globals.logger, globals.analytics),
XcodeBuildSystemMigration(app.project, globals.logger),
ProjectBaseConfigurationMigration(app.project, globals.logger),
ProjectBuildLocationMigration(app.project, globals.logger),
Expand Down Expand Up @@ -452,7 +451,6 @@ Future<XcodeBuildResult> buildXcodeProject({
+ getElapsedAsSeconds(sw.elapsed).padLeft(5),
);
final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming(xcodeBuildActionToString(buildAction), 'xcode-ios', elapsedDuration);
globals.analytics.send(Event.timing(
workflow: xcodeBuildActionToString(buildAction),
variableName: 'xcode-ios',
Expand Down Expand Up @@ -625,7 +623,6 @@ Future<void> diagnoseXcodeBuildFailure(
required Analytics analytics,
required Logger logger,
required FileSystem fileSystem,
required Usage flutterUsage,
required SupportedPlatform platform,
required FlutterProject project,
}) async {
Expand All @@ -639,13 +636,6 @@ Future<void> diagnoseXcodeBuildFailure(
final String command = xcodeBuildExecution.buildCommands.toString();
final String settings = xcodeBuildExecution.buildSettings.toString();

BuildEvent(
label,
type: buildType,
command: command,
settings: settings,
flutterUsage: flutterUsage,
).send();
analytics.send(Event.flutterBuildInfo(
label: label,
buildType: buildType,
Expand Down
Loading

0 comments on commit 5103d75

Please sign in to comment.