From d30c355d24d6106558523f2499662c7c41126f6b Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 28 May 2020 12:06:52 -0700 Subject: [PATCH] [flutter] allow loading either NOTICES or LICENSE (#58131) To make #57871 easier to land, add support for loading either LICENSES or NOTICES, preferring the later. --- packages/flutter/lib/src/services/binding.dart | 9 ++++++++- packages/flutter/test/services/binding_test.dart | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/services/binding.dart b/packages/flutter/lib/src/services/binding.dart index a92d83a6ef..19bd370e14 100644 --- a/packages/flutter/lib/src/services/binding.dart +++ b/packages/flutter/lib/src/services/binding.dart @@ -101,7 +101,14 @@ mixin ServicesBinding on BindingBase, SchedulerBinding { // TODO(ianh): Remove this complexity once these bugs are fixed. final Completer rawLicenses = Completer(); scheduleTask(() async { - rawLicenses.complete(rootBundle.loadString('LICENSE', cache: false)); + // TODO(jonahwilliams): temporary catch to allow migrating LICENSE to NOTICES. + // Once both the tool and google3 use notices this can be removed after PR: + // https://github.com/flutter/flutter/pull/57871 + try { + rawLicenses.complete(await rootBundle.loadString('NOTICES', cache: false)); + } on FlutterError { + rawLicenses.complete(await rootBundle.loadString('LICENSE', cache: false)); + } }, Priority.animation); await rawLicenses.future; final Completer> parsedLicenses = Completer>(); diff --git a/packages/flutter/test/services/binding_test.dart b/packages/flutter/test/services/binding_test.dart index 4c32ec43c9..8b204e691f 100644 --- a/packages/flutter/test/services/binding_test.dart +++ b/packages/flutter/test/services/binding_test.dart @@ -44,7 +44,10 @@ class TestBinding extends BindingBase with SchedulerBinding, ServicesBinding { BinaryMessenger createBinaryMessenger() { return super.createBinaryMessenger() ..setMockMessageHandler('flutter/assets', (ByteData message) async { - if (const StringCodec().decodeMessage(message) == 'LICENSE') { + // Temporarily check for both LICENSE and NOTICES + // Once both the tool and google3 use notices this can be removed after PR: + // https://github.com/flutter/flutter/pull/57871 + if (const StringCodec().decodeMessage(message) == 'LICENSE' || const StringCodec().decodeMessage(message) == 'NOTICES') { return const StringCodec().encodeMessage(licenses); } return null;