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

Commit c7798781 authored by Evan Chen's avatar Evan Chen
Browse files

Remove `isDevicePresent` checker before sending callback

Test: cts
Bug: 293792703
Change-Id: If93d3fb1666900fe9d61cb0536c0ccb3fd7f0308
parent d6c45131
Loading
Loading
Loading
Loading
+7 −20
Original line number Diff line number Diff line
@@ -281,43 +281,30 @@ public class CompanionDevicePresenceMonitor implements AssociationStore.OnChange
            case DEVICE_EVENT_BLE_APPEARED:
            case DEVICE_EVENT_BT_CONNECTED:
            case DEVICE_EVENT_SELF_MANAGED_APPEARED:
                final boolean alreadyPresent = isDevicePresent(associationId);
                final boolean added = presentDevicesForSource.add(associationId);

                if (!added) {
                    Slog.w(TAG, "Association with id "
                            + associationId + " is ALREADY reported as "
                            + "present by this source, event=" + event);
                    return;
                }
                // For backward compatibility, do not send the onDeviceAppeared() callback
                // if it already reported BLE device status.
                if (event == DEVICE_EVENT_BT_CONNECTED && alreadyPresent) {
                    Slog.i(TAG, "Ignore sending onDeviceAppeared callback, "
                            + "device id (" + associationId + ") already present.");
                } else {

                mCallback.onDeviceAppeared(associationId);
                }

                break;
            case DEVICE_EVENT_BLE_DISAPPEARED:
            case DEVICE_EVENT_BT_DISCONNECTED:
            case DEVICE_EVENT_SELF_MANAGED_DISAPPEARED:
                final boolean removed = presentDevicesForSource.remove(associationId);

                if (!removed) {
                    Log.w(TAG, "Association with id " + associationId + " was NOT reported "
                    Slog.w(TAG, "Association with id " + associationId + " was NOT reported "
                            + "as present by this source, event= " + event);

                    return;
                }
                final boolean stillPresent = isDevicePresent(associationId);
                // For backward compatibility, do not send the onDeviceDisappeared()
                // callback when ble scan still presenting.
                if (stillPresent) {
                    Slog.i(TAG, "Ignore sending onDeviceDisappeared callback, "
                            + "device id (" + associationId + ") is still present.");
                } else {

                mCallback.onDeviceDisappeared(associationId);
                }

                break;
            default: