Loading android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +6 −10 Original line number Diff line number Diff line Loading @@ -367,7 +367,8 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr, bt_acl_state_t state, int transport_link_type, bt_hci_error_code_t hci_reason, bt_conn_direction_t direction) { bt_conn_direction_t direction, uint16_t acl_handle) { if (!bd_addr) { ALOGE("Address is null in %s", __func__); return; Loading @@ -387,7 +388,8 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr, sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_aclStateChangeCallback, (jint)status, addr.get(), (jint)state, (jint)transport_link_type, (jint)hci_reason); (jint)transport_link_type, (jint)hci_reason, (jint)acl_handle); } static void discovery_state_changed_callback(bt_discovery_state_t state) { Loading Loading @@ -683,11 +685,6 @@ static void dut_mode_recv_callback(uint16_t opcode, uint8_t* buf, uint8_t len) { } static void le_test_mode_recv_callback(bt_status_t status, uint16_t packet_count) { ALOGV("%s: status:%d packet_count:%d ", __func__, status, packet_count); } static void energy_info_recv_callback(bt_activity_energy_info* p_energy_info, bt_uid_traffic_t* uid_data) { CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -732,7 +729,6 @@ static bt_callbacks_t sBluetoothCallbacks = {sizeof(sBluetoothCallbacks), acl_state_changed_callback, callback_thread_event, dut_mode_recv_callback, le_test_mode_recv_callback, energy_info_recv_callback, link_quality_report_callback, generate_local_oob_data_callback, Loading Loading @@ -959,8 +955,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_leAddressAssociateCallback = env->GetMethodID( jniCallbackClass, "leAddressAssociateCallback", "([B[B)V"); method_aclStateChangeCallback = env->GetMethodID(jniCallbackClass, "aclStateChangeCallback", "(I[BIII)V"); method_aclStateChangeCallback = env->GetMethodID( jniCallbackClass, "aclStateChangeCallback", "(I[BIIII)V"); method_linkQualityReportCallback = env->GetMethodID( jniCallbackClass, "linkQualityReportCallback", "(JIIIIII)V"); Loading android/app/res/values/config.xml +28 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,34 @@ <integer name="gatt_low_power_min_interval">80</integer> <integer name="gatt_low_power_max_interval">100</integer> <!-- min/max connection intervals/latencies for companion devices --> <!-- Primary companion --> <integer name="gatt_high_priority_min_interval_primary">6</integer> <integer name="gatt_high_priority_max_interval_primary">8</integer> <integer name="gatt_high_priority_latency_primary">45</integer> <integer name="gatt_balanced_priority_min_interval_primary">6</integer> <integer name="gatt_balanced_priority_max_interval_primary">10</integer> <integer name="gatt_balanced_priority_latency_primary">120</integer> <integer name="gatt_low_power_min_interval_primary">8</integer> <integer name="gatt_low_power_max_interval_primary">10</integer> <integer name="gatt_low_power_latency_primary">150</integer> <!-- Secondary companion --> <integer name="gatt_high_priority_min_interval_secondary">6</integer> <integer name="gatt_high_priority_max_interval_secondary">6</integer> <integer name="gatt_high_priority_latency_secondary">0</integer> <integer name="gatt_balanced_priority_min_interval_secondary">12</integer> <integer name="gatt_balanced_priority_max_interval_secondary">12</integer> <integer name="gatt_balanced_priority_latency_secondary">30</integer> <integer name="gatt_low_power_min_interval_secondary">80</integer> <integer name="gatt_low_power_max_interval_secondary">100</integer> <integer name="gatt_low_power_latency_secondary">15</integer> <!-- ============================================================ --> <!-- Specifies latency parameters for high priority, balanced and low power GATT configurations. These values represents the number of packets a peripheral device is allowed to skip. --> Loading android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +30 −4 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties; import com.google.common.collect.EvictingQueue; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -92,6 +94,9 @@ class AdapterProperties { private CopyOnWriteArrayList<BluetoothDevice> mBondedDevices = new CopyOnWriteArrayList<BluetoothDevice>(); private static final int SCAN_MODE_CHANGES_MAX_SIZE = 10; private EvictingQueue<String> mScanModeChanges; private int mProfilesConnecting, mProfilesConnected, mProfilesDisconnecting; private final HashMap<Integer, Pair<Integer, Integer>> mProfileConnectionState = new HashMap<>(); Loading Loading @@ -201,6 +206,7 @@ class AdapterProperties { AdapterProperties(AdapterService service) { mService = service; mAdapter = BluetoothAdapter.getDefaultAdapter(); mScanModeChanges = EvictingQueue.create(SCAN_MODE_CHANGES_MAX_SIZE); invalidateBluetoothCaches(); } Loading Loading @@ -255,6 +261,7 @@ class AdapterProperties { } mService = null; mBondedDevices.clear(); mScanModeChanges.clear(); invalidateBluetoothCaches(); } Loading Loading @@ -390,15 +397,28 @@ class AdapterProperties { /** * Set the local adapter property - scanMode * * @param scanMode the ScanMode to set * @param scanMode the ScanMode to set, valid values are: { * BluetoothAdapter.SCAN_MODE_NONE, * BluetoothAdapter.SCAN_MODE_CONNECTABLE, * BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, * } */ boolean setScanMode(int scanMode) { addScanChangeLog(scanMode); synchronized (mObject) { return mService.setAdapterPropertyNative(AbstractionLayer.BT_PROPERTY_ADAPTER_SCAN_MODE, Utils.intToByteArray(scanMode)); Utils.intToByteArray(AdapterService.convertScanModeToHal(scanMode))); } } private void addScanChangeLog(int scanMode) { String time = Utils.getLocalTimeString(); String uidPid = Utils.getUidPidString(); String scanModeString = dumpScanMode(scanMode); mScanModeChanges.add(time + " (" + uidPid + ") " + scanModeString); } /** * @return the mUuids */ Loading Loading @@ -1077,7 +1097,7 @@ class AdapterProperties { mProfilesConnecting = 0; mProfilesDisconnecting = 0; // adapterPropertyChangedCallback has already been received. Set the scan mode. setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE); setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE); // This keeps NV up-to date on first-boot after flash. setDiscoverableTimeout(mDiscoverableTimeout); } Loading @@ -1087,7 +1107,7 @@ class AdapterProperties { // Sequence BLE_ON to STATE_OFF - that is _complete_ OFF state. debugLog("onBleDisable"); // Set the scan_mode to NONE (no incoming connections). setScanMode(AbstractionLayer.BT_SCAN_MODE_NONE); setScanMode(BluetoothAdapter.SCAN_MODE_NONE); } void discoveryStateChangeCallback(int state) { Loading Loading @@ -1141,6 +1161,12 @@ class AdapterProperties { } } writer.println(sb.toString()); writer.println(" " + "Scan Mode Changes:"); for (String log : mScanModeChanges) { writer.println(" " + log); } } private String dumpDeviceType(int deviceType) { Loading Loading
android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +6 −10 Original line number Diff line number Diff line Loading @@ -367,7 +367,8 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr, bt_acl_state_t state, int transport_link_type, bt_hci_error_code_t hci_reason, bt_conn_direction_t direction) { bt_conn_direction_t direction, uint16_t acl_handle) { if (!bd_addr) { ALOGE("Address is null in %s", __func__); return; Loading @@ -387,7 +388,8 @@ static void acl_state_changed_callback(bt_status_t status, RawAddress* bd_addr, sCallbackEnv->CallVoidMethod(sJniCallbacksObj, method_aclStateChangeCallback, (jint)status, addr.get(), (jint)state, (jint)transport_link_type, (jint)hci_reason); (jint)transport_link_type, (jint)hci_reason, (jint)acl_handle); } static void discovery_state_changed_callback(bt_discovery_state_t state) { Loading Loading @@ -683,11 +685,6 @@ static void dut_mode_recv_callback(uint16_t opcode, uint8_t* buf, uint8_t len) { } static void le_test_mode_recv_callback(bt_status_t status, uint16_t packet_count) { ALOGV("%s: status:%d packet_count:%d ", __func__, status, packet_count); } static void energy_info_recv_callback(bt_activity_energy_info* p_energy_info, bt_uid_traffic_t* uid_data) { CallbackEnv sCallbackEnv(__func__); Loading Loading @@ -732,7 +729,6 @@ static bt_callbacks_t sBluetoothCallbacks = {sizeof(sBluetoothCallbacks), acl_state_changed_callback, callback_thread_event, dut_mode_recv_callback, le_test_mode_recv_callback, energy_info_recv_callback, link_quality_report_callback, generate_local_oob_data_callback, Loading Loading @@ -959,8 +955,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { method_leAddressAssociateCallback = env->GetMethodID( jniCallbackClass, "leAddressAssociateCallback", "([B[B)V"); method_aclStateChangeCallback = env->GetMethodID(jniCallbackClass, "aclStateChangeCallback", "(I[BIII)V"); method_aclStateChangeCallback = env->GetMethodID( jniCallbackClass, "aclStateChangeCallback", "(I[BIIII)V"); method_linkQualityReportCallback = env->GetMethodID( jniCallbackClass, "linkQualityReportCallback", "(JIIIIII)V"); Loading
android/app/res/values/config.xml +28 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,34 @@ <integer name="gatt_low_power_min_interval">80</integer> <integer name="gatt_low_power_max_interval">100</integer> <!-- min/max connection intervals/latencies for companion devices --> <!-- Primary companion --> <integer name="gatt_high_priority_min_interval_primary">6</integer> <integer name="gatt_high_priority_max_interval_primary">8</integer> <integer name="gatt_high_priority_latency_primary">45</integer> <integer name="gatt_balanced_priority_min_interval_primary">6</integer> <integer name="gatt_balanced_priority_max_interval_primary">10</integer> <integer name="gatt_balanced_priority_latency_primary">120</integer> <integer name="gatt_low_power_min_interval_primary">8</integer> <integer name="gatt_low_power_max_interval_primary">10</integer> <integer name="gatt_low_power_latency_primary">150</integer> <!-- Secondary companion --> <integer name="gatt_high_priority_min_interval_secondary">6</integer> <integer name="gatt_high_priority_max_interval_secondary">6</integer> <integer name="gatt_high_priority_latency_secondary">0</integer> <integer name="gatt_balanced_priority_min_interval_secondary">12</integer> <integer name="gatt_balanced_priority_max_interval_secondary">12</integer> <integer name="gatt_balanced_priority_latency_secondary">30</integer> <integer name="gatt_low_power_min_interval_secondary">80</integer> <integer name="gatt_low_power_max_interval_secondary">100</integer> <integer name="gatt_low_power_latency_secondary">15</integer> <!-- ============================================================ --> <!-- Specifies latency parameters for high priority, balanced and low power GATT configurations. These values represents the number of packets a peripheral device is allowed to skip. --> Loading
android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +30 −4 Original line number Diff line number Diff line Loading @@ -56,6 +56,8 @@ import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.RemoteDevices.DeviceProperties; import com.google.common.collect.EvictingQueue; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -92,6 +94,9 @@ class AdapterProperties { private CopyOnWriteArrayList<BluetoothDevice> mBondedDevices = new CopyOnWriteArrayList<BluetoothDevice>(); private static final int SCAN_MODE_CHANGES_MAX_SIZE = 10; private EvictingQueue<String> mScanModeChanges; private int mProfilesConnecting, mProfilesConnected, mProfilesDisconnecting; private final HashMap<Integer, Pair<Integer, Integer>> mProfileConnectionState = new HashMap<>(); Loading Loading @@ -201,6 +206,7 @@ class AdapterProperties { AdapterProperties(AdapterService service) { mService = service; mAdapter = BluetoothAdapter.getDefaultAdapter(); mScanModeChanges = EvictingQueue.create(SCAN_MODE_CHANGES_MAX_SIZE); invalidateBluetoothCaches(); } Loading Loading @@ -255,6 +261,7 @@ class AdapterProperties { } mService = null; mBondedDevices.clear(); mScanModeChanges.clear(); invalidateBluetoothCaches(); } Loading Loading @@ -390,15 +397,28 @@ class AdapterProperties { /** * Set the local adapter property - scanMode * * @param scanMode the ScanMode to set * @param scanMode the ScanMode to set, valid values are: { * BluetoothAdapter.SCAN_MODE_NONE, * BluetoothAdapter.SCAN_MODE_CONNECTABLE, * BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, * } */ boolean setScanMode(int scanMode) { addScanChangeLog(scanMode); synchronized (mObject) { return mService.setAdapterPropertyNative(AbstractionLayer.BT_PROPERTY_ADAPTER_SCAN_MODE, Utils.intToByteArray(scanMode)); Utils.intToByteArray(AdapterService.convertScanModeToHal(scanMode))); } } private void addScanChangeLog(int scanMode) { String time = Utils.getLocalTimeString(); String uidPid = Utils.getUidPidString(); String scanModeString = dumpScanMode(scanMode); mScanModeChanges.add(time + " (" + uidPid + ") " + scanModeString); } /** * @return the mUuids */ Loading Loading @@ -1077,7 +1097,7 @@ class AdapterProperties { mProfilesConnecting = 0; mProfilesDisconnecting = 0; // adapterPropertyChangedCallback has already been received. Set the scan mode. setScanMode(AbstractionLayer.BT_SCAN_MODE_CONNECTABLE); setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE); // This keeps NV up-to date on first-boot after flash. setDiscoverableTimeout(mDiscoverableTimeout); } Loading @@ -1087,7 +1107,7 @@ class AdapterProperties { // Sequence BLE_ON to STATE_OFF - that is _complete_ OFF state. debugLog("onBleDisable"); // Set the scan_mode to NONE (no incoming connections). setScanMode(AbstractionLayer.BT_SCAN_MODE_NONE); setScanMode(BluetoothAdapter.SCAN_MODE_NONE); } void discoveryStateChangeCallback(int state) { Loading Loading @@ -1141,6 +1161,12 @@ class AdapterProperties { } } writer.println(sb.toString()); writer.println(" " + "Scan Mode Changes:"); for (String log : mScanModeChanges) { writer.println(" " + log); } } private String dumpDeviceType(int deviceType) { Loading