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

Commit d2bc53e3 authored by Christine Hallstrom's avatar Christine Hallstrom
Browse files

Hook up BluetoothGatt#CONNECTION_PRIORITY_DCK

Pull the related config values for DCK connection priority when
BluetoothGatt#CONNECTION_PRIORITY_DCK is passed as param to
BluetoothGatt#requestConnectionPriority.

Bug: 269534790
Test: atest CompanionManagerTest
Change-Id: I6712c3a382a9da3aacf9ee5812ce415cbbdb0879
parent 30666482
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -63,12 +63,13 @@
    <integer name="gatt_low_power_latency_secondary">15</integer>
    <integer name="gatt_low_power_latency_secondary">15</integer>
    <!-- ============================================================ -->
    <!-- ============================================================ -->


    <!-- Specifies latency parameters for high priority, balanced and low power
    <!-- Specifies latency parameters for high priority, balanced, low power and
         GATT configurations. These values represents the number of packets a
         Digital Car Key-preferred GATT configurations. These values represent
         peripheral device is allowed to skip. -->
         the number of packets a peripheral device is allowed to skip. -->
    <integer name="gatt_high_priority_latency">0</integer>
    <integer name="gatt_high_priority_latency">0</integer>
    <integer name="gatt_balanced_priority_latency">0</integer>
    <integer name="gatt_balanced_priority_latency">0</integer>
    <integer name="gatt_low_power_latency">2</integer>
    <integer name="gatt_low_power_latency">2</integer>
    <integer name="gatt_dck_priority_latency">0</integer>


    <!-- Specifies the min/max subrate factor parameters for high priority,
    <!-- Specifies the min/max subrate factor parameters for high priority,
         balanced and low power subrate request configurations. -->
         balanced and low power subrate request configurations. -->
+10 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@ public class CompanionManager {
    private final int[] mGattConnHighDefault;
    private final int[] mGattConnHighDefault;
    private final int[] mGattConnBalanceDefault;
    private final int[] mGattConnBalanceDefault;
    private final int[] mGattConnLowDefault;
    private final int[] mGattConnLowDefault;
    private final int[] mGattConnDckDefault;


    @VisibleForTesting static final int COMPANION_TYPE_NONE      = 0;
    @VisibleForTesting static final int COMPANION_TYPE_NONE      = 0;
    @VisibleForTesting static final int COMPANION_TYPE_PRIMARY   = 1;
    @VisibleForTesting static final int COMPANION_TYPE_PRIMARY   = 1;
@@ -81,6 +82,9 @@ public class CompanionManager {
    static final String PROPERTY_LOW_MIN_INTERVAL = "bluetooth.gatt.low_priority_min.interval";
    static final String PROPERTY_LOW_MIN_INTERVAL = "bluetooth.gatt.low_priority_min.interval";
    static final String PROPERTY_LOW_MAX_INTERVAL = "bluetooth.gatt.low_priority_max.interval";
    static final String PROPERTY_LOW_MAX_INTERVAL = "bluetooth.gatt.low_priority_max.interval";
    static final String PROPERTY_LOW_LATENCY = "bluetooth.gatt.low_priority.latency";
    static final String PROPERTY_LOW_LATENCY = "bluetooth.gatt.low_priority.latency";
    static final String PROPERTY_DCK_MIN_INTERVAL = "bluetooth.gatt.dck_priority_min.interval";
    static final String PROPERTY_DCK_MAX_INTERVAL = "bluetooth.gatt.dck_priority_max.interval";
    static final String PROPERTY_DCK_LATENCY = "bluetooth.gatt.dck_priority.latency";
    static final String PROPERTY_SUFFIX_PRIMARY = ".primary";
    static final String PROPERTY_SUFFIX_PRIMARY = ".primary";
    static final String PROPERTY_SUFFIX_SECONDARY = ".secondary";
    static final String PROPERTY_SUFFIX_SECONDARY = ".secondary";


@@ -109,6 +113,10 @@ public class CompanionManager {
                getGattConfig(PROPERTY_LOW_MIN_INTERVAL, R.integer.gatt_low_power_min_interval),
                getGattConfig(PROPERTY_LOW_MIN_INTERVAL, R.integer.gatt_low_power_min_interval),
                getGattConfig(PROPERTY_LOW_MAX_INTERVAL, R.integer.gatt_low_power_max_interval),
                getGattConfig(PROPERTY_LOW_MAX_INTERVAL, R.integer.gatt_low_power_max_interval),
                getGattConfig(PROPERTY_LOW_LATENCY, R.integer.gatt_low_power_latency)};
                getGattConfig(PROPERTY_LOW_LATENCY, R.integer.gatt_low_power_latency)};
        mGattConnDckDefault = new int[] {
                getGattConfig(PROPERTY_DCK_MIN_INTERVAL, R.integer.gatt_dck_priority_min_interval),
                getGattConfig(PROPERTY_DCK_MAX_INTERVAL, R.integer.gatt_dck_priority_max_interval),
                getGattConfig(PROPERTY_DCK_LATENCY, R.integer.gatt_dck_priority_latency)};


        mGattConnHighPrimary = new int[] {
        mGattConnHighPrimary = new int[] {
                getGattConfig(PROPERTY_HIGH_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY,
                getGattConfig(PROPERTY_HIGH_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY,
@@ -397,6 +405,8 @@ public class CompanionManager {
                return mGattConnHighDefault[type];
                return mGattConnHighDefault[type];
            case BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER:
            case BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER:
                return mGattConnLowDefault[type];
                return mGattConnLowDefault[type];
            case BluetoothGatt.CONNECTION_PRIORITY_DCK:
                return mGattConnDckDefault[type];
        }
        }
        return mGattConnBalanceDefault[type];
        return mGattConnBalanceDefault[type];
    }
    }
+1 −0
Original line number Original line Diff line number Diff line
@@ -129,6 +129,7 @@ public class CompanionManagerTest {
        checkReasonableConnParameterHelper(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
        checkReasonableConnParameterHelper(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
        checkReasonableConnParameterHelper(BluetoothGatt.CONNECTION_PRIORITY_BALANCED);
        checkReasonableConnParameterHelper(BluetoothGatt.CONNECTION_PRIORITY_BALANCED);
        checkReasonableConnParameterHelper(BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER);
        checkReasonableConnParameterHelper(BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER);
        checkReasonableConnParameterHelper(BluetoothGatt.CONNECTION_PRIORITY_DCK);
    }
    }


    private void loadCompanionInfoHelper(String address, int companionType) {
    private void loadCompanionInfoHelper(String address, int companionType) {
+3 −2
Original line number Original line Diff line number Diff line
@@ -1885,14 +1885,15 @@ public final class BluetoothGatt implements BluetoothProfile {
     *
     *
     * @param connectionPriority Request a specific connection priority. Must be one of {@link
     * @param connectionPriority Request a specific connection priority. Must be one of {@link
     * BluetoothGatt#CONNECTION_PRIORITY_BALANCED}, {@link BluetoothGatt#CONNECTION_PRIORITY_HIGH}
     * BluetoothGatt#CONNECTION_PRIORITY_BALANCED}, {@link BluetoothGatt#CONNECTION_PRIORITY_HIGH}
     * or {@link BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER}.
     * {@link BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER}, or
     * {@link BluetoothGatt#CONNECTION_PRIORITY_DCK}.
     * @throws IllegalArgumentException If the parameters are outside of their specified range.
     * @throws IllegalArgumentException If the parameters are outside of their specified range.
     */
     */
    @RequiresBluetoothConnectPermission
    @RequiresBluetoothConnectPermission
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
    public boolean requestConnectionPriority(int connectionPriority) {
    public boolean requestConnectionPriority(int connectionPriority) {
        if (connectionPriority < CONNECTION_PRIORITY_BALANCED
        if (connectionPriority < CONNECTION_PRIORITY_BALANCED
                || connectionPriority > CONNECTION_PRIORITY_LOW_POWER) {
                || connectionPriority > CONNECTION_PRIORITY_DCK) {
            throw new IllegalArgumentException("connectionPriority not within valid range");
            throw new IllegalArgumentException("connectionPriority not within valid range");
        }
        }