Bluetooth: Mark unaudited PendingIntents with FLAG_IMMUTABLE
Bug: 160794467
Bug: 178441949
Test: atest BluetoothInstrumentationTests
Change-Id: I5177efac17ea9ccbeecee232bcc321867a19c693
diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterService.java b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
index 461f591..6342246 100644
--- a/android/app/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
@@ -2861,11 +2861,9 @@
: AlarmManager.ELAPSED_REALTIME;
Intent intent = new Intent(ACTION_ALARM_WAKEUP);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
mPendingAlarm =
PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT
- | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ | PendingIntent.FLAG_IMMUTABLE);
mAlarmManager.setExact(type, wakeupTime, mPendingAlarm);
return true;
}
diff --git a/android/app/src/com/android/bluetooth/gatt/ScanManager.java b/android/app/src/com/android/bluetooth/gatt/ScanManager.java
index 5a12251..e80834b 100644
--- a/android/app/src/com/android/bluetooth/gatt/ScanManager.java
+++ b/android/app/src/com/android/bluetooth/gatt/ScanManager.java
@@ -539,10 +539,8 @@
mAlarmManager = (AlarmManager) mService.getSystemService(Context.ALARM_SERVICE);
Intent batchIntent = new Intent(ACTION_REFRESH_BATCHED_SCAN, null);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
mBatchScanIntervalIntent = PendingIntent.getBroadcast(mService, 0, batchIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_IMMUTABLE);
IntentFilter filter = new IntentFilter();
filter.addAction(ACTION_REFRESH_BATCHED_SCAN);
mBatchAlarmReceiver = new BroadcastReceiver() {
diff --git a/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java b/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java
index 4529f1d..3ae5e46 100644
--- a/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java
+++ b/android/app/src/com/android/bluetooth/map/BluetoothMapContentObserver.java
@@ -2856,11 +2856,9 @@
sentIntent.putExtra(EXTRA_MESSAGE_SENT_TRANSPARENT, transparent);
sentIntent.putExtra(EXTRA_MESSAGE_SENT_RETRY, retry);
//sentIntent.setDataAndNormalize(btMmsUri);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent pendingSendIntent =
PendingIntent.getBroadcast(mContext, 0, sentIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_IMMUTABLE);
SmsManager.getDefault()
.sendMultimediaMessage(mContext, btMmsUri, null/*locationUrl*/,
null/*configOverrides*/,
@@ -3207,12 +3205,9 @@
"message/" + Long.toString(msgInfo.id) + msgInfo.timestamp + i);
intentDelivery.putExtra(EXTRA_MESSAGE_SENT_HANDLE, msgInfo.id);
intentDelivery.putExtra(EXTRA_MESSAGE_SENT_TIMESTAMP, msgInfo.timestamp);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent pendingIntentDelivery =
PendingIntent.getBroadcast(mContext, 0, intentDelivery,
- PendingIntent.FLAG_UPDATE_CURRENT
- | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
intentSent = new Intent(ACTION_MESSAGE_SENT, null);
/* Add msgId and part number to ensure the intents are different, and we
@@ -3225,12 +3220,9 @@
intentSent.putExtra(EXTRA_MESSAGE_SENT_RETRY, msgInfo.retry);
intentSent.putExtra(EXTRA_MESSAGE_SENT_TRANSPARENT, msgInfo.transparent);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent pendingIntentSent =
PendingIntent.getBroadcast(mContext, 0, intentSent,
- PendingIntent.FLAG_UPDATE_CURRENT
- | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
// We use the same pending intent for all parts, but do not set the one shot flag.
deliveryIntents.add(pendingIntentDelivery);
diff --git a/android/app/src/com/android/bluetooth/map/BluetoothMapService.java b/android/app/src/com/android/bluetooth/map/BluetoothMapService.java
index ab312e5..e88f30e 100644
--- a/android/app/src/com/android/bluetooth/map/BluetoothMapService.java
+++ b/android/app/src/com/android/bluetooth/map/BluetoothMapService.java
@@ -950,10 +950,8 @@
}
mRemoveTimeoutMsg = true;
Intent timeoutIntent = new Intent(USER_CONFIRM_TIMEOUT_ACTION);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent pIntent = PendingIntent.getBroadcast(this, 0, timeoutIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_IMMUTABLE);
mAlarmManager.set(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + USER_CONFIRM_TIMEOUT_VALUE, pIntent);
}
@@ -963,10 +961,8 @@
Log.d(TAG, "cancelUserTimeOutAlarm()");
}
Intent timeoutIntent = new Intent(USER_CONFIRM_TIMEOUT_ACTION);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent pIntent = PendingIntent.getBroadcast(this, 0, timeoutIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_IMMUTABLE);
pIntent.cancel();
AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
diff --git a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
index 145333f..54b10a8 100644
--- a/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
+++ b/android/app/src/com/android/bluetooth/opp/BluetoothOppNotification.java
@@ -389,11 +389,8 @@
Intent intent = new Intent(Constants.ACTION_LIST);
intent.setClassName(Constants.THIS_PACKAGE_NAME, BluetoothOppReceiver.class.getName());
intent.setDataAndNormalize(Uri.parse(BluetoothShare.CONTENT_URI + "/" + item.id));
-
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
b.setContentIntent(PendingIntent.getBroadcast(mContext, 0, intent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED));
+ PendingIntent.FLAG_IMMUTABLE));
mNotificationMgr.notify(NOTIFICATION_ID_PROGRESS, b.build());
}
}
@@ -460,14 +457,12 @@
com.android.internal.R.color
.system_notification_accent_color,
mContext.getTheme()))
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
.setContentIntent(
PendingIntent.getBroadcast(mContext, 0, contentIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setDeleteIntent(
PendingIntent.getBroadcast(mContext, 0, deleteIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setWhen(timeStamp)
.setLocalOnly(true)
.build();
@@ -531,14 +526,12 @@
.system_notification_accent_color,
mContext.getTheme()))
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
.setContentIntent(
PendingIntent.getBroadcast(mContext, 0, contentIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setDeleteIntent(
PendingIntent.getBroadcast(mContext, 0, deleteIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setWhen(timeStamp)
.setLocalOnly(true)
.build();
@@ -573,19 +566,15 @@
new Notification.Action.Builder(Icon.createWithResource(mContext,
R.drawable.ic_decline),
mContext.getText(R.string.incoming_file_confirm_cancel),
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent.getBroadcast(mContext, 0,
new Intent(baseIntent).setAction(Constants.ACTION_DECLINE),
- PendingIntent.FLAG_MUTABLE_UNAUDITED)).build();
+ PendingIntent.FLAG_IMMUTABLE)).build();
Notification.Action actionAccept = new Notification.Action.Builder(
Icon.createWithResource(mContext,R.drawable.ic_accept),
mContext.getText(R.string.incoming_file_confirm_ok),
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
PendingIntent.getBroadcast(mContext, 0,
new Intent(baseIntent).setAction(Constants.ACTION_ACCEPT),
- PendingIntent.FLAG_MUTABLE_UNAUDITED)).build();
+ PendingIntent.FLAG_IMMUTABLE)).build();
Notification public_n =
new Notification.Builder(mContext, OPP_NOTIFICATION_CHANNEL).setOnlyAlertOnce(
true)
@@ -593,15 +582,13 @@
.setWhen(info.mTimeStamp)
.addAction(actionDecline)
.addAction(actionAccept)
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
.setContentIntent(PendingIntent.getBroadcast(mContext, 0,
new Intent(baseIntent).setAction(
Constants.ACTION_INCOMING_FILE_CONFIRM),
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setDeleteIntent(PendingIntent.getBroadcast(mContext, 0,
new Intent(baseIntent).setAction(Constants.ACTION_HIDE),
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setColor(mContext.getResources()
.getColor(
com.android.internal.R.color
@@ -622,15 +609,13 @@
true)
.setOngoing(true)
.setWhen(info.mTimeStamp)
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
.setContentIntent(PendingIntent.getBroadcast(mContext, 0,
new Intent(baseIntent).setAction(
Constants.ACTION_INCOMING_FILE_CONFIRM),
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setDeleteIntent(PendingIntent.getBroadcast(mContext, 0,
new Intent(baseIntent).setAction(Constants.ACTION_HIDE),
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setColor(mContext.getResources()
.getColor(
com.android.internal.R.color
diff --git a/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java b/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java
index 660f9f9..909d739 100644
--- a/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java
+++ b/android/app/src/com/android/bluetooth/pbap/PbapStateMachine.java
@@ -393,14 +393,12 @@
mService.getTheme()))
.setFlag(Notification.FLAG_AUTO_CANCEL, true)
.setFlag(Notification.FLAG_ONLY_ALERT_ONCE, true)
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
.setContentIntent(
PendingIntent.getActivity(mService, 0, clickIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setDeleteIntent(
PendingIntent.getBroadcast(mService, 0, deleteIntent,
- PendingIntent.FLAG_MUTABLE_UNAUDITED))
+ PendingIntent.FLAG_IMMUTABLE))
.setLocalOnly(true)
.build();
nm.notify(mNotificationId, notification);
diff --git a/android/app/src/com/android/bluetooth/sap/SapServer.java b/android/app/src/com/android/bluetooth/sap/SapServer.java
index 3a41ecf..e1de99d 100644
--- a/android/app/src/com/android/bluetooth/sap/SapServer.java
+++ b/android/app/src/com/android/bluetooth/sap/SapServer.java
@@ -196,7 +196,8 @@
/* Handle local disconnect procedures */
if (discType == SapMessage.DISC_GRACEFULL) {
/* Update the notification to allow the user to initiate a force disconnect */
- setNotification(SapMessage.DISC_IMMEDIATE, PendingIntent.FLAG_CANCEL_CURRENT);
+ setNotification(SapMessage.DISC_IMMEDIATE,
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
} else if (discType == SapMessage.DISC_IMMEDIATE) {
/* Request an immediate disconnect, but start a timer to force disconnect if the
@@ -754,10 +755,8 @@
sapDisconnectIntent.putExtra(SAP_DISCONNECT_TYPE_EXTRA, discType);
AlarmManager alarmManager =
(AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
- // TODO(b/171825892) Please replace FLAG_MUTABLE_UNAUDITED below
- // with either FLAG_IMMUTABLE (recommended) or FLAG_MUTABLE.
mPendingDiscIntent = PendingIntent.getBroadcast(mContext, discType, sapDisconnectIntent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_MUTABLE_UNAUDITED);
+ PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + timeMs, mPendingDiscIntent);