mirror of
https://github.com/flutter/flutter
synced 2024-08-24 18:36:03 +00:00
Update the gradle task to add fallback scheme and host if needed when retrieving deep links. (#146470)
This is to support feature: https://github.com/flutter/devtools/issues/7541 before behavior: do not show this link in the dev tool if there's no scheme or host target behavior: show the link in the dev tool with a error text : ( missing scheme/ missing domain) ## 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], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] 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 [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [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 [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes
This commit is contained in:
parent
5bc3de9d75
commit
07f3103c67
|
@ -570,11 +570,12 @@ class FlutterPlugin implements Plugin<Project> {
|
|||
}
|
||||
}
|
||||
}
|
||||
schemes.each { scheme ->
|
||||
hosts.each { host ->
|
||||
if (!paths) {
|
||||
appLinkSettings.deeplinks.add(new Deeplink(scheme: scheme, host: host, path: ".*", intentFilterCheck: intentFilterCheck))
|
||||
} else {
|
||||
if(!hosts.isEmpty() || !paths.isEmpty()){
|
||||
if(schemes.isEmpty()){schemes.add(null)}
|
||||
if(hosts.isEmpty()){hosts.add(null)}
|
||||
if(paths.isEmpty()){paths.add('.*')}
|
||||
schemes.each { scheme ->
|
||||
hosts.each { host ->
|
||||
paths.each { path ->
|
||||
appLinkSettings.deeplinks.add(new Deeplink(scheme: scheme, host: host, path: path, intentFilterCheck: intentFilterCheck))
|
||||
}
|
||||
|
|
|
@ -192,6 +192,55 @@ final XmlElement nonBrowsableCategoryIntentFilter = XmlElement(
|
|||
),
|
||||
],
|
||||
);
|
||||
final XmlElement nonSchemeCategoryIntentFilter = XmlElement(
|
||||
XmlName('intent-filter'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('autoVerify', 'android'), 'true')],
|
||||
<XmlElement>[
|
||||
XmlElement(
|
||||
XmlName('action'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('name', 'android'), 'android.intent.action.VIEW')],
|
||||
),
|
||||
XmlElement(
|
||||
XmlName('category'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('name', 'android'), 'android.intent.category.DEFAULT')],
|
||||
),
|
||||
XmlElement(
|
||||
XmlName('category'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('name', 'android'), 'android.intent.category.BROWSABLE')],
|
||||
),
|
||||
XmlElement(
|
||||
XmlName('data'),
|
||||
<XmlAttribute>[
|
||||
XmlAttribute(XmlName('host', 'android'), 'non-browsable-category.com'),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
final XmlElement nonHostCategoryIntentFilter = XmlElement(
|
||||
XmlName('intent-filter'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('autoVerify', 'android'), 'true')],
|
||||
<XmlElement>[
|
||||
XmlElement(
|
||||
XmlName('action'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('name', 'android'), 'android.intent.action.VIEW')],
|
||||
),
|
||||
XmlElement(
|
||||
XmlName('category'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('name', 'android'), 'android.intent.category.DEFAULT')],
|
||||
),
|
||||
XmlElement(
|
||||
XmlName('category'),
|
||||
<XmlAttribute>[XmlAttribute(XmlName('name', 'android'), 'android.intent.category.BROWSABLE')],
|
||||
),
|
||||
XmlElement(
|
||||
XmlName('data'),
|
||||
<XmlAttribute>[
|
||||
XmlAttribute(XmlName('scheme', 'android'), 'http'),
|
||||
XmlAttribute(XmlName('path', 'android'), '/path1'),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
void main() {
|
||||
late Directory tempDir;
|
||||
|
@ -206,8 +255,8 @@ void main() {
|
|||
|
||||
void testDeeplink(
|
||||
dynamic deeplink,
|
||||
String scheme,
|
||||
String host,
|
||||
String? scheme,
|
||||
String? host,
|
||||
String path, {
|
||||
required bool hasAutoVerify,
|
||||
required bool hasActionView,
|
||||
|
@ -251,6 +300,8 @@ void main() {
|
|||
activity.children.add(nonActionIntentFilter);
|
||||
activity.children.add(nonDefaultCategoryIntentFilter);
|
||||
activity.children.add(nonBrowsableCategoryIntentFilter);
|
||||
activity.children.add(nonSchemeCategoryIntentFilter);
|
||||
activity.children.add(nonHostCategoryIntentFilter);
|
||||
androidManifestFile.writeAsStringSync(androidManifest.toString(), flush: true);
|
||||
|
||||
// Ensure that gradle files exists from templates.
|
||||
|
@ -278,7 +329,7 @@ void main() {
|
|||
expect(json['applicationId'], 'com.example.testapp');
|
||||
expect(json['deeplinkingFlagEnabled'], true);
|
||||
final List<dynamic> deeplinks = json['deeplinks']! as List<dynamic>;
|
||||
expect(deeplinks.length, 8);
|
||||
expect(deeplinks.length, 10);
|
||||
testDeeplink(deeplinks[0], 'http', 'pure-http.com', '.*', hasAutoVerify:true, hasActionView: true, hasDefaultCategory:true, hasBrowsableCategory: true);
|
||||
testDeeplink(deeplinks[1], 'custom', 'custom.com', '.*', hasAutoVerify:true, hasActionView: true, hasDefaultCategory:true, hasBrowsableCategory: true);
|
||||
testDeeplink(deeplinks[2], 'custom', 'hybrid.com', '.*', hasAutoVerify:true, hasActionView: true, hasDefaultCategory:true, hasBrowsableCategory: true);
|
||||
|
@ -287,6 +338,8 @@ void main() {
|
|||
testDeeplink(deeplinks[5], 'http', 'non-action.com', '.*', hasAutoVerify:true, hasActionView: false, hasDefaultCategory:true, hasBrowsableCategory: true);
|
||||
testDeeplink(deeplinks[6], 'http', 'non-default-category.com', '.*', hasAutoVerify:true, hasActionView: true, hasDefaultCategory:false, hasBrowsableCategory: true);
|
||||
testDeeplink(deeplinks[7], 'http', 'non-browsable-category.com', '.*', hasAutoVerify:true, hasActionView: true, hasDefaultCategory:true, hasBrowsableCategory: false);
|
||||
testDeeplink(deeplinks[8], null, 'non-browsable-category.com', '.*', hasAutoVerify:true, hasActionView: true, hasDefaultCategory:true, hasBrowsableCategory: true);
|
||||
testDeeplink(deeplinks[9], 'http', null, '/path1', hasAutoVerify:true, hasActionView: true, hasDefaultCategory:true, hasBrowsableCategory: true);
|
||||
});
|
||||
|
||||
testWithoutContext(
|
||||
|
|
Loading…
Reference in a new issue