Specifies RECEIVER_NOT_EXPORTED for FlashNotificationsController broadcast receiver

After changing Flash Notifications preview broadcasts to be protected,
there is no need to specify RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED
for the receiver. These flags are only required for runtime receivers
that listen to non-system broadcast(s).

However, if a receiver is registered for only system broadcasts along with the RECEIVER_NOT_EXPORTED flag, the platform will honor this flag, and only root or system UIDs will be able to send the system broadcast(s) to this receiver. Since Flash Notifications preview can only be triggered by settings app for now, changing the receiver flag to RECEIVER_NOT_EXPORTED can best avoid this receiver from potential vulnerabilities.

See go/receiver-flag-enforcement-design.

Bug: 266775677
Test: uses go/abtd to run com.google.android.projection.gearhead.test.functional#CarAppTest-searchTemplate
Change-Id: I3f819d8c5bee9d96c97799e80548cccbcca32fe8
This commit is contained in:
Angela Wang
2023-03-02 09:05:59 +00:00
parent 96d9410262
commit e02042e3ad

View File

@@ -254,7 +254,7 @@ class FlashNotificationsController {
broadcastFilter.addAction(ACTION_FLASH_NOTIFICATION_STOP_PREVIEW);
mFlashBroadcastReceiver = new FlashBroadcastReceiver();
mContext.registerReceiver(
mFlashBroadcastReceiver, broadcastFilter, Context.RECEIVER_EXPORTED);
mFlashBroadcastReceiver, broadcastFilter, Context.RECEIVER_NOT_EXPORTED);
final PowerManager powerManager = mContext.getSystemService(PowerManager.class);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK_TAG);