Skip to content

Commit bfad9c3

Browse files
Sudheer ShankaAndroid Build Coastguard Worker
authored andcommitted
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: I11d736771d859d2af27d5c84a502ab038974e2e2 Merged-In: I11d736771d859d2af27d5c84a502ab038974e2e2 (cherry picked from commit 1494979a6ac772fa49a26748f047a4c3d64baf51) (cherry picked from commit 16732a1253294866c588ca040416c48be734490b)
1 parent 42c16ed commit bfad9c3

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

services/core/java/com/android/server/net/NetworkPolicyManagerService.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,8 @@ private void enqueueNotification(NetworkPolicy policy, int type, long totalBytes
13701370

13711371
builder.setSmallIcon(R.drawable.stat_notify_error);
13721372

1373-
final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template);
1373+
final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template,
1374+
mContext.getPackageName());
13741375
builder.setDeleteIntent(PendingIntent.getBroadcast(
13751376
mContext, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT));
13761377

@@ -1456,7 +1457,8 @@ private void enqueueNotification(NetworkPolicy policy, int type, long totalBytes
14561457

14571458
builder.setSmallIcon(R.drawable.stat_notify_error);
14581459

1459-
final Intent snoozeIntent = buildSnoozeRapidIntent(policy.template);
1460+
final Intent snoozeIntent = buildSnoozeRapidIntent(policy.template,
1461+
mContext.getPackageName());
14601462
builder.setDeleteIntent(PendingIntent.getBroadcast(
14611463
mContext, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT));
14621464

@@ -5061,17 +5063,19 @@ private static Intent buildAllowBackgroundDataIntent() {
50615063
return new Intent(ACTION_ALLOW_BACKGROUND);
50625064
}
50635065

5064-
private static Intent buildSnoozeWarningIntent(NetworkTemplate template) {
5066+
private static Intent buildSnoozeWarningIntent(NetworkTemplate template, String targetPackage) {
50655067
final Intent intent = new Intent(ACTION_SNOOZE_WARNING);
50665068
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
50675069
intent.putExtra(EXTRA_NETWORK_TEMPLATE, template);
5070+
intent.setPackage(targetPackage);
50685071
return intent;
50695072
}
50705073

5071-
private static Intent buildSnoozeRapidIntent(NetworkTemplate template) {
5074+
private static Intent buildSnoozeRapidIntent(NetworkTemplate template, String targetPackage) {
50725075
final Intent intent = new Intent(ACTION_SNOOZE_RAPID);
50735076
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
50745077
intent.putExtra(EXTRA_NETWORK_TEMPLATE, template);
5078+
intent.setPackage(targetPackage);
50755079
return intent;
50765080
}
50775081

0 commit comments

Comments
 (0)