Skip to content

Commit 354f42f

Browse files
Collect HCPP adoption analytics for flutter run/build apk/build appbundle (flutter#184225)
Fixes flutter#184127 Leaves the add-to-app case unresolved for now, tracked in flutter#184541 --------- Co-authored-by: Gray Mackall <mackall@google.com>
1 parent d5c5d7a commit 354f42f

12 files changed

Lines changed: 100 additions & 43 deletions

File tree

dev/integration_tests/widget_preview_scaffold/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ dependencies:
2020
stack_trace: 1.12.1
2121
url_launcher: 6.3.2
2222

23-
async: 2.13.0
23+
async: 2.13.1
2424
boolean_selector: 2.1.2
2525
characters: 1.4.1
2626
clock: 1.1.2
@@ -45,8 +45,8 @@ dependencies:
4545
term_glyph: 1.2.2
4646
test_api: 0.7.11
4747
typed_data: 1.4.0
48-
unified_analytics: 8.0.12
49-
url_launcher_android: 6.3.28
48+
unified_analytics: 8.0.14
49+
url_launcher_android: 6.3.29
5050
url_launcher_ios: 6.4.1
5151
url_launcher_linux: 3.2.2
5252
url_launcher_macos: 3.2.5
@@ -68,4 +68,4 @@ dev_dependencies:
6868

6969
flutter:
7070
uses-material-design: true
71-
# PUBSPEC CHECKSUM: 18ep1m
71+
# PUBSPEC CHECKSUM: ciq2fr

packages/flutter_tools/lib/src/commands/build_aar.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class BuildAarCommand extends BuildSubCommand {
8787
commandHasTerminal: hasTerminal,
8888
buildAarProjectType: projectType,
8989
buildAarTargetPlatform: stringsArg('target-platform').join(','),
90+
// TODO(gmackall): Consider collecting hcpp analytics, see https://github.com/flutter/flutter/issues/184541.
9091
);
9192
}
9293

packages/flutter_tools/lib/src/commands/build_apk.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class BuildApkCommand extends BuildSubCommand {
110110
buildApkTargetPlatform: _targetArchs.join(','),
111111
buildApkBuildMode: _buildMode.cliName,
112112
buildApkSplitPerAbi: boolArg('split-per-abi'),
113+
buildApkEnableHcpp: FlutterProject.current().android.computeHcppEnabled(),
113114
);
114115
}
115116

packages/flutter_tools/lib/src/commands/build_appbundle.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class BuildAppBundleCommand extends BuildSubCommand {
109109
commandHasTerminal: hasTerminal,
110110
buildAppBundleTargetPlatform: stringsArg('target-platform').join(','),
111111
buildAppBundleBuildMode: buildMode,
112+
buildBundleEnableHcpp: FlutterProject.current().android.computeHcppEnabled(),
112113
);
113114
}
114115

packages/flutter_tools/lib/src/commands/run.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ class RunCommand extends RunCommandBase {
571571
runEnableImpeller: record.runEnableImpeller,
572572
runIOSInterfaceType: record.runIOSInterfaceType,
573573
runIsTest: record.runIsTest,
574+
runEnableHcpp: record.runEnableHcpp,
574575
);
575576
}
576577

@@ -651,6 +652,7 @@ class RunCommand extends RunCommandBase {
651652
runEnableImpeller: enableImpeller.asBool,
652653
runIOSInterfaceType: iOSInterfaceType,
653654
runIsTest: targetFile.endsWith('_test.dart'),
655+
runEnableHcpp: enableHcpp,
654656
);
655657
})();
656658

@@ -981,4 +983,5 @@ typedef AnalyticsUsageValuesRecord = ({
981983
bool runProjectModule,
982984
String runTargetName,
983985
String runTargetOsVersion,
986+
bool? runEnableHcpp,
984987
});

packages/flutter_tools/lib/src/project.dart

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,19 @@ See the link below for more information:
10161016
///
10171017
/// If there is no manifest file, or the key is not present, returns [_impellerEnabledByDefault].
10181018
bool computeImpellerEnabled() {
1019+
return _computeManifestMetadataBoolValue(
1020+
'io.flutter.embedding.android.EnableImpeller',
1021+
_impellerEnabledByDefault,
1022+
);
1023+
}
1024+
1025+
bool computeHcppEnabled() {
1026+
return _computeManifestMetadataBoolValue('io.flutter.embedding.android.EnableHcpp', false);
1027+
}
1028+
1029+
bool _computeManifestMetadataBoolValue(String metadataKey, bool defaultValue) {
10191030
if (!appManifestFile.existsSync()) {
1020-
return _impellerEnabledByDefault;
1031+
return defaultValue;
10211032
}
10221033
final XmlDocument document;
10231034
try {
@@ -1035,17 +1046,20 @@ See the link below for more information:
10351046
}
10361047
for (final XmlElement metaData in document.findAllElements('meta-data')) {
10371048
final String? name = metaData.getAttribute('android:name');
1038-
if (name == 'io.flutter.embedding.android.EnableImpeller') {
1049+
if (name == metadataKey) {
10391050
final String? value = metaData.getAttribute('android:value');
1040-
if (value == 'true') {
1051+
if (value == null) {
1052+
continue;
1053+
}
1054+
if (value.toLowerCase() == 'true') {
10411055
return true;
10421056
}
1043-
if (value == 'false') {
1057+
if (value.toLowerCase() == 'false') {
10441058
return false;
10451059
}
10461060
}
10471061
}
1048-
return _impellerEnabledByDefault;
1062+
return defaultValue;
10491063
}
10501064
}
10511065

packages/flutter_tools/pubspec.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies:
2828
intl: 0.20.2
2929
meta: 1.18.0
3030
multicast_dns: 0.3.3
31-
mustache_template: 2.0.3
31+
mustache_template: 2.0.4
3232
package_config: 2.2.0
3333
process: 5.0.5
3434
fake_async: 1.3.3
@@ -53,12 +53,12 @@ dependencies:
5353
logging: 1.3.0
5454
http_multi_server: 3.2.2
5555
convert: 3.1.2
56-
async: 2.13.0
57-
unified_analytics: 8.0.12
56+
async: 2.13.1
57+
unified_analytics: 8.0.14
5858
pubspec_parse: 1.5.0
5959

6060
graphs: 2.3.2
61-
hooks_runner: 1.1.0
61+
hooks_runner: 1.1.1
6262
hooks: 1.0.2
6363
code_assets: 1.0.0
6464
data_assets: 0.19.6
@@ -80,7 +80,7 @@ dependencies:
8080
boolean_selector: 2.1.2
8181
browser_launcher: 1.1.3
8282
built_collection: 5.1.1
83-
built_value: 8.12.4
83+
built_value: 8.12.5
8484
cli_config: 0.2.0
8585
clock: 1.1.2
8686
csslib: 1.0.2
@@ -128,4 +128,4 @@ dartdoc:
128128
# Exclude this package from the hosted API docs.
129129
nodoc: true
130130

131-
# PUBSPEC CHECKSUM: ma8sc5
131+
# PUBSPEC CHECKSUM: r72vdp

packages/flutter_tools/test/commands.shard/hermetic/run_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ void main() {
428428
runProjectHostLanguage: 'swift',
429429
runIOSInterfaceType: 'usb',
430430
runIsTest: false,
431+
runEnableHcpp: false,
431432
),
432433
),
433434
);
@@ -481,6 +482,7 @@ void main() {
481482
runProjectHostLanguage: 'swift',
482483
runIOSInterfaceType: 'usb',
483484
runIsTest: true,
485+
runEnableHcpp: false,
484486
),
485487
),
486488
);
@@ -787,6 +789,7 @@ void main() {
787789
runProjectModule: false,
788790
runProjectHostLanguage: '',
789791
runIsTest: false,
792+
runEnableHcpp: false,
790793
),
791794
),
792795
);
@@ -837,6 +840,7 @@ void main() {
837840
runProjectHostLanguage: '',
838841
runIOSInterfaceType: 'usb',
839842
runIsTest: false,
843+
runEnableHcpp: false,
840844
),
841845
),
842846
);
@@ -892,6 +896,7 @@ void main() {
892896
runProjectHostLanguage: '',
893897
runIOSInterfaceType: 'wireless',
894898
runIsTest: false,
899+
runEnableHcpp: false,
895900
),
896901
),
897902
);
@@ -948,6 +953,7 @@ void main() {
948953
runProjectHostLanguage: '',
949954
runIOSInterfaceType: 'wireless',
950955
runIsTest: false,
956+
runEnableHcpp: false,
951957
),
952958
),
953959
);

packages/flutter_tools/test/commands.shard/permeable/build_apk_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ void main() {
6767
buildApkTargetPlatform: 'android-arm,android-arm64,android-x64',
6868
buildApkBuildMode: 'release',
6969
buildApkSplitPerAbi: false,
70+
buildApkEnableHcpp: false,
7071
),
7172
),
7273
);
@@ -81,6 +82,7 @@ void main() {
8182
buildApkTargetPlatform: 'android-arm,android-arm64,android-x64',
8283
buildApkBuildMode: 'debug',
8384
buildApkSplitPerAbi: false,
85+
buildApkEnableHcpp: false,
8486
),
8587
),
8688
);
@@ -95,6 +97,7 @@ void main() {
9597
buildApkTargetPlatform: 'android-arm,android-arm64,android-x64',
9698
buildApkBuildMode: 'jit_release',
9799
buildApkSplitPerAbi: false,
100+
buildApkEnableHcpp: false,
98101
),
99102
),
100103
);
@@ -109,6 +112,7 @@ void main() {
109112
buildApkTargetPlatform: 'android-arm,android-arm64,android-x64',
110113
buildApkBuildMode: 'profile',
111114
buildApkSplitPerAbi: false,
115+
buildApkEnableHcpp: false,
112116
),
113117
),
114118
);
@@ -123,6 +127,7 @@ void main() {
123127
buildApkTargetPlatform: 'android-arm,android-arm64,android-x64',
124128
buildApkBuildMode: 'release',
125129
buildApkSplitPerAbi: false,
130+
buildApkEnableHcpp: false,
126131
),
127132
),
128133
);
@@ -152,6 +157,7 @@ void main() {
152157
buildApkTargetPlatform: 'android-arm',
153158
buildApkBuildMode: 'release',
154159
buildApkSplitPerAbi: false,
160+
buildApkEnableHcpp: false,
155161
),
156162
),
157163
);
@@ -169,6 +175,7 @@ void main() {
169175
buildApkTargetPlatform: 'android-arm',
170176
buildApkBuildMode: 'debug',
171177
buildApkSplitPerAbi: false,
178+
buildApkEnableHcpp: false,
172179
),
173180
),
174181
);
@@ -186,6 +193,7 @@ void main() {
186193
buildApkTargetPlatform: 'android-arm',
187194
buildApkBuildMode: 'release',
188195
buildApkSplitPerAbi: false,
196+
buildApkEnableHcpp: false,
189197
),
190198
),
191199
);
@@ -203,6 +211,7 @@ void main() {
203211
buildApkTargetPlatform: 'android-arm',
204212
buildApkBuildMode: 'profile',
205213
buildApkSplitPerAbi: false,
214+
buildApkEnableHcpp: false,
206215
),
207216
),
208217
);
@@ -220,6 +229,7 @@ void main() {
220229
buildApkTargetPlatform: 'android-arm',
221230
buildApkBuildMode: 'jit_release',
222231
buildApkSplitPerAbi: false,
232+
buildApkEnableHcpp: false,
223233
),
224234
),
225235
);

packages/flutter_tools/test/commands.shard/permeable/build_appbundle_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void main() {
6363
commandHasTerminal: false,
6464
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
6565
buildAppBundleBuildMode: 'release',
66+
buildBundleEnableHcpp: false,
6667
),
6768
),
6869
);
@@ -95,6 +96,7 @@ void main() {
9596
commandHasTerminal: false,
9697
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
9798
buildAppBundleBuildMode: 'release',
99+
buildBundleEnableHcpp: false,
98100
),
99101
),
100102
);
@@ -109,6 +111,7 @@ void main() {
109111
commandHasTerminal: false,
110112
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
111113
buildAppBundleBuildMode: 'release',
114+
buildBundleEnableHcpp: false,
112115
),
113116
),
114117
);
@@ -123,6 +126,7 @@ void main() {
123126
commandHasTerminal: false,
124127
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
125128
buildAppBundleBuildMode: 'debug',
129+
buildBundleEnableHcpp: false,
126130
),
127131
),
128132
);
@@ -138,6 +142,7 @@ void main() {
138142
commandHasTerminal: false,
139143
buildAppBundleTargetPlatform: 'android-arm,android-arm64,android-x64',
140144
buildAppBundleBuildMode: 'profile',
145+
buildBundleEnableHcpp: false,
141146
),
142147
),
143148
);

0 commit comments

Comments
 (0)