Reputation: 45
Discussing about Android Security a question raised and we could not find a reasonable answer (maybe naive questions):
Example found on Application Manifests: package = "com.google.android.youtube" Application: android:name="com.google.android.apps.youtube.app.YouTubeApplication" Receiver: android:name="com.google.android.apps.youtube.core.player.notification.ExternalPlaybackControllerV14$RemoteControlIntentReceiver" android:exported="true"
Upvotes: 2
Views: 923
Reputation: 95568
An explanation for the example you have given is pretty easy. The example you've given is for a BroadcastReceiver
component. This component has android:exported="true"
so that it can be called from other components external to the application. A good example of this use is AlarmManager
. If the application wants to use AlarmManager
to set an alarm, the component which the AlarmManager
calls when the alarm goes off must be publicly available. The reason is that AlarmManager
must be able to start the component, even if your application is not running. To do that, the component must be declared in the manifest and it must be publicly available (ie: "android:exported="true").
In general, anytime your application creates an explicit Intent
, and then passes this Intent
(using PendingIntent
) to another component that is external to your application, the component in question must be publicly available.
You asked for a code example. Another application could trigger the BroadcastReciever
component you've given in the example like this:
Intent intent = new Intent();
intent.setClassName("com.google.android.youtube",
"com.google.android.apps.youtube.core.player.notification.ExternalPlaybackControllerV14$RemoteControlIntentReceiver");
sendBroadcast(intent);
Hope this answers all your questions.
Upvotes: 2