Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 34e42b7f authored by Hall Liu's avatar Hall Liu
Browse files

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
parent 2b4f7ed5
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ import android.provider.CallLog.Calls;
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 @@ public class CallsManager extends Call.ListenerBase
                    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());