Set deep linking flag to true by default (flutter/engine#52350)
doc: flutter.dev/go/deep-link-flag-migration Action item: make sure customers are aware of this change before merging this PR. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I signed the [CLA]. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
This commit is contained in:
parent
555c2ff92a
commit
5f18f2ebfd
@ -18,9 +18,9 @@ import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_DA
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_DESTROY_ENGINE_WITH_ACTIVITY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_ENABLE_STATE_RESTORATION;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_INITIAL_ROUTE;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.HANDLE_DEEPLINKING_META_DATA_KEY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.INITIAL_ROUTE_META_DATA_KEY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.NORMAL_THEME_META_DATA_KEY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.deepLinkEnabled;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
@ -1404,9 +1404,7 @@ public class FlutterActivity extends Activity
|
||||
public boolean shouldHandleDeeplinking() {
|
||||
try {
|
||||
Bundle metaData = getMetaData();
|
||||
boolean shouldHandleDeeplinking =
|
||||
metaData != null ? metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY) : false;
|
||||
return shouldHandleDeeplinking;
|
||||
return deepLinkEnabled(metaData);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
package io.flutter.embedding.android;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
/** Collection of Flutter launch configuration options. */
|
||||
// This class is public so that Flutter app developers can reference
|
||||
// BackgroundMode
|
||||
@ -41,5 +43,24 @@ public class FlutterActivityLaunchConfigs {
|
||||
transparent
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to handle the deeplinking.
|
||||
*
|
||||
* <p>The default implementation looks {@code <meta-data>} called {@link
|
||||
* FlutterActivityLaunchConfigs#HANDLE_DEEPLINKING_META_DATA_KEY} within the Android manifest
|
||||
* definition for this {@code FlutterActivity}.
|
||||
*
|
||||
* <p>Defaults to {@code true}.
|
||||
*/
|
||||
public static boolean deepLinkEnabled(Bundle metaData) {
|
||||
// Check if metadata is not null and contains the HANDLE_DEEPLINKING_META_DATA_KEY.
|
||||
if (metaData != null && metaData.containsKey(HANDLE_DEEPLINKING_META_DATA_KEY)) {
|
||||
return metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY);
|
||||
} else {
|
||||
// Return true if the deep linking flag is not found in metadata.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private FlutterActivityLaunchConfigs() {}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_DA
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_DART_ENTRYPOINT_ARGS;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_DESTROY_ENGINE_WITH_ACTIVITY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.EXTRA_INITIAL_ROUTE;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.HANDLE_DEEPLINKING_META_DATA_KEY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.INITIAL_ROUTE_META_DATA_KEY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.NORMAL_THEME_META_DATA_KEY;
|
||||
import static io.flutter.embedding.android.FlutterActivityLaunchConfigs.deepLinkEnabled;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -695,9 +695,7 @@ public class FlutterFragmentActivity extends FragmentActivity
|
||||
protected boolean shouldHandleDeeplinking() {
|
||||
try {
|
||||
Bundle metaData = getMetaData();
|
||||
boolean shouldHandleDeeplinking =
|
||||
metaData != null ? metaData.getBoolean(HANDLE_DEEPLINKING_META_DATA_KEY) : false;
|
||||
return shouldHandleDeeplinking;
|
||||
return deepLinkEnabled(metaData);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -332,8 +332,8 @@ public class FlutterActivityTest {
|
||||
Bundle bundle = new Bundle();
|
||||
FlutterActivity spyFlutterActivity = spy(flutterActivity);
|
||||
when(spyFlutterActivity.getMetaData()).thenReturn(bundle);
|
||||
// Empty bundle should return false.
|
||||
assertFalse(spyFlutterActivity.shouldHandleDeeplinking());
|
||||
// Empty bundle should return true.
|
||||
assertTrue(spyFlutterActivity.shouldHandleDeeplinking());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -180,8 +180,8 @@ public class FlutterFragmentActivityTest {
|
||||
Bundle bundle = new Bundle();
|
||||
FlutterFragmentActivity spyFlutterActivity = spy(activity);
|
||||
when(spyFlutterActivity.getMetaData()).thenReturn(bundle);
|
||||
// Empty bundle should return false.
|
||||
assertFalse(spyFlutterActivity.shouldHandleDeeplinking());
|
||||
// Empty bundle should return true.
|
||||
assertTrue(spyFlutterActivity.shouldHandleDeeplinking());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -137,8 +137,8 @@ static NSString* const kRestorationStateAppModificationKey = @"mod-date";
|
||||
- (BOOL)isFlutterDeepLinkingEnabled {
|
||||
NSNumber* isDeepLinkingEnabled =
|
||||
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"];
|
||||
// if not set, return NO
|
||||
return isDeepLinkingEnabled ? [isDeepLinkingEnabled boolValue] : NO;
|
||||
// if not set, return YES
|
||||
return isDeepLinkingEnabled ? [isDeepLinkingEnabled boolValue] : YES;
|
||||
}
|
||||
|
||||
// This method is called when opening an URL with custom schemes.
|
||||
|
@ -80,12 +80,18 @@ FLUTTER_ASSERT_ARC
|
||||
OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
|
||||
.andReturn(nil);
|
||||
|
||||
OCMStub([self.mockNavigationChannel
|
||||
invokeMethod:@"pushRouteInformation"
|
||||
arguments:@{@"location" : @"http://myApp/custom/route?query=test"}])
|
||||
.andReturn(@YES);
|
||||
|
||||
BOOL result =
|
||||
[self.appDelegate application:[UIApplication sharedApplication]
|
||||
openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
|
||||
options:@{}];
|
||||
XCTAssertFalse(result);
|
||||
OCMReject([self.mockNavigationChannel invokeMethod:OCMOCK_ANY arguments:OCMOCK_ANY]);
|
||||
|
||||
XCTAssertTrue(result);
|
||||
OCMVerifyAll(self.mockNavigationChannel);
|
||||
}
|
||||
|
||||
- (void)testLaunchUrlWithDeepLinkingDisabled {
|
||||
|
Loading…
x
Reference in New Issue
Block a user