Explicitly mark receivers as RECEIVER_NOT_EXPORTED

The intent actions registered for here are only marked as protected
broadcasts if the telephony package is present. In its absence,
receivers *must* specify either RECEIVER_EXPORTED or
RECEIVER_NOT_EXPORTED.

Since these Intents are sent from Telephony, which runs with a system
UID less than the first application UID (10000), the system_server can
receive these broadcasts without exporting the receivers.

Bug: 218831939
Test: build & run on ATV device
Test: atest TelephonySubscriptionTrackerTest
Change-Id: I3fed2a1772fccea611f68e9425755b0c9aa9051e
This commit is contained in:
Robert Horvath 2022-02-10 15:36:31 +01:00
parent dae8e486bf
commit 2e0cba87dd
3 changed files with 6 additions and 4 deletions

View File

@ -73,7 +73,8 @@ public class DataConnectionStats extends BroadcastReceiver {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SIM_STATE_CHANGED);
mContext.registerReceiver(this, filter, null /* broadcastPermission */, mListenerHandler);
mContext.registerReceiver(this, filter, null /* broadcastPermission */, mListenerHandler,
Context.RECEIVER_NOT_EXPORTED);
}
@Override

View File

@ -146,7 +146,7 @@ public class TelephonySubscriptionTracker extends BroadcastReceiver {
filter.addAction(ACTION_CARRIER_CONFIG_CHANGED);
filter.addAction(ACTION_MULTI_SIM_CONFIG_CHANGED);
mContext.registerReceiver(this, filter, null, mHandler);
mContext.registerReceiver(this, filter, null, mHandler, Context.RECEIVER_NOT_EXPORTED);
mSubscriptionManager.addOnSubscriptionsChangedListener(
executor, mSubscriptionChangedListener);
mTelephonyManager.registerTelephonyCallback(executor, mActiveDataSubIdListener);

View File

@ -174,7 +174,7 @@ public class TelephonySubscriptionTrackerTest {
private IntentFilter getIntentFilter() {
final ArgumentCaptor<IntentFilter> captor = ArgumentCaptor.forClass(IntentFilter.class);
verify(mContext).registerReceiver(any(), captor.capture(), any(), any());
verify(mContext).registerReceiver(any(), captor.capture(), any(), any(), anyInt());
return captor.getValue();
}
@ -258,7 +258,8 @@ public class TelephonySubscriptionTrackerTest {
eq(mTelephonySubscriptionTracker),
any(IntentFilter.class),
any(),
eq(mHandler));
eq(mHandler),
eq(Context.RECEIVER_NOT_EXPORTED));
final IntentFilter filter = getIntentFilter();
assertEquals(2, filter.countActions());
assertTrue(filter.hasAction(ACTION_CARRIER_CONFIG_CHANGED));