1ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal/*
2ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * Copyright (C) 2016 The Android Open Source Project
3ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal *
4ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * Licensed under the Apache License, Version 2.0 (the "License");
5ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * you may not use this file except in compliance with the License.
6ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * You may obtain a copy of the License at
7ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal *
8ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal *      http://www.apache.org/licenses/LICENSE-2.0
9ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal *
10ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * Unless required by applicable law or agreed to in writing, software
11ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * distributed under the License is distributed on an "AS IS" BASIS,
12ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * See the License for the specific language governing permissions and
14ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * limitations under the License
15ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal */
16ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
17ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalpackage com.android.server.telecom;
18ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
19ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalimport android.net.Uri;
20ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalimport android.telecom.Connection;
21ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalimport android.telecom.ParcelableCall;
22dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liuimport android.telecom.ParcelableRttCall;
23ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalimport android.telecom.TelecomManager;
24ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
25ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalimport java.util.ArrayList;
26ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalimport java.util.List;
27ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
28ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal/**
29ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal * Utilities dealing with {@link ParcelableCall}.
30ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal */
31ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepalpublic class ParcelableCallUtils {
321e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn    private static final int CALL_STATE_OVERRIDE_NONE = -1;
331e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn
346d4b66df3d918e3f17263ff40ca3ba0ec5a46719Hall Liu    public static class Converter {
356d4b66df3d918e3f17263ff40ca3ba0ec5a46719Hall Liu        public ParcelableCall toParcelableCall(Call call, boolean includeVideoProvider,
366d4b66df3d918e3f17263ff40ca3ba0ec5a46719Hall Liu                PhoneAccountRegistrar phoneAccountRegistrar) {
376d4b66df3d918e3f17263ff40ca3ba0ec5a46719Hall Liu            return ParcelableCallUtils.toParcelableCall(
38dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu                    call, includeVideoProvider, phoneAccountRegistrar, false, false);
396d4b66df3d918e3f17263ff40ca3ba0ec5a46719Hall Liu        }
406d4b66df3d918e3f17263ff40ca3ba0ec5a46719Hall Liu    }
416d4b66df3d918e3f17263ff40ca3ba0ec5a46719Hall Liu
42ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    /**
43ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     * Parcels all information for a {@link Call} into a new {@link ParcelableCall} instance.
44ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     *
45ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     * @param call The {@link Call} to parcel.
46ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     * @param includeVideoProvider {@code true} if the video provider should be parcelled with the
47ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     *      {@link Call}, {@code false} otherwise.  Since the {@link ParcelableCall#getVideoCall()}
48ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     *      method creates a {@link VideoCallImpl} instance on access it is important for the
49ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     *      recipient of the {@link ParcelableCall} to know if the video provider changed.
50ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     * @param phoneAccountRegistrar The {@link PhoneAccountRegistrar}.
511e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     * @param supportsExternalCalls Indicates whether the call should be parcelled for an
521e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     *      {@link InCallService} which supports external calls or not.
531e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     */
541e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn    public static ParcelableCall toParcelableCall(
551e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            Call call,
561e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            boolean includeVideoProvider,
571e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            PhoneAccountRegistrar phoneAccountRegistrar,
58dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu            boolean supportsExternalCalls,
59dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu            boolean includeRttCall) {
601e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn        return toParcelableCall(call, includeVideoProvider, phoneAccountRegistrar,
61dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu                supportsExternalCalls, CALL_STATE_OVERRIDE_NONE /* overrideState */,
62dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu                includeRttCall);
631e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn    }
641e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn
651e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn    /**
661e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     * Parcels all information for a {@link Call} into a new {@link ParcelableCall} instance.
671e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     *
681e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     * @param call The {@link Call} to parcel.
691e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     * @param includeVideoProvider {@code true} if the video provider should be parcelled with the
701e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     *      {@link Call}, {@code false} otherwise.  Since the {@link ParcelableCall#getVideoCall()}
711e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     *      method creates a {@link VideoCallImpl} instance on access it is important for the
721e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     *      recipient of the {@link ParcelableCall} to know if the video provider changed.
731e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     * @param phoneAccountRegistrar The {@link PhoneAccountRegistrar}.
741e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     * @param supportsExternalCalls Indicates whether the call should be parcelled for an
751e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     *      {@link InCallService} which supports external calls or not.
761e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     * @param overrideState When not {@link #CALL_STATE_OVERRIDE_NONE}, use the provided state as an
771e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn     *      override to whatever is defined in the call.
78ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     * @return The {@link ParcelableCall} containing all call information from the {@link Call}.
79ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     */
80ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    public static ParcelableCall toParcelableCall(
81ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            Call call,
82ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            boolean includeVideoProvider,
831e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            PhoneAccountRegistrar phoneAccountRegistrar,
841e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            boolean supportsExternalCalls,
85dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu            int overrideState,
86dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu            boolean includeRttCall) {
871e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn        int state;
881e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn        if (overrideState == CALL_STATE_OVERRIDE_NONE) {
891e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            state = getParcelableState(call, supportsExternalCalls);
901e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn        } else {
911e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            state = overrideState;
921e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn        }
93ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        int capabilities = convertConnectionToCallCapabilities(call.getConnectionCapabilities());
94571d5e66b8cbee023702b4b0a2a1c28663c5a7f8Tyler Gunn        int properties = convertConnectionToCallProperties(call.getConnectionProperties());
95ffe558c570ae5736d47fded2caccc7da145e7d92Christine Hallstrom        int supportedAudioRoutes = call.getSupportedAudioRoutes();
96ffe558c570ae5736d47fded2caccc7da145e7d92Christine Hallstrom
97ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        if (call.isConference()) {
98ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            properties |= android.telecom.Call.Details.PROPERTY_CONFERENCE;
99ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
100ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
101d29d93778fe288d87aef03e0a934099995b550bfTony Mak        if (call.isWorkCall()) {
102d9ec0ea4e4821b0ba4287df7c44c42ae77ca8a89Tony Mak            properties |= android.telecom.Call.Details.PROPERTY_ENTERPRISE_CALL;
103ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
104ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
105ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        // If this is a single-SIM device, the "default SIM" will always be the only SIM.
10628b82f0fe9b55b3bd826ba3a4204329988447c57Hall Liu        boolean isDefaultSmsAccount = phoneAccountRegistrar != null &&
107ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                phoneAccountRegistrar.isUserSelectedSmsPhoneAccount(call.getTargetPhoneAccount());
108ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        if (call.isRespondViaSmsCapable() && isDefaultSmsAccount) {
109ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            capabilities |= android.telecom.Call.Details.CAPABILITY_RESPOND_VIA_TEXT;
110ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
111ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
112ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        if (call.isEmergencyCall()) {
113ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            capabilities = removeCapability(
114ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                    capabilities, android.telecom.Call.Details.CAPABILITY_MUTE);
115ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
116ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
117ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        if (state == android.telecom.Call.STATE_DIALING) {
118ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            capabilities = removeCapability(capabilities,
119ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                    android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL);
120ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            capabilities = removeCapability(capabilities,
121ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                    android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL);
122ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
123ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
124ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        String parentCallId = null;
125ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Call parentCall = call.getParentCall();
126ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        if (parentCall != null) {
127ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            parentCallId = parentCall.getId();
128ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
129ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
130ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        long connectTimeMillis = call.getConnectTimeMillis();
131ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        List<Call> childCalls = call.getChildCalls();
132ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        List<String> childCallIds = new ArrayList<>();
133ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        if (!childCalls.isEmpty()) {
134ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            long childConnectTimeMillis = Long.MAX_VALUE;
135ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            for (Call child : childCalls) {
136ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                if (child.getConnectTimeMillis() > 0) {
137ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                    childConnectTimeMillis = Math.min(child.getConnectTimeMillis(),
138ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                            childConnectTimeMillis);
139ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                }
140ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                childCallIds.add(child.getId());
141ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            }
142ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
143ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            if (childConnectTimeMillis != Long.MAX_VALUE) {
144ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                connectTimeMillis = childConnectTimeMillis;
145ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            }
146ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
147ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
148ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Uri handle = call.getHandlePresentation() == TelecomManager.PRESENTATION_ALLOWED ?
149ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getHandle() : null;
150ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        String callerDisplayName = call.getCallerDisplayNamePresentation() ==
151ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                TelecomManager.PRESENTATION_ALLOWED ?  call.getCallerDisplayName() : null;
152ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
153ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        List<Call> conferenceableCalls = call.getConferenceableCalls();
154ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        List<String> conferenceableCallIds = new ArrayList<String>(conferenceableCalls.size());
155ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        for (Call otherCall : conferenceableCalls) {
156ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            conferenceableCallIds.add(otherCall.getId());
157ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
158ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
159dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu        ParcelableRttCall rttCall = includeRttCall ? getParcelableRttCall(call) : null;
160dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu
161ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        return new ParcelableCall(
162ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getId(),
163ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state,
164ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getDisconnectCause(),
165ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getCannedSmsResponses(),
166ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                capabilities,
167ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                properties,
168ffe558c570ae5736d47fded2caccc7da145e7d92Christine Hallstrom                supportedAudioRoutes,
169ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                connectTimeMillis,
170ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                handle,
171ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getHandlePresentation(),
172ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                callerDisplayName,
173ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getCallerDisplayNamePresentation(),
174ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getGatewayInfo(),
175ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getTargetPhoneAccount(),
176ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                includeVideoProvider,
177ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                includeVideoProvider ? call.getVideoProvider() : null,
178dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu                includeRttCall,
179dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu                rttCall,
180ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                parentCallId,
181ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                childCallIds,
182ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getStatusHints(),
183ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getVideoState(),
184ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                conferenceableCallIds,
185ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                call.getIntentExtras(),
18600af1c86264d80dbdeff8d28f250b6eda7f00ebbTyler Gunn                call.getExtras(),
18700af1c86264d80dbdeff8d28f250b6eda7f00ebbTyler Gunn                call.getCreationTimeMillis());
188ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    }
189ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
1901e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn    private static int getParcelableState(Call call, boolean supportsExternalCalls) {
191ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        int state = CallState.NEW;
192ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        switch (call.getState()) {
193ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.ABORTED:
194ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.DISCONNECTED:
195ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_DISCONNECTED;
196ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
197ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.ACTIVE:
198ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_ACTIVE;
199ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
200ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.CONNECTING:
201ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_CONNECTING;
202ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
203ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.DIALING:
204ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_DIALING;
205ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
2061e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn            case CallState.PULLING:
2071e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                if (supportsExternalCalls) {
2081e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    // The InCallService supports external calls, so it must handle
2091e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    // STATE_PULLING_CALL.
2101e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    state = android.telecom.Call.STATE_PULLING_CALL;
2111e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                } else {
2121e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    // The InCallService does NOT support external calls, so remap
2131e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    // STATE_PULLING_CALL to STATE_DIALING.  In essence, pulling a call can be seen
2141e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    // as a form of dialing, so it is appropriate for InCallServices which do not
2151e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    // handle external calls.
2161e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                    state = android.telecom.Call.STATE_DIALING;
2171e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                }
2181e37be5dd86a51b90e461f09dc8a89effe4aee21Tyler Gunn                break;
219ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.DISCONNECTING:
220ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_DISCONNECTING;
221ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
222ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.NEW:
223ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_NEW;
224ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
225ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.ON_HOLD:
226ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_HOLDING;
227ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
228ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.RINGING:
229ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_RINGING;
230ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
231ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            case CallState.SELECT_PHONE_ACCOUNT:
232ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                state = android.telecom.Call.STATE_SELECT_PHONE_ACCOUNT;
233ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                break;
234ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
235ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
236ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        // If we are marked as 'locally disconnecting' then mark ourselves as disconnecting instead.
237ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        // Unless we're disconnect*ED*, in which case leave it at that.
238ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        if (call.isLocallyDisconnecting() &&
239ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                (state != android.telecom.Call.STATE_DISCONNECTED)) {
240ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            state = android.telecom.Call.STATE_DISCONNECTING;
241ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
242ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        return state;
243ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    }
244ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
245ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    private static final int[] CONNECTION_TO_CALL_CAPABILITY = new int[] {
246ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_HOLD,
247ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_HOLD,
248ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
249ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SUPPORT_HOLD,
250ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SUPPORT_HOLD,
251ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
252ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_MERGE_CONFERENCE,
253ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_MERGE_CONFERENCE,
254ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
255ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SWAP_CONFERENCE,
256ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SWAP_CONFERENCE,
257ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
258ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_RESPOND_VIA_TEXT,
259ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_RESPOND_VIA_TEXT,
260ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
261ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_MUTE,
262ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_MUTE,
263ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
264ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_MANAGE_CONFERENCE,
265ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_MANAGE_CONFERENCE,
266ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
267ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SUPPORTS_VT_LOCAL_RX,
268ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL_RX,
269ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
270ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SUPPORTS_VT_LOCAL_TX,
271ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL_TX,
272ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
273ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL,
274ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL,
275ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
276ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SUPPORTS_VT_REMOTE_RX,
277ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE_RX,
278ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
279ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SUPPORTS_VT_REMOTE_TX,
280ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE_TX,
281ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
282ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL,
283ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL,
284ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
285ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_SEPARATE_FROM_CONFERENCE,
286ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_SEPARATE_FROM_CONFERENCE,
287ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
288ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_DISCONNECT_FROM_CONFERENCE,
289ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_DISCONNECT_FROM_CONFERENCE,
290ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
291ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_CAN_UPGRADE_TO_VIDEO,
292ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_CAN_UPGRADE_TO_VIDEO,
293ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
294ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_CAN_PAUSE_VIDEO,
295ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_CAN_PAUSE_VIDEO,
296ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
297ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION,
298ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION,
299ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
300ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        Connection.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO,
301d45e6d973ea7460fb605a1eb7a66ba38c6f2467dTyler Gunn        android.telecom.Call.Details.CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO,
302d45e6d973ea7460fb605a1eb7a66ba38c6f2467dTyler Gunn
303d45e6d973ea7460fb605a1eb7a66ba38c6f2467dTyler Gunn        Connection.CAPABILITY_CAN_PULL_CALL,
304ad4ebc022bf8a28958606121a1a2a0c4130dc821Pooja Jain        android.telecom.Call.Details.CAPABILITY_CAN_PULL_CALL,
305ad4ebc022bf8a28958606121a1a2a0c4130dc821Pooja Jain
306ad4ebc022bf8a28958606121a1a2a0c4130dc821Pooja Jain        Connection.CAPABILITY_SUPPORT_DEFLECT,
307ad4ebc022bf8a28958606121a1a2a0c4130dc821Pooja Jain        android.telecom.Call.Details.CAPABILITY_SUPPORT_DEFLECT
308ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    };
309ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
310ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    private static int convertConnectionToCallCapabilities(int connectionCapabilities) {
311ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        int callCapabilities = 0;
312ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        for (int i = 0; i < CONNECTION_TO_CALL_CAPABILITY.length; i += 2) {
313ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            if ((CONNECTION_TO_CALL_CAPABILITY[i] & connectionCapabilities) ==
314ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                    CONNECTION_TO_CALL_CAPABILITY[i]) {
315ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
316ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                callCapabilities |= CONNECTION_TO_CALL_CAPABILITY[i + 1];
317ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            }
318ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
319ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        return callCapabilities;
320ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    }
321ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
322ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    private static final int[] CONNECTION_TO_CALL_PROPERTIES = new int[] {
323571d5e66b8cbee023702b4b0a2a1c28663c5a7f8Tyler Gunn        Connection.PROPERTY_HIGH_DEF_AUDIO,
324ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.PROPERTY_HIGH_DEF_AUDIO,
325ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
326571d5e66b8cbee023702b4b0a2a1c28663c5a7f8Tyler Gunn        Connection.PROPERTY_WIFI,
327ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.PROPERTY_WIFI,
328ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
329571d5e66b8cbee023702b4b0a2a1c28663c5a7f8Tyler Gunn        Connection.PROPERTY_GENERIC_CONFERENCE,
330ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        android.telecom.Call.Details.PROPERTY_GENERIC_CONFERENCE,
331ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
332ddf3f9c445699db2034da580db02dcaaddcdd322Hall Liu        Connection.PROPERTY_EMERGENCY_CALLBACK_MODE,
333d45e6d973ea7460fb605a1eb7a66ba38c6f2467dTyler Gunn        android.telecom.Call.Details.PROPERTY_EMERGENCY_CALLBACK_MODE,
334d45e6d973ea7460fb605a1eb7a66ba38c6f2467dTyler Gunn
335571d5e66b8cbee023702b4b0a2a1c28663c5a7f8Tyler Gunn        Connection.PROPERTY_IS_EXTERNAL_CALL,
33684771f8f87f5f582bf848b621eed8c6cd99d41b0Brad Ebinger        android.telecom.Call.Details.PROPERTY_IS_EXTERNAL_CALL,
33784771f8f87f5f582bf848b621eed8c6cd99d41b0Brad Ebinger
33884771f8f87f5f582bf848b621eed8c6cd99d41b0Brad Ebinger        Connection.PROPERTY_HAS_CDMA_VOICE_PRIVACY,
33937e782b421f63a81bfae1efaa1eb01f0fbdd7abfTyler Gunn        android.telecom.Call.Details.PROPERTY_HAS_CDMA_VOICE_PRIVACY,
34037e782b421f63a81bfae1efaa1eb01f0fbdd7abfTyler Gunn
34137e782b421f63a81bfae1efaa1eb01f0fbdd7abfTyler Gunn        Connection.PROPERTY_SELF_MANAGED,
34207294864544f27bdca0fd8d429d083d9b4d4d7daEric Erfanian        android.telecom.Call.Details.PROPERTY_SELF_MANAGED,
34307294864544f27bdca0fd8d429d083d9b4d4d7daEric Erfanian
34407294864544f27bdca0fd8d429d083d9b4d4d7daEric Erfanian        Connection.PROPERTY_ASSISTED_DIALING_USED,
345ea67a76715cf3b961c61559d5a35cd182087a263Hall Liu        android.telecom.Call.Details.PROPERTY_ASSISTED_DIALING_USED,
346ea67a76715cf3b961c61559d5a35cd182087a263Hall Liu
347ea67a76715cf3b961c61559d5a35cd182087a263Hall Liu        Connection.PROPERTY_IS_RTT,
348ea67a76715cf3b961c61559d5a35cd182087a263Hall Liu        android.telecom.Call.Details.PROPERTY_RTT
349ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    };
350ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
351571d5e66b8cbee023702b4b0a2a1c28663c5a7f8Tyler Gunn    private static int convertConnectionToCallProperties(int connectionProperties) {
352ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        int callProperties = 0;
353ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        for (int i = 0; i < CONNECTION_TO_CALL_PROPERTIES.length; i += 2) {
354571d5e66b8cbee023702b4b0a2a1c28663c5a7f8Tyler Gunn            if ((CONNECTION_TO_CALL_PROPERTIES[i] & connectionProperties) ==
355ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                    CONNECTION_TO_CALL_PROPERTIES[i]) {
356ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
357ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal                callProperties |= CONNECTION_TO_CALL_PROPERTIES[i + 1];
358ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal            }
359ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        }
360ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        return callProperties;
361ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    }
362ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
363ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    /**
364ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     * Removes the specified capability from the set of capabilities bits and returns the new set.
365ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal     */
366ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    private static int removeCapability(int capabilities, int capability) {
367ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal        return capabilities & ~capability;
368ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    }
369ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal
370dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu    private static ParcelableRttCall getParcelableRttCall(Call call) {
371dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu        if (!call.isRttCall()) {
372dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu            return null;
373dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu        }
374dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu        return new ParcelableRttCall(call.getRttMode(), call.getInCallToCsRttPipeForInCall(),
375dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu                call.getCsToInCallRttPipeForInCall());
376dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu    }
377dd68bc36a3278557b1c4d9183ed9e3dee077eb20Hall Liu
378ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal    private ParcelableCallUtils() {}
379ae92595c2f0f88a5bef8d2601f026b9d3ae2d7ddSailesh Nepal}
380