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

Commit b2e284b3 authored by Sal Savage's avatar Sal Savage Committed by Automerger Merge Worker
Browse files

Merge "Support the GATT profile by default" into tm-dev am: 135c86ef am: d943919f

parents 0eb735b9 d943919f
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -424,6 +424,8 @@ public class AdapterService extends Service {
                        return;
                    }
                    mRunningProfiles.add(profile);
                    // TODO(b/228875190): GATT is assumed supported. GATT starting triggers hardware
                    // initializtion. Configuring a device without GATT causes start up failures.
                    if (GattService.class.getSimpleName().equals(profile.getName())) {
                        enableNative();
                    } else if (mRegisteredProfiles.size() == Config.getSupportedProfiles().length
@@ -448,7 +450,9 @@ public class AdapterService extends Service {
                        return;
                    }
                    mRunningProfiles.remove(profile);
                    // If only GATT is left, send BREDR_STOPPED.
                    // TODO(b/228875190): GATT is assumed supported. GATT is expected to be the only
                    // profile available in the "BLE ON" state. If only GATT is left, send
                    // BREDR_STOPPED. If GATT is stopped, deinitialize the hardware.
                    if ((mRunningProfiles.size() == 1 && (GattService.class.getSimpleName()
                            .equals(mRunningProfiles.get(0).getName())))) {
                        mAdapterStateMachine.sendMessage(AdapterState.BREDR_STOPPED);
@@ -645,7 +649,13 @@ public class AdapterService extends Service {
        BluetoothStatsLog.write_non_chained(BluetoothStatsLog.BLE_SCAN_STATE_CHANGED, -1, null,
                BluetoothStatsLog.BLE_SCAN_STATE_CHANGED__STATE__RESET, false, false, false);

        //Start Gatt service
        // TODO(b/228875190): GATT is assumed supported. As a result, we don't respect the
        // configuration sysprop. Configuring a device without GATT, although rare, will cause stack
        // start up errors yielding init loops.
        if (!GattService.isEnabled()) {
            Log.w(TAG,
                    "GATT is configured off but the stack assumes it to be enabled. Start anyway.");
        }
        setProfileServiceState(GattService.class, BluetoothAdapter.STATE_ON);
    }

@@ -682,10 +692,11 @@ public class AdapterService extends Service {
    void startProfileServices() {
        debugLog("startCoreServices()");
        Class[] supportedProfileServices = Config.getSupportedProfiles();
        // If we support no profiles, or we only support GATT/BLE, just move on to BREDR_STARTED
        if (supportedProfileServices.length == 0
                || (supportedProfileServices.length == 1 && GattService.class.getSimpleName()
                .equals(supportedProfileServices[0].getSimpleName()))) {
        // TODO(b/228875190): GATT is assumed supported. If we support no other profiles then just
        // move on to BREDR_STARTED. Note that configuring GATT to NOT supported will cause adapter
        // initialization failures
        if (supportedProfileServices.length == 1 && GattService.class.getSimpleName()
                .equals(supportedProfileServices[0].getSimpleName())) {
            mAdapterProperties.onBluetoothReady();
            updateUuids();
            setBluetoothClassFromConfig();
@@ -701,10 +712,10 @@ public class AdapterService extends Service {
        mAdapterProperties.setScanMode(AbstractionLayer.BT_SCAN_MODE_NONE);

        Class[] supportedProfileServices = Config.getSupportedProfiles();
        // If we support no profiles, or we only support GATT/BLE, just move on to BREDR_STOPPED
        if (supportedProfileServices.length == 0
                || (supportedProfileServices.length == 1 && (mRunningProfiles.size() == 1
                && GattService.class.getSimpleName().equals(mRunningProfiles.get(0).getName())))) {
        // TODO(b/228875190): GATT is assumed supported. If we support no profiles then just move on
        // to BREDR_STOPPED
        if (supportedProfileServices.length == 1 && (mRunningProfiles.size() == 1
                && GattService.class.getSimpleName().equals(mRunningProfiles.get(0).getName()))) {
            debugLog("stopProfileServices() - No profiles services to stop or already stopped.");
            mAdapterStateMachine.sendMessage(AdapterState.BREDR_STOPPED);
        } else {
@@ -990,6 +1001,8 @@ public class AdapterService extends Service {

    private void setAllProfileServiceStates(Class[] services, int state) {
        for (Class service : services) {
            // TODO(b/228875190): GATT is assumed supported and treated differently as part of the
            // "BLE ON" state, despite GATT not being BLE specific.
            if (GattService.class.getSimpleName().equals(service.getSimpleName())) {
                continue;
            }
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public class GattService extends ProfileService {
    private final Object mTestModeLock = new Object();

    public static boolean isEnabled() {
        return BluetoothProperties.isProfileGattEnabled().orElse(false);
        return BluetoothProperties.isProfileGattEnabled().orElse(true);
    }

    /**