Send targeted broadcasts to prevent other apps from receiving them.

When sending broadcasts ACTION_SNOOZE_WARNING in NPMS, which may
contain sensitive information, explicitly set the package name
that should receive it to prevent other apps from receiving them.

Bug: 177931370
Test: manual
Change-Id: I2a0a0dc09e27791de829bacfb2e865ffea993715
Merged-In: I11d736771d859d2af27d5c84a502ab038974e2e2
This commit is contained in:
MahendaviAamir
2021-06-09 17:10:42 +05:30
committed by Sudheer Shanka
parent 1692babe5e
commit fdbcf17a4e

View File

@@ -1155,8 +1155,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
builder.setContentText(body);
builder.setDefaults(Notification.DEFAULT_ALL);
builder.setChannelId(SystemNotificationChannels.NETWORK_ALERTS);
final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template);
final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template,
mContext.getPackageName());
builder.setDeleteIntent(PendingIntent.getBroadcast(
mContext, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT));
@@ -4243,9 +4243,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
return new Intent(ACTION_ALLOW_BACKGROUND);
}
private static Intent buildSnoozeWarningIntent(NetworkTemplate template) {
private static Intent buildSnoozeWarningIntent(NetworkTemplate template, String targetPackage) {
final Intent intent = new Intent(ACTION_SNOOZE_WARNING);
intent.putExtra(EXTRA_NETWORK_TEMPLATE, template);
intent.setPackage(targetPackage);
return intent;
}