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

Commit 7978e0e9 authored by Hall Liu's avatar Hall Liu
Browse files

Add plumbing in Telecom for new Call APIs

Add plumbing in Telecom to transmit the CDMA active child info and
contacts display name to the in-call service.

Fixes: 147445725
Fixes: 147445603
Test: atest CallDetailsTest ConferenceTest InCallControllerTest
Test: manual test by attaching a debugger
Change-Id: I975c0e3e01bf08a0aeb0c56c7cde042892a8e72a
parent d4c99ad0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        void onPhoneAccountChanged(Call call);
        void onConferenceableCallsChanged(Call call);
        void onConferenceStateChanged(Call call, boolean isConference);
        void onCdmaConferenceSwap(Call call);
        boolean onCanceledViaNewOutgoingCallBroadcast(Call call, long disconnectionTimeout);
        void onHoldToneRequested(Call call);
        void onCallHoldFailed(Call call);
@@ -208,6 +209,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        @Override
        public void onConferenceStateChanged(Call call, boolean isConference) {}
        @Override
        public void onCdmaConferenceSwap(Call call) {}
        @Override
        public boolean onCanceledViaNewOutgoingCallBroadcast(Call call, long disconnectionTimeout) {
            return false;
        }
@@ -2413,6 +2416,9 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
                    mConferenceLevelActiveCall = null;
                    break;
            }
            for (Listener l : mListeners) {
                l.onCdmaConferenceSwap(this);
            }
        }
    }

+9 −0
Original line number Diff line number Diff line
@@ -166,6 +166,7 @@ public class CallsManager extends Call.ListenerBase
        void onDisconnectedTonePlaying(boolean isTonePlaying);
        void onConnectionTimeChanged(Call call);
        void onConferenceStateChanged(Call call, boolean isConference);
        void onCdmaConferenceSwap(Call call);
    }

    /** Interface used to define the action which is executed delay under some condition. */
@@ -928,6 +929,14 @@ public class CallsManager extends Call.ListenerBase
        }
    }

    @Override
    public void onCdmaConferenceSwap(Call call) {
        // SWAP was executed on a CDMA conference
        for (CallsManagerListener listener : mListeners) {
            listener.onCdmaConferenceSwap(call);
        }
    }

    @Override
    public void onIsVoipAudioModeChanged(Call call) {
        for (CallsManagerListener listener : mListeners) {
+4 −0
Original line number Diff line number Diff line
@@ -100,4 +100,8 @@ public class CallsManagerListenerBase implements CallsManager.CallsManagerListen
    @Override
    public void onConferenceStateChanged(Call call, boolean isConference) {
    }

    @Override
    public void onCdmaConferenceSwap(Call call) {
    }
}
+30 −6
Original line number Diff line number Diff line
@@ -865,7 +865,7 @@ public class InCallController extends CallsManagerListenerBase {
                        info.isExternalCallsSupported(), includeRttCall,
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI);
                try {
                    inCallService.addCall(parcelableCall);
                    inCallService.addCall(sanitizeParcelableCallForService(info, parcelableCall));
                } catch (RemoteException ignored) {
                }
            }
@@ -929,7 +929,7 @@ public class InCallController extends CallsManagerListenerBase {
                        info.isExternalCallsSupported(), includeRttCall,
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI);
                try {
                    inCallService.addCall(parcelableCall);
                    inCallService.addCall(sanitizeParcelableCallForService(info, parcelableCall));
                } catch (RemoteException ignored) {
                }
            }
@@ -961,7 +961,8 @@ public class InCallController extends CallsManagerListenerBase {
                        );

                try {
                    inCallService.updateCall(parcelableCall);
                    inCallService.updateCall(
                            sanitizeParcelableCallForService(info, parcelableCall));
                } catch (RemoteException ignored) {
                }
            }
@@ -1046,6 +1047,12 @@ public class InCallController extends CallsManagerListenerBase {
        updateCall(call);
    }

    @Override
    public void onCdmaConferenceSwap(Call call) {
        Log.d(this, "onCdmaConferenceSwap %s", call);
        updateCall(call);
    }

    void bringToForeground(boolean showDialpad) {
        if (!mInCallServices.isEmpty()) {
            for (IInCallService inCallService : mInCallServices.values()) {
@@ -1446,13 +1453,14 @@ public class InCallController extends CallsManagerListenerBase {
                // Track the call if we don't already know about it.
                addCall(call);
                numCallsSent += 1;
                inCallService.addCall(ParcelableCallUtils.toParcelableCall(
                ParcelableCall parcelableCall = ParcelableCallUtils.toParcelableCall(
                        call,
                        true /* includeVideoProvider */,
                        mCallsManager.getPhoneAccountRegistrar(),
                        info.isExternalCallsSupported(),
                        includeRttCall,
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI));
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI);
                inCallService.addCall(sanitizeParcelableCallForService(info, parcelableCall));
            } catch (RemoteException ignored) {
            }
        }
@@ -1522,7 +1530,8 @@ public class InCallController extends CallsManagerListenerBase {
                componentsUpdated.add(componentName);

                try {
                    inCallService.updateCall(parcelableCall);
                    inCallService.updateCall(
                            sanitizeParcelableCallForService(info, parcelableCall));
                } catch (RemoteException ignored) {
                }
            }
@@ -1654,6 +1663,21 @@ public class InCallController extends CallsManagerListenerBase {
        return childCalls;
    }

    private ParcelableCall sanitizeParcelableCallForService(
            InCallServiceInfo info, ParcelableCall parcelableCall) {
        ParcelableCall.ParcelableCallBuilder builder =
                ParcelableCall.ParcelableCallBuilder.fromParcelableCall(parcelableCall);
        // Check for contacts permission. If it's not there, remove the contactsDisplayName.
        PackageManager pm = mContext.getPackageManager();
        if (pm.checkPermission(Manifest.permission.READ_CONTACTS,
                info.getComponentName().getPackageName()) != PackageManager.PERMISSION_GRANTED) {
            builder.setContactDisplayName(null);
        }

        // TODO: move all the other service-specific sanitizations in here
        return builder.createParcelableCall();
    }

    @VisibleForTesting
    public Handler getHandler() {
        return mHandler;
+69 −62
Original line number Diff line number Diff line
@@ -29,14 +29,10 @@ import android.telecom.ParcelableRttCall;
import android.telecom.TelecomManager;
import android.text.TextUtils;

import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Utilities dealing with {@link ParcelableCall}.
@@ -224,6 +220,11 @@ public class ParcelableCallUtils {
            callDirection = DIRECTION_OUTGOING;
        }

        String activeChildCallId = null;
        if (call.getConferenceLevelActiveCall() != null) {
            activeChildCallId = call.getConferenceLevelActiveCall().getId();
        }

        Bundle extras;
        if (isForSystemDialer) {
            extras = call.getExtras();
@@ -231,35 +232,38 @@ public class ParcelableCallUtils {
            extras = sanitizeExtras(call.getExtras());
        }

        return new ParcelableCall(
                call.getId(),
                state,
                call.getDisconnectCause(),
                call.getCannedSmsResponses(),
                capabilities,
                properties,
                supportedAudioRoutes,
                connectTimeMillis,
                handle,
                call.getHandlePresentation(),
                callerDisplayName,
                call.getCallerDisplayNamePresentation(),
                call.getGatewayInfo(),
                call.getTargetPhoneAccount(),
                includeVideoProvider,
                includeVideoProvider ? call.getVideoProvider() : null,
                includeRttCall,
                rttCall,
                parentCallId,
                childCallIds,
                call.getStatusHints(),
                call.getVideoState(),
                conferenceableCallIds,
                call.getIntentExtras(),
                extras,
                call.getCreationTimeMillis(),
                callDirection,
                call.getCallerNumberVerificationStatus());
        return new ParcelableCall.ParcelableCallBuilder()
                .setId(call.getId())
                .setState(state)
                .setDisconnectCause(call.getDisconnectCause())
                .setCannedSmsResponses(call.getCannedSmsResponses())
                .setCapabilities(capabilities)
                .setProperties(properties)
                .setSupportedAudioRoutes(supportedAudioRoutes)
                .setConnectTimeMillis(connectTimeMillis)
                .setHandle(handle)
                .setHandlePresentation(call.getHandlePresentation())
                .setCallerDisplayName(callerDisplayName)
                .setCallerDisplayNamePresentation(call.getCallerDisplayNamePresentation())
                .setGatewayInfo(call.getGatewayInfo())
                .setAccountHandle(call.getTargetPhoneAccount())
                .setIsVideoCallProviderChanged(includeVideoProvider)
                .setVideoCallProvider(includeVideoProvider ? call.getVideoProvider() : null)
                .setIsRttCallChanged(includeRttCall)
                .setRttCall(rttCall)
                .setParentCallId(parentCallId)
                .setChildCallIds(childCallIds)
                .setStatusHints(call.getStatusHints())
                .setVideoState(call.getVideoState())
                .setConferenceableCallIds(conferenceableCallIds)
                .setIntentExtras(call.getIntentExtras())
                .setExtras(extras)
                .setCreationTimeMillis(call.getCreationTimeMillis())
                .setCallDirection(callDirection)
                .setCallerNumberVerificationStatus(call.getCallerNumberVerificationStatus())
                .setContactDisplayName(call.getName())
                .setActiveChildCallId(activeChildCallId)
                .createParcelableCall();
    }

    /**
@@ -303,35 +307,38 @@ public class ParcelableCallUtils {
            callExtras = new Bundle();
        }

        return new ParcelableCall(
                call.getId(),
                getParcelableState(call, false /* supportsExternalCalls */),
                new DisconnectCause(DisconnectCause.UNKNOWN),
                null, /* cannedSmsResponses */
                0, /* capabilities */
                0, /* properties */
                0, /* supportedAudioRoutes */
                call.getConnectTimeMillis(),
                handle,
                call.getHandlePresentation(),
                null, /* callerDisplayName */
                0 /* callerDisplayNamePresentation */,
                null, /* gatewayInfo */
                null, /* targetPhoneAccount */
                false, /* includeVideoProvider */
                null, /* videoProvider */
                false, /* includeRttCall */
                null, /* rttCall */
                null, /* parentCallId */
                null, /* childCallIds */
                null, /* statusHints */
                0, /* videoState */
                Collections.emptyList(), /* conferenceableCallIds */
                null, /* intentExtras */
                callExtras, /* callExtras */
                call.getCreationTimeMillis(),
                callDirection,
                call.getCallerNumberVerificationStatus());
        return new ParcelableCall.ParcelableCallBuilder()
                .setId(call.getId())
                .setState(getParcelableState(call, false /* supportsExternalCalls */))
                .setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN))
                .setCannedSmsResponses(null)
                .setCapabilities(0)
                .setProperties(0)
                .setSupportedAudioRoutes(0)
                .setConnectTimeMillis(call.getConnectTimeMillis())
                .setHandle(handle)
                .setHandlePresentation(call.getHandlePresentation())
                .setCallerDisplayName(null)
                .setCallerDisplayNamePresentation(0)
                .setGatewayInfo(null)
                .setAccountHandle(null)
                .setIsVideoCallProviderChanged(false)
                .setVideoCallProvider(null)
                .setIsRttCallChanged(false)
                .setRttCall(null)
                .setParentCallId(null)
                .setChildCallIds(null)
                .setStatusHints(null)
                .setVideoState(0)
                .setConferenceableCallIds(Collections.emptyList())
                .setIntentExtras(null)
                .setExtras(callExtras)
                .setCreationTimeMillis(call.getCreationTimeMillis())
                .setCallDirection(callDirection)
                .setCallerNumberVerificationStatus(call.getCallerNumberVerificationStatus())
                .setContactDisplayName(null)
                .setActiveChildCallId(null)
                .createParcelableCall();
    }

    /**
Loading