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

Commit 3422d73b authored by Himanshu Rawat's avatar Himanshu Rawat Committed by Automerger Merge Worker
Browse files

Do not update connection policies when service discovery fails am: d43ff4f4

parents a4edadd8 d43ff4f4
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ public class RemoteDevices {

    private static final int UUID_INTENT_DELAY = 6000;
    private static final int MESSAGE_UUID_INTENT = 1;
    private static final int MESSAGE_UUID_STATUS_SUCCESS = 0;
    private static final int MESSAGE_UUID_STATUS_TIMEOUT = 1;
    private static final String LOG_SOURCE_DIS = "DIS";

    private final HashMap<String, DeviceProperties> mDevices;
@@ -116,12 +118,13 @@ public class RemoteDevices {
                case MESSAGE_UUID_INTENT:
                    BluetoothDevice device = (BluetoothDevice) msg.obj;
                    if (device != null) {
                        boolean success = (msg.arg1 == MESSAGE_UUID_STATUS_SUCCESS);
                        debugLog("MESSAGE_UUID_INTENT: " + device);
                        // SDP Sending delayed SDP UUID intent
                        MetricsLogger.getInstance()
                                .cacheCount(BluetoothProtoEnums.SDP_SENDING_DELAYED_UUID, 1);
                        DeviceProperties prop = getDeviceProperties(device);
                        sendUuidIntent(device, prop);
                        sendUuidIntent(device, prop, success);
                    } else {
                        // SDP Not sending delayed SDP UUID intent b/c device is not there
                        MetricsLogger.getInstance()
@@ -723,10 +726,13 @@ public class RemoteDevices {
        }
    }

    private void sendUuidIntent(BluetoothDevice device, DeviceProperties prop) {
    private void sendUuidIntent(BluetoothDevice device, DeviceProperties prop, boolean success) {
        // Send uuids within the stack before the broadcast is sent out
        ParcelUuid[] uuids = prop == null ? null : prop.getUuids();

        if (!Flags.preventDuplicateUuidIntent() || success) {
            mAdapterService.sendUuidsInternal(device, uuids);
        }

        Intent intent = new Intent(BluetoothDevice.ACTION_UUID);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
@@ -998,7 +1004,7 @@ public class RemoteDevices {
                                        .cacheCount(
                                                BluetoothProtoEnums.SDP_ADD_UUID_WITH_INTENT, 1);
                                mAdapterService.deviceUuidUpdated(bdDevice);
                                sendUuidIntent(bdDevice, deviceProperties);
                                sendUuidIntent(bdDevice, deviceProperties, true);
                            } else if (mAdapterService.getState()
                                    == BluetoothAdapter.STATE_BLE_ON) {
                                // SDP Adding UUIDs to property cache but with no intent
@@ -1419,6 +1425,7 @@ public class RemoteDevices {

        Message message = mHandler.obtainMessage(MESSAGE_UUID_INTENT);
        message.obj = device;
        message.arg1 = MESSAGE_UUID_STATUS_TIMEOUT;
        mHandler.sendMessageDelayed(message, UUID_INTENT_DELAY);

        // Uses cached UUIDs if we are bonding. If not, we fetch the UUIDs with SDP.
@@ -1438,6 +1445,7 @@ public class RemoteDevices {
    void updateUuids(BluetoothDevice device) {
        Message message = mHandler.obtainMessage(MESSAGE_UUID_INTENT);
        message.obj = device;
        message.arg1 = MESSAGE_UUID_STATUS_SUCCESS;
        mHandler.sendMessage(message);
    }