From 2c2f222a461da927320d7cb23e5773ec0379ccd7 Mon Sep 17 00:00:00 2001 From: chunhtai <47866232+chunhtai@users.noreply.github.com> Date: Tue, 2 Feb 2021 17:01:03 -0800 Subject: [PATCH 1/3] fixes android deeplink query paremeter null crashes (#24146) --- .../FlutterActivityAndFragmentDelegate.java | 2 +- ...lutterActivityAndFragmentDelegateTest.java | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index 0990604b9ba1b..e3d0235ff621e 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -400,7 +400,7 @@ private String maybeGetInitialRouteFromIntent(Intent intent) { Uri data = intent.getData(); if (data != null && !data.getPath().isEmpty()) { String pathAndQuery = data.getPath(); - if (!data.getQuery().isEmpty()) { + if (data.getQuery() != null && !data.getQuery().isEmpty()) { pathAndQuery += "?" + data.getQuery(); } return pathAndQuery; diff --git a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java index 509b97791cd9c..848ad8505495e 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java @@ -456,6 +456,32 @@ public void itForwardsOnRequestPermissionsResultToFlutterEngine() { .setInitialRoute("/custom/route?query=test"); } + @Test + public void + itSendsInitialRouteFromIntentOnStartIfNoInitialRouteFromActivityAndShouldHandleDeeplinkingNoQueryParameter() { + Intent intent = FlutterActivity.createDefaultIntent(RuntimeEnvironment.application); + intent.setData(Uri.parse("http://myApp/custom/route")); + + ActivityController activityController = + Robolectric.buildActivity(FlutterActivity.class, intent); + FlutterActivity flutterActivity = activityController.get(); + + when(mockHost.getActivity()).thenReturn(flutterActivity); + when(mockHost.getInitialRoute()).thenReturn(null); + when(mockHost.shouldHandleDeeplinking()).thenReturn(true); + // Create the real object that we're testing. + FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost); + + // --- Execute the behavior under test --- + // The FlutterEngine is setup in onAttach(). + delegate.onAttach(RuntimeEnvironment.application); + // Emulate app start. + delegate.onStart(); + + // Verify that the navigation channel was given the initial route message. + verify(mockFlutterEngine.getNavigationChannel(), times(1)).setInitialRoute("/custom/route"); + } + @Test public void itSendsdefaultInitialRouteOnStartIfNotDeepLinkingFromIntent() { // Creates an empty intent without launch uri. @@ -501,6 +527,25 @@ public void itSendsPushRouteMessageWhenOnNewIntent() { .pushRoute("/custom/route?query=test"); } + @Test + public void itSendsPushRouteMessageWhenOnNewIntentNoQueryParameter() { + when(mockHost.shouldHandleDeeplinking()).thenReturn(true); + // Create the real object that we're testing. + FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost); + + // --- Execute the behavior under test --- + // The FlutterEngine is setup in onAttach(). + delegate.onAttach(RuntimeEnvironment.application); + + Intent mockIntent = mock(Intent.class); + when(mockIntent.getData()).thenReturn(Uri.parse("http://myApp/custom/route")); + // Emulate the host and call the method that we expect to be forwarded. + delegate.onNewIntent(mockIntent); + + // Verify that the navigation channel was given the push route message. + verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRoute("/custom/route"); + } + @Test public void itForwardsOnNewIntentToFlutterEngine() { // Create the real object that we're testing. From a6983ec6fd0df6fe226b49975d0ebb646a08cc66 Mon Sep 17 00:00:00 2001 From: Christopher Fujino Date: Wed, 17 Mar 2021 16:20:14 -0700 Subject: [PATCH 2/3] Update Dart SDK to 2.12.2 --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index eddb798600419..db6809fe682ec 100644 --- a/DEPS +++ b/DEPS @@ -35,7 +35,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS. # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': 'd6e7aacfe6d19c8d478dcf3e315b76720813a417', + 'dart_revision': '65376c07234d1df472662d21dff2498ab2d3cdda', # WARNING: DO NOT EDIT MANUALLY # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py From 0570e2937afd85d9fe8c2f5cc74535e47f6fc909 Mon Sep 17 00:00:00 2001 From: Christopher Fujino Date: Wed, 17 Mar 2021 16:53:07 -0700 Subject: [PATCH 3/3] update licenses golden --- ci/licenses_golden/licenses_third_party | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/licenses_golden/licenses_third_party b/ci/licenses_golden/licenses_third_party index 54ef3f16ebaf6..42199b34218b1 100644 --- a/ci/licenses_golden/licenses_third_party +++ b/ci/licenses_golden/licenses_third_party @@ -1,4 +1,4 @@ -Signature: 56dff2126686e1d0cc09e0792dce6a2a +Signature: 890d97116d1c4d016c71fa50db974d98 UNUSED LICENSES: