Is it possible to programatically set the protection level of an IntentFilter/Intent
in java similar to how we can define it in the AndroidManifest.xml
:
<receiver
android:name="my.test.receiver"
android:protectionLevel="signature" />
We have a core library for our apps which facilitates dynamic broadcasts and receivers at runtime and we would like to make them secure here.
I have found no information on this method online and not sure if it is possible. if we could set an intentFilters permission level = PermissionInfo.PROTECTION_SIGNATURE
it would work but going by the docs it seems PermissionInfo is only used for reading. The only alternative method I can find is declaring a special permission, sending it with our broadcasts and adding it to all our manifests: https://stackoverflow.com/a/15316487/1810256
We may fall back on this approach but we would prefer the first method as the signature approach seems more secure.
Any help/suggestions appreciated!