Delete call composer attachments when specified

When CallScreeningService says that attachments aren't supposed to shown
to the user, delete the extras from the call.

Bug: 179412110
Test: atest ExtendedInCallServiceTest
Change-Id: Icece760cef265b906a3aefcfc9964276a23dab47
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index e0cc01e..81dddbe 100755
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -72,6 +72,7 @@
 import android.provider.Settings;
 import android.sysprop.TelephonyProperties;
 import android.telecom.CallAudioState;
+import android.telecom.CallScreeningService;
 import android.telecom.CallerInfo;
 import android.telecom.Conference;
 import android.telecom.Connection;
@@ -768,6 +769,26 @@
                     result.mIsResponseFromSystemDialer);
         }
 
+        // Get rid of the call composer attachments that aren't wanted
+        if (result.mIsResponseFromSystemDialer && result.mCallScreeningResponse != null
+                && result.mCallScreeningResponse.getCallComposerAttachmentsToShow() >= 0) {
+            int attachmentMask = result.mCallScreeningResponse.getCallComposerAttachmentsToShow();
+            if ((attachmentMask
+                    & CallScreeningService.CallResponse.CALL_COMPOSER_ATTACHMENT_LOCATION) == 0) {
+                incomingCall.getExtras().remove(TelecomManager.EXTRA_LOCATION);
+            }
+
+            if ((attachmentMask
+                    & CallScreeningService.CallResponse.CALL_COMPOSER_ATTACHMENT_SUBJECT) == 0) {
+                incomingCall.getExtras().remove(TelecomManager.EXTRA_CALL_SUBJECT);
+            }
+
+            if ((attachmentMask
+                    & CallScreeningService.CallResponse.CALL_COMPOSER_ATTACHMENT_PRIORITY) == 0) {
+                incomingCall.getExtras().remove(TelecomManager.EXTRA_PRIORITY);
+            }
+        }
+
         if (result.shouldAllowCall) {
             incomingCall.setPostCallPackageName(
                     getRoleManagerAdapter().getDefaultCallScreeningApp());