From 966cbf8d5b9bf8350d3edf15d01243a4f64b4113 Mon Sep 17 00:00:00 2001 From: Chun-Heng Tai Date: Tue, 22 Dec 2020 15:50:05 -0800 Subject: [PATCH 1/2] fixes android deeplink to push the path only --- .../embedding/android/FlutterActivityAndFragmentDelegate.java | 4 ++-- .../android/FlutterActivityAndFragmentDelegateTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index a7be71dce0789..4d5cfcac0dbeb 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -398,8 +398,8 @@ private void doInitialFlutterViewRun() { private String maybeGetInitialRouteFromIntent(Intent intent) { if (host.shouldHandleDeeplinking()) { Uri data = intent.getData(); - if (data != null && !data.toString().isEmpty()) { - return data.toString(); + if (data != null && !data.getPath().isEmpty()) { + return data.getPath(); } } return null; 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 bf49fb6871c94..682459bc51944 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java @@ -453,7 +453,7 @@ public void itForwardsOnRequestPermissionsResultToFlutterEngine() { // Verify that the navigation channel was given the initial route message. verify(mockFlutterEngine.getNavigationChannel(), times(1)) - .setInitialRoute("http://myApp/custom/route"); + .setInitialRoute("/custom/route"); } @Test @@ -498,7 +498,7 @@ public void itSendsPushRouteMessageWhenOnNewIntent() { // Verify that the navigation channel was given the push route message. verify(mockFlutterEngine.getNavigationChannel(), times(1)) - .pushRoute("http://myApp/custom/route"); + .pushRoute("/custom/route"); } @Test From c780915e3056d4bd1942b215f6c986c47ce099f8 Mon Sep 17 00:00:00 2001 From: Chun-Heng Tai Date: Tue, 5 Jan 2021 10:10:43 -0800 Subject: [PATCH 2/2] format --- .../android/FlutterActivityAndFragmentDelegateTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 682459bc51944..e4c02d7492807 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java +++ b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java @@ -452,8 +452,7 @@ public void itForwardsOnRequestPermissionsResultToFlutterEngine() { delegate.onStart(); // Verify that the navigation channel was given the initial route message. - verify(mockFlutterEngine.getNavigationChannel(), times(1)) - .setInitialRoute("/custom/route"); + verify(mockFlutterEngine.getNavigationChannel(), times(1)).setInitialRoute("/custom/route"); } @Test @@ -497,8 +496,7 @@ public void itSendsPushRouteMessageWhenOnNewIntent() { delegate.onNewIntent(mockIntent); // Verify that the navigation channel was given the push route message. - verify(mockFlutterEngine.getNavigationChannel(), times(1)) - .pushRoute("/custom/route"); + verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRoute("/custom/route"); } @Test