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

Commit 71bb55f8 authored by Rongxuan Liu's avatar Rongxuan Liu Committed by Gerrit Code Review
Browse files

Merge "Correct the getConnectionState return value" into main

parents 92dc7c29 1a3a69cc
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -229,6 +229,14 @@ public class AdapterService extends Service {

    private static final int CONTROLLER_ENERGY_UPDATE_TIMEOUT_MILLIS = 30;

    /**
     * Connection state bitmask as returned by getConnectionState.
     */
    public static final int CONNECTION_STATE_DISCONNECTED = 0;
    public static final int CONNECTION_STATE_CONNECTED = 1;
    public static final int CONNECTION_STATE_ENCRYPTED_BREDR = 2;
    public static final int CONNECTION_STATE_ENCRYPTED_LE = 4;

    // Report ID definition
    public enum BqrQualityReportId {
        QUALITY_REPORT_ID_MONITOR_MODE(0x01),
@@ -2899,7 +2907,7 @@ public class AdapterService extends Service {
            if (service == null
                    || !Utils.checkConnectPermissionForDataDelivery(
                            service, attributionSource, "AdapterService getConnectionState")) {
                return BluetoothProfile.STATE_DISCONNECTED;
                return CONNECTION_STATE_DISCONNECTED;
            }

            return service.getConnectionState(device);
+2 −1
Original line number Diff line number Diff line
@@ -653,7 +653,8 @@ class PhonePolicy implements AdapterService.BluetoothStateCallback {
        }

        /* Make sure that device is still connected before connecting other profiles */
        if (mAdapterService.getConnectionState(device) != BluetoothAdapter.STATE_CONNECTED) {
        if (mAdapterService.getConnectionState(device)
                == AdapterService.CONNECTION_STATE_DISCONNECTED) {
            debugLog("processConnectOtherProfiles: device is not connected anymore " + device);
            return;
        }
+2 −2
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ public class PhonePolicyTest {

        // ACL is connected, lets simulate this.
        when(mAdapterService.getConnectionState(bondedDevices[0]))
                .thenReturn(BluetoothProfile.STATE_CONNECTED);
                .thenReturn(AdapterService.CONNECTION_STATE_ENCRYPTED_BREDR);

        // We send a connection successful for one profile since the re-connect *only* works if we
        // have already connected successfully over one of the profiles
@@ -507,7 +507,7 @@ public class PhonePolicyTest {
        // ACL is disconnected just after HEADSET profile got connected and connectOtherProfile
        // was scheduled. Lets simulate this.
        when(mAdapterService.getConnectionState(bondedDevices[0]))
                .thenReturn(BluetoothProfile.STATE_DISCONNECTED);
                .thenReturn(AdapterService.CONNECTION_STATE_DISCONNECTED);

        // We send a connection successful for one profile since the re-connect *only* works if we
        // have already connected successfully over one of the profiles