Merge "Fix issues with test mode for call composer" into sc-dev am: 65f6b375e0

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telephony/+/13428676

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I473079801eee68e44af1025b63c58d9fcda22837
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 0a0ab96..c41bf1a 100755
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -1133,19 +1133,21 @@
     @Override
     public void onCallFilteringCompleted(boolean isBlocked, boolean isInContacts) {
         if (isImsConnection()) {
-            ImsPhone imsPhone = (ImsPhone) getPhone().getImsPhone();
+            ImsPhone imsPhone = (getPhone() instanceof ImsPhone) ? (ImsPhone) getPhone() : null;
             if (imsPhone != null
                     && imsPhone.getCallComposerStatus() == TelephonyManager.CALL_COMPOSER_STATUS_ON
                     && !isBlocked && isInContacts) {
                 ImsPhoneConnection originalConnection = (ImsPhoneConnection) mOriginalConnection;
                 ImsCallProfile profile = originalConnection.getImsCall().getCallProfile();
+                String serverUrl = CallComposerPictureManager.sTestMode
+                        ? CallComposerPictureManager.FAKE_SERVER_URL
+                        : profile.getCallExtra(ImsCallProfile.EXTRA_PICTURE_URL);
                 if (profile != null
-                        && !TextUtils.isEmpty(
-                        profile.getCallExtra(ImsCallProfile.EXTRA_PICTURE_URL))) {
+                        && !TextUtils.isEmpty(serverUrl)) {
                     CallComposerPictureManager manager = CallComposerPictureManager
                             .getInstance(getPhone().getContext(), getPhone().getSubId());
                     manager.handleDownloadFromServer(new CallComposerPictureTransfer.Factory() {},
-                            profile.getCallExtra(ImsCallProfile.EXTRA_PICTURE_URL),
+                            serverUrl,
                             (result) -> {
                                 if (result.first != null) {
                                     Bundle newExtras = new Bundle();