Properly set picture URI on outgoing calls
Set the picture URI so it can be written into the call log when Telecom
logs the call.
Bug: 177613111
Test: manual
Merged-In: I11a3d459bc38799179fa709e253dd73bc5a85d02
Change-Id: I7922549fb9429317d4832bcafd4e72cfd514b0bb
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 971f41b..0a0ab96 100755
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -1149,7 +1149,7 @@
(result) -> {
if (result.first != null) {
Bundle newExtras = new Bundle();
- newExtras.putParcelable(TelecomManager.EXTRA_INCOMING_PICTURE,
+ newExtras.putParcelable(TelecomManager.EXTRA_PICTURE_URI,
result.first);
putTelephonyExtras(newExtras);
} else {
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 459c7c4..79f9153 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -1711,10 +1711,20 @@
return;
}
- if (extras.containsKey(TelecomManager.EXTRA_OUTGOING_PICTURE)) {
+ if (extras != null && extras.containsKey(TelecomManager.EXTRA_OUTGOING_PICTURE)) {
ParcelUuid uuid = extras.getParcelable(TelecomManager.EXTRA_OUTGOING_PICTURE);
CallComposerPictureManager.getInstance(phone.getContext(), phone.getSubId())
- .storeUploadedPictureToCallLog(uuid.getUuid(), (uri) -> { });
+ .storeUploadedPictureToCallLog(uuid.getUuid(), (uri) -> {
+ if (uri != null) {
+ try {
+ Bundle b = new Bundle();
+ b.putParcelable(TelecomManager.EXTRA_PICTURE_URI, uri);
+ connection.putTelephonyExtras(b);
+ } catch (Exception e) {
+ Log.e(this, e, "Couldn't set picture extra on outgoing call");
+ }
+ }
+ });
}
com.android.internal.telephony.Connection originalConnection = null;
diff --git a/tests/src/com/android/phone/callcomposer/PictureManagerTest.java b/tests/src/com/android/phone/callcomposer/PictureManagerTest.java
index d93db17..b52b297 100644
--- a/tests/src/com/android/phone/callcomposer/PictureManagerTest.java
+++ b/tests/src/com/android/phone/callcomposer/PictureManagerTest.java
@@ -68,7 +68,9 @@
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
originalTestMode = CallComposerPictureManager.sTestMode;
- CallComposerPictureManager.sTestMode = true;
+ // Even though this is a test, we want test mode off so we can actually exercise the logic
+ // in the class.
+ CallComposerPictureManager.sTestMode = false;
when(context.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(telephonyManager);
when(context.getSystemServiceName(TelephonyManager.class))
.thenReturn(Context.TELEPHONY_SERVICE);