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

Commit 40adc10d authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

Tbs: Set default technology bearer to GSM

This is used only when there is no call and no bearer is registered.
Also, in this patch we add mapping from TelephonyManager network types
to the Bluetooth Bearer Technology values from Bluetooth Assigned
Numbers.

Bug: 233335655
Test: atest BluetoothInstrumentationTests
Tag: #feature

Change-Id: Ieeff9d05e2e746e96d91c1ca225887b46e52fbb7
parent 7d9b2546
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -17,10 +17,9 @@

package com.android.bluetooth.tbs;

import android.bluetooth.BluetoothLeCallControl;
import android.bluetooth.BluetoothLeCall;
import android.bluetooth.BluetoothLeCallControl;

import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executor;
@@ -36,6 +35,16 @@ public class BluetoothLeCallControlProxy {

    private BluetoothLeCallControl mBluetoothLeCallControl;

    public static final int BEARER_TECHNOLOGY_3G = 0x01;
    public static final int BEARER_TECHNOLOGY_4G = 0x02;
    public static final int BEARER_TECHNOLOGY_LTE = 0x03;
    public static final int BEARER_TECHNOLOGY_WIFI = 0x04;
    public static final int BEARER_TECHNOLOGY_5G = 0x05;
    public static final int BEARER_TECHNOLOGY_GSM = 0x06;
    public static final int BEARER_TECHNOLOGY_CDMA = 0x07;
    public static final int BEARER_TECHNOLOGY_2G = 0x08;
    public static final int BEARER_TECHNOLOGY_WCDMA = 0x09;

    public BluetoothLeCallControlProxy(BluetoothLeCallControl tbs) {
        mBluetoothLeCallControl = tbs;
    }
+5 −1
Original line number Diff line number Diff line
@@ -52,7 +52,11 @@ public class TbsGeneric {

    private static final String UCI = "GTBS";
    private static final String DEFAULT_PROVIDER_NAME = "none";
    private static final int DEFAULT_BEARER_TECHNOLOGY = 0x00;
    /* Use GSM as default technology value. It is used only
     * when bearer is not registered. It will be updated on the phone call
     */
    private static final int DEFAULT_BEARER_TECHNOLOGY =
            BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_GSM;
    private static final String UNKNOWN_FRIENDLY_NAME = "unknown";

    /** Class representing the pending request sent to the application */
+60 −3
Original line number Diff line number Diff line
@@ -417,6 +417,62 @@ public class BluetoothInCallService extends InCallService {
        }
    }

    /**
     * Gets the brearer technology.
     *
     * @return bearer technology as defined in Bluetooth Assigned Numbers
     */
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public int getBearerTechnology()  {
        synchronized (LOCK) {
            enforceModifyPermission();
            Log.i(TAG, "getBearerTechnology");
            // Get the network name from telephony.
            int dataNetworkType = mTelephonyManager.getDataNetworkType();
            switch (dataNetworkType) {
                case TelephonyManager.NETWORK_TYPE_UNKNOWN:
                case TelephonyManager.NETWORK_TYPE_GSM:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_GSM;

                case TelephonyManager.NETWORK_TYPE_GPRS:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_2G;

                case TelephonyManager.NETWORK_TYPE_EDGE :
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_3G;

                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_WCDMA;

                case TelephonyManager.NETWORK_TYPE_LTE:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_LTE;

                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_CDMA;

                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_4G;

                case TelephonyManager.NETWORK_TYPE_IWLAN:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_WIFI;

                case TelephonyManager.NETWORK_TYPE_NR:
                    return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_5G;
            }

            return BluetoothLeCallControlProxy.BEARER_TECHNOLOGY_GSM;
        }
    }

    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public String getSubscriberNumber() {
        synchronized (LOCK) {
@@ -1241,9 +1297,10 @@ public class BluetoothInCallService extends InCallService {
        mBluetoothLeCallControl = bluetoothTbs;

        if ((mBluetoothLeCallControl) != null && (mTelecomManager != null)) {
            mBluetoothLeCallControl.registerBearer(TAG, new ArrayList<String>(Arrays.asList("tel")),
                    BluetoothLeCallControl.CAPABILITY_HOLD_CALL, getNetworkOperator(), 0x01, mExecutor,
                    mBluetoothLeCallControlCallback);
            mBluetoothLeCallControl.registerBearer(TAG,
                    new ArrayList<String>(Arrays.asList("tel")),
                    BluetoothLeCallControl.CAPABILITY_HOLD_CALL, getNetworkOperator(),
                    getBearerTechnology(), mExecutor, mBluetoothLeCallControlCallback);
        }
    }