Skip to content

Commit ad26067

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 e329730572f3bd492127054a12a4a064dbe3baa9)
1 parent 9665440 commit ad26067

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
@@ -1362,7 +1362,8 @@ private void enqueueNotification(NetworkPolicy policy, int type, long totalBytes
13621362

13631363
builder.setSmallIcon(R.drawable.stat_notify_error);
13641364

1365-
final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template);
1365+
final Intent snoozeIntent = buildSnoozeWarningIntent(policy.template,
1366+
mContext.getPackageName());
13661367
builder.setDeleteIntent(PendingIntent.getBroadcast(
13671368
mContext, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT));
13681369

@@ -1448,7 +1449,8 @@ private void enqueueNotification(NetworkPolicy policy, int type, long totalBytes
14481449

14491450
builder.setSmallIcon(R.drawable.stat_notify_error);
14501451

1451-
final Intent snoozeIntent = buildSnoozeRapidIntent(policy.template);
1452+
final Intent snoozeIntent = buildSnoozeRapidIntent(policy.template,
1453+
mContext.getPackageName());
14521454
builder.setDeleteIntent(PendingIntent.getBroadcast(
14531455
mContext, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT));
14541456

@@ -5043,17 +5045,19 @@ private static Intent buildAllowBackgroundDataIntent() {
50435045
return new Intent(ACTION_ALLOW_BACKGROUND);
50445046
}
50455047

5046-
private static Intent buildSnoozeWarningIntent(NetworkTemplate template) {
5048+
private static Intent buildSnoozeWarningIntent(NetworkTemplate template, String targetPackage) {
50475049
final Intent intent = new Intent(ACTION_SNOOZE_WARNING);
50485050
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
50495051
intent.putExtra(EXTRA_NETWORK_TEMPLATE, template);
5052+
intent.setPackage(targetPackage);
50505053
return intent;
50515054
}
50525055

5053-
private static Intent buildSnoozeRapidIntent(NetworkTemplate template) {
5056+
private static Intent buildSnoozeRapidIntent(NetworkTemplate template, String targetPackage) {
50545057
final Intent intent = new Intent(ACTION_SNOOZE_RAPID);
50555058
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
50565059
intent.putExtra(EXTRA_NETWORK_TEMPLATE, template);
5060+
intent.setPackage(targetPackage);
50575061
return intent;
50585062
}
50595063

0 commit comments

Comments
 (0)