From 8b7e018dbf4ab03dce85da22315df0bf0216fc60 Mon Sep 17 00:00:00 2001 From: chunhtai <47866232+chunhtai@users.noreply.github.com> Date: Tue, 5 Jan 2021 11:14:01 -0800 Subject: [PATCH] fixes android deeplink to push the path only (flutter/engine#23255) --- .../android/FlutterActivityAndFragmentDelegate.java | 4 ++-- .../android/FlutterActivityAndFragmentDelegateTest.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java index a7be71dce0..4d5cfcac0d 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java @@ -398,8 +398,8 @@ import java.util.Arrays; 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/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java index bf49fb6871..e4c02d7492 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java @@ -452,8 +452,7 @@ public class FlutterActivityAndFragmentDelegateTest { delegate.onStart(); // Verify that the navigation channel was given the initial route message. - verify(mockFlutterEngine.getNavigationChannel(), times(1)) - .setInitialRoute("http://myApp/custom/route"); + verify(mockFlutterEngine.getNavigationChannel(), times(1)).setInitialRoute("/custom/route"); } @Test @@ -497,8 +496,7 @@ public class FlutterActivityAndFragmentDelegateTest { delegate.onNewIntent(mockIntent); // Verify that the navigation channel was given the push route message. - verify(mockFlutterEngine.getNavigationChannel(), times(1)) - .pushRoute("http://myApp/custom/route"); + verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRoute("/custom/route"); } @Test