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

Commit 1e941c84 authored by Mariusz Skamra's avatar Mariusz Skamra Committed by Jack He
Browse files

gtbs: Add Generic Telephone Bearer Service implementation

This adds Generic Telephone Bearer Service (GTBS) implementation
and exposes API that allows other TBS instances to be registered
by applications which want to expose their call control interfaces
over Bluetooth.

The GTBS aggregates call states of all the registered TBSes.
Each Call from GATT Client perspective is identified by a call
index assigned by TbsServerService, which is unique across TBS
instances and GTBS. From an application perspective, a call is
identified by the BluetoothTbsCall instance which has a unique UUID.

Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
test: Test: atest BluetoothInstrumentationTests
Change-Id: I652a40b3f1ce01fc57f0afea451ed1d39781ed36
parent 4212da62
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -449,6 +449,15 @@
                <action android:name="android.bluetooth.IBluetoothCsipSetCoordinator" />
            </intent-filter>
        </service>
        <service
            android:process="@string/process"
            android:name = ".tbs.TbsService"
            android:enabled="@bool/profile_supported_le_call_control"
            android:exported = "true">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothLeCallControl" />
            </intent-filter>
        </service>
        <!-- Authenticator for PBAP account. -->
        <service android:process="@string/process"
             android:name=".pbapclient.AuthenticationService"
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
    <bool name="profile_supported_vc">true</bool>
    <bool name="profile_supported_mcp_server">true</bool>
    <bool name="profile_supported_csip_set_coordinator">true</bool>
    <bool name="profile_supported_le_call_control">true</bool>

    <!-- If true, we will require location to be enabled on the device to
         fire Bluetooth LE scan result callbacks in addition to having one
+3 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.bluetooth.pbap.BluetoothPbapService;
import com.android.bluetooth.pbapclient.PbapClientService;
import com.android.bluetooth.sap.SapService;
import com.android.bluetooth.vc.VolumeControlService;
import com.android.bluetooth.tbs.TbsService;

import java.util.ArrayList;
import java.util.Arrays;
@@ -121,6 +122,8 @@ public class Config {
                    (1 << BluetoothProfile.VOLUME_CONTROL)),
            new ProfileConfig(McpService.class, R.bool.profile_supported_mcp_server,
                    (1 << BluetoothProfile.MCP_SERVER)),
            new ProfileConfig(TbsService.class, R.bool.profile_supported_le_call_control,
                    (1 << BluetoothProfile.LE_CALL_CONTROL)),
            new ProfileConfig(HearingAidService.class,
                    com.android.internal.R.bool.config_hearing_aid_profile_supported,
                    (1 << BluetoothProfile.HEARING_AID)),
+5 −0
Original line number Diff line number Diff line
@@ -119,6 +119,9 @@ class Metadata {
            case BluetoothProfile.CSIP_SET_COORDINATOR:
                profileConnectionPolicies.csip_set_coordinator_connection_policy = connectionPolicy;
                break;
            case BluetoothProfile.LE_CALL_CONTROL:
                profileConnectionPolicies.le_call_control_connection_policy = connectionPolicy;
                break;
            default:
                throw new IllegalArgumentException("invalid profile " + profile);
        }
@@ -156,6 +159,8 @@ class Metadata {
                return profileConnectionPolicies.volume_control_connection_policy;
            case BluetoothProfile.CSIP_SET_COORDINATOR:
                return profileConnectionPolicies.csip_set_coordinator_connection_policy;
            case BluetoothProfile.LE_CALL_CONTROL:
                return profileConnectionPolicies.le_call_control_connection_policy;
        }
        return BluetoothProfile.CONNECTION_POLICY_UNKNOWN;
    }
+20 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import java.util.List;
/**
 * MetadataDatabase is a Room database stores Bluetooth persistence data
 */
@Database(entities = {Metadata.class}, version = 108)
@Database(entities = {Metadata.class}, version = 109)
public abstract class MetadataDatabase extends RoomDatabase {
    /**
     * The metadata database file name
@@ -61,6 +61,7 @@ public abstract class MetadataDatabase extends RoomDatabase {
                .addMigrations(MIGRATION_105_106)
                .addMigrations(MIGRATION_106_107)
                .addMigrations(MIGRATION_107_108)
                .addMigrations(MIGRATION_108_109)
                .allowMainThreadQueries()
                .build();
    }
@@ -388,4 +389,22 @@ public abstract class MetadataDatabase extends RoomDatabase {
            }
        }
    };

    @VisibleForTesting
    static final Migration MIGRATION_108_109 = new Migration(108, 109) {
        @Override
        public void migrate(SupportSQLiteDatabase database) {
            try {
                database.execSQL(
                        "ALTER TABLE metadata ADD COLUMN `le_call_control_connection_policy` "
                        + "INTEGER DEFAULT 100");
            } catch (SQLException ex) {
                // Check if user has new schema, but is just missing the version update
                Cursor cursor = database.query("SELECT * FROM metadata");
                if (cursor == null || cursor.getColumnIndex("le_call_control_connection_policy") == -1) {
                    throw ex;
                }
            }
        }
    };
}
Loading