Disable reply for messages with null contact URIs
Contact URIs need to be non-null for BluetoothMapClient to understand
which sender on the phone to send a message to. Therefore, if a URI is null,
we should disable replying/sending a message.
Change-Id: I8d8bf9d8ad335711de32efbe6f1e3664901844d6
Fix: 144842584
Test: verified for iOS 12, iOS 13+, Android
diff --git a/src/com/android/car/messenger/MessengerDelegate.java b/src/com/android/car/messenger/MessengerDelegate.java
index 5a3d2e0..bd5e9fa 100644
--- a/src/com/android/car/messenger/MessengerDelegate.java
+++ b/src/com/android/car/messenger/MessengerDelegate.java
@@ -412,7 +412,7 @@
final List<Action> actionList = new ArrayList<>();
// Reply action
- if (shouldAddReplyAction(senderKey.getDeviceAddress())) {
+ if (shouldAddReplyAction(senderKey)) {
final String replyString = mContext.getString(R.string.action_reply);
PendingIntent replyIntent = createServiceIntent(senderKey, notificationId,
MessengerService.ACTION_VOICE_REPLY);
@@ -444,12 +444,16 @@
return actionList;
}
- private boolean shouldAddReplyAction(String deviceAddress) {
+ private boolean shouldAddReplyAction(SenderKey senderKey) {
+ if (mNotificationInfos.get(senderKey).mSenderContactUri == null) {
+ return false;
+ }
+
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter == null) {
return false;
}
- BluetoothDevice device = adapter.getRemoteDevice(deviceAddress);
+ BluetoothDevice device = adapter.getRemoteDevice(senderKey.getDeviceAddress());
synchronized (mMapClientLock) {
return (mBluetoothMapClient != null) && mBluetoothMapClient.isUploadingSupported(