GATT: Move connection parameters to config.xml

This makes it easier for OEMs to customize the high prioriy, balanced
and low power mode connection parameters through overlays.

Bug: 18013697
Change-Id: I8b486b772fdb871f2800238cb5e45c4ff0663952
(cherry-picked from d65009d591017319a429be1a920fdf763e71cebd)
diff --git a/res/values/config.xml b/res/values/config.xml
index c7635bb..91f0c0f 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -35,14 +35,25 @@
          of the location permissions. -->
     <bool name="strict_location_check">true</bool>
 
-    <!-- Specifies the min/max connection interval parameters for high priority
-         and low power GATT configurations. These values are in multiples of
-         1.25ms. -->
+    <!-- Specifies the min/max connection interval parameters for high priority,
+         balanced and low power GATT configurations. These values are in
+         multiples of 1.25ms. -->
     <integer name="gatt_high_priority_min_interval">9</integer>
     <integer name="gatt_high_priority_max_interval">12</integer>
+    <!-- Default specs recommended interval is 30 (24 * 1.25) -> 50 (40 * 1.25)
+         ms. -->
+    <integer name="gatt_balanced_priority_min_interval">24</integer>
+    <integer name="gatt_balanced_priority_max_interval">40</integer>
     <integer name="gatt_low_power_min_interval">80</integer>
     <integer name="gatt_low_power_max_interval">100</integer>
 
+    <!-- Specifies latency parameters for high priority, balanced and low power
+         GATT configurations. These values represents the number of packets a
+         slave device is allowed to skip. -->
+    <integer name="gatt_high_priority_latency">0</integer>
+    <integer name="gatt_balanced_priority_latency">0</integer>
+    <integer name="gatt_low_power_latency">2</integer>
+
     <bool name="headset_client_initial_audio_route_allowed">true</bool>
 
     <!-- For AVRCP absolute volume feature. If the threshold is non-zero,
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java
index dfb08d3..7a164c6 100644
--- a/src/com/android/bluetooth/gatt/GattService.java
+++ b/src/com/android/bluetooth/gatt/GattService.java
@@ -1594,12 +1594,11 @@
     void connectionParameterUpdate(int clientIf, String address, int connectionPriority) {
         enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
 
-        // Default spec recommended interval is 30->50 ms
-        int minInterval = 24; // 24 * 1.25ms = 30ms
-        int maxInterval = 40; // 40 * 1.25ms = 50ms
+        int minInterval;
+        int maxInterval;
 
         // Slave latency
-        int latency = 0;
+        int latency;
 
         // Link supervision timeout is measured in N * 10ms
         int timeout = 2000; // 20s
@@ -1609,12 +1608,22 @@
             case BluetoothGatt.CONNECTION_PRIORITY_HIGH:
                 minInterval = getResources().getInteger(R.integer.gatt_high_priority_min_interval);
                 maxInterval = getResources().getInteger(R.integer.gatt_high_priority_max_interval);
+                latency = getResources().getInteger(R.integer.gatt_high_priority_latency);
                 break;
 
             case BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER:
                 minInterval = getResources().getInteger(R.integer.gatt_low_power_min_interval);
                 maxInterval = getResources().getInteger(R.integer.gatt_low_power_max_interval);
-                latency = 2;
+                latency = getResources().getInteger(R.integer.gatt_low_power_latency);
+                break;
+
+            default:
+                // Using the values for CONNECTION_PRIORITY_BALANCED.
+                minInterval =
+                        getResources().getInteger(R.integer.gatt_balanced_priority_min_interval);
+                maxInterval =
+                        getResources().getInteger(R.integer.gatt_balanced_priority_max_interval);
+                latency = getResources().getInteger(R.integer.gatt_balanced_priority_latency);
                 break;
         }