[TIMOB-28050] Android: Investigate "package visibility" handling on Android 11
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-11-25T15:15:16.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | android, canOpenUrl, email, emaildialog, intent, openUrl |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-07-25T01:49:05.000+0000 |
Updated | 2020-11-25T15:15:16.000+0000 |
Description
*Summary:*
Android 11 requires developers to add a new
<query/>
entries into the "AndroidManifest.xml" for all intents passed to the Java resolveActivity()
and queryIntentActivities()
methods or else they will return false
or an empty collection respectively.
https://developer.android.com/preview/privacy/package-visibility
https://developer.android.com/preview/privacy/package-visibility-use-cases#open-a-file
Google lists which Java APIs are not affected below. The startActivity()
and startActivityForResult()
methods are not impacted. Intents referencing their own app are fine too.
https://developer.android.com/preview/privacy/package-visibility#use-cases-not-affected
*Impact:*
The following Titanium methods are impacted by this:
* [Ti.Platform.canOpenURL()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Platform-method-canOpenURL)
* [Ti.Platform.openURL()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Platform-method-openURL)
* [Ti.UI.EmailDialog.isSupported()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.EmailDialog-method-isSupported)
*To-Do:*
* Our openURL()
method should not call the Java resolveActivity()
anymore so that it won't require the <query/>
block. However, our canOpenURL()
should continue to use it and we'll need to document the need for this. (Note that iOS requires a "LSApplicationQueriesSchemes" plist setting for this method as well for the same reasons.)
* Ideally, our build system should auto-inject the <query/>
block needed if the app's code contains a createEmailDialog()
method call.
The canOpenURL()
and openURL()
methods should log an error if a <query/>
entry is needed.
*Test:*
The below PR has test code for canOpenURL()
and openURL()
which tests several different URLs.
https://github.com/appcelerator/titanium_mobile/pull/10881
Regarding the [EmailDialog.isSupported()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.EmailDialog-method-isSupported) method, a
<queries/>
block was not required a on a physical Pixel 3a device running Android 11, but it was required in the Android 11 emulator. Injecting the following into the "AndroidManifest.xml" will make ourisSupported()
method work.PR (9.3.x): https://github.com/appcelerator/titanium_mobile/pull/11985
merged to 9_3_X branch, backport cherry-picked to master for 9.3.0 target
*Closing ticket*. Fix verified in SDK version
9.3.0.v20201125050632
. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/11985