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

Commit d51be634 authored by Nivedita Sarkar's avatar Nivedita Sarkar Committed by Bruno Martins
Browse files

Bluetooth: Support to know if there is High Def call

Support to know if there a High def call

Change-Id: Ieedcc0aa8b23eeabe75ad2670efcf1c371b00296
CRs-fixed: 2450295
parent a1f9ba43
Loading
Loading
Loading
Loading
+38 −1
Original line number Diff line number Diff line
@@ -27,16 +27,19 @@ import android.content.IntentFilter;
import android.net.Uri;
import android.os.Binder;
import android.os.IBinder;
import android.os.Bundle;
import android.os.RemoteException;
import android.telecom.Connection;
import android.telecom.Log;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
import android.telecom.VideoProfile;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.PhoneConstants;
import com.android.server.telecom.CallsManager.CallsManagerListener;

import java.util.Collection;
@@ -253,6 +256,40 @@ public class BluetoothPhoneServiceImpl {
            }
        }

       /**
        * @return true if there is any call is in progress with High Definition.
        */
        @Override
        public boolean isHighDefCallInProgress() {
            boolean isHighDef = false;
            Call ringingCall = mCallsManager.getRingingCall();
            Call dialingCall = mCallsManager.getOutgoingCall();
            Call activeCall = mCallsManager.getActiveCall();

            /* If its an incoming call we will have codec info in dialing state */
            if (ringingCall != null) {
                isHighDef = ringingCall.hasProperty(Connection.PROPERTY_HIGH_DEF_AUDIO);
            } else if (dialingCall != null) { /* CS dialing call has codec info in dialing state */
                Bundle extras = dialingCall.getExtras();
                if (extras != null) {
                    int phoneType = extras.getInt(
                        TelecomManager.EXTRA_CALL_TECHNOLOGY_TYPE);
                    if (phoneType == PhoneConstants.PHONE_TYPE_GSM
                        || phoneType == PhoneConstants.PHONE_TYPE_CDMA) {
                        isHighDef = dialingCall.hasProperty(Connection.PROPERTY_HIGH_DEF_AUDIO);
                    /* For IMS calls codec info is not present in dialing state */
                    } else if (phoneType == PhoneConstants.PHONE_TYPE_IMS
                        || phoneType == PhoneConstants.PHONE_TYPE_CDMA_LTE) {
                        isHighDef = true;
                    }
                }
            } else if (activeCall != null) {
                isHighDef = activeCall.hasProperty(Connection.PROPERTY_HIGH_DEF_AUDIO);
            }
            Log.i(TAG, "isHighDefCallInProgress: Call is High Def " + isHighDef);
            return isHighDef;
        }

        @Override
        public boolean processChld(int chld) throws RemoteException {
            synchronized (mLock) {
@@ -848,7 +885,7 @@ public class BluetoothPhoneServiceImpl {
        int bluetoothCallState = CALL_STATE_IDLE;
        if (ringingCall != null && !ringingCall.isSilentRingingRequested()) {
            bluetoothCallState = CALL_STATE_INCOMING;
        } else if (dialingCall != null) {
        } else if (dialingCall != null && dialingCall.getState() == CallState.DIALING) {
            bluetoothCallState = CALL_STATE_ALERTING;
        } else if (hasOnlyDisconnectedCalls || mIsDisconnectedTonePlaying) {
            // Keep the DISCONNECTED state until the disconnect tone's playback is done