Unverified Commit 0287449c authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Do not show v1 Android embedding message for non-Android commands (#96148)

parent 500a3324
...@@ -552,8 +552,15 @@ class AndroidProject extends FlutterProjectPlatform { ...@@ -552,8 +552,15 @@ class AndroidProject extends FlutterProjectPlatform {
} }
void checkForDeprecation({DeprecationBehavior deprecationBehavior = DeprecationBehavior.none}) { void checkForDeprecation({DeprecationBehavior deprecationBehavior = DeprecationBehavior.none}) {
if (deprecationBehavior == DeprecationBehavior.none) {
return;
}
final AndroidEmbeddingVersionResult result = computeEmbeddingVersion(); final AndroidEmbeddingVersionResult result = computeEmbeddingVersion();
if (result.version == AndroidEmbeddingVersion.v1) { if (result.version != AndroidEmbeddingVersion.v1) {
return;
}
globals.printStatus( globals.printStatus(
''' '''
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
...@@ -573,15 +580,10 @@ The detected reason was: ...@@ -573,15 +580,10 @@ The detected reason was:
${result.reason} ${result.reason}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
''' ''');
); if (deprecationBehavior == DeprecationBehavior.ignore) {
switch (deprecationBehavior) {
case DeprecationBehavior.none:
break;
case DeprecationBehavior.ignore:
BuildEvent('deprecated-v1-android-embedding-ignored', type: 'gradle', flutterUsage: globals.flutterUsage).send(); BuildEvent('deprecated-v1-android-embedding-ignored', type: 'gradle', flutterUsage: globals.flutterUsage).send();
break; } else { // DeprecationBehavior.exit
case DeprecationBehavior.exit:
BuildEvent('deprecated-v1-android-embedding-failed', type: 'gradle', flutterUsage: globals.flutterUsage).send(); BuildEvent('deprecated-v1-android-embedding-failed', type: 'gradle', flutterUsage: globals.flutterUsage).send();
throwToolExit( throwToolExit(
'Build failed due to use of deprecated Android v1 embedding.', 'Build failed due to use of deprecated Android v1 embedding.',
...@@ -589,7 +591,6 @@ The detected reason was: ...@@ -589,7 +591,6 @@ The detected reason was:
); );
} }
} }
}
AndroidEmbeddingVersion getEmbeddingVersion() { AndroidEmbeddingVersion getEmbeddingVersion() {
return computeEmbeddingVersion().version; return computeEmbeddingVersion().version;
......
...@@ -182,7 +182,7 @@ void main() { ...@@ -182,7 +182,7 @@ void main() {
// v1 embedding, as opposed to having <meta-data // v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />. // android:name="flutterEmbedding" android:value="2" />.
project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.none); project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.ignore);
expect(testLogger.statusText, contains('https://flutter.dev/go/android-project-migration')); expect(testLogger.statusText, contains('https://flutter.dev/go/android-project-migration'));
}); });
_testInMemory('Android project not on v2 embedding exits', () async { _testInMemory('Android project not on v2 embedding exits', () async {
...@@ -198,6 +198,15 @@ void main() { ...@@ -198,6 +198,15 @@ void main() {
expect(testLogger.statusText, contains('https://flutter.dev/go/android-project-migration')); expect(testLogger.statusText, contains('https://flutter.dev/go/android-project-migration'));
expect(testLogger.statusText, contains('No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in ')); expect(testLogger.statusText, contains('No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in '));
}); });
_testInMemory('Project not on v2 embedding does not warn if deprecation status is irrelevant', () async {
final FlutterProject project = await someProject();
// The default someProject with an empty <manifest> already indicates
// v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />.
project.checkForDeprecation(deprecationBehavior: DeprecationBehavior.none);
expect(testLogger.statusText, isEmpty);
});
_testInMemory('Android project not on v2 embedding ignore continues', () async { _testInMemory('Android project not on v2 embedding ignore continues', () async {
final FlutterProject project = await someProject(); final FlutterProject project = await someProject();
// The default someProject with an empty <manifest> already indicates // The default someProject with an empty <manifest> already indicates
......
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