Loading services/companion/java/com/android/server/companion/devicepresence/BluetoothDeviceProcessor.java +25 −7 Original line number Diff line number Diff line Loading @@ -29,7 +29,9 @@ import android.os.Handler; import android.os.HandlerExecutor; import android.os.ParcelUuid; import android.os.UserHandle; import android.util.Slog; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.ArrayUtils; import com.android.server.companion.association.AssociationStore; Loading Loading @@ -61,6 +63,7 @@ public class BluetoothDeviceProcessor private final Callback mCallback; /** A set of ALL connected BT device (not only companion.) */ @GuardedBy("mAllConnectedDevices") @NonNull private final Map<MacAddress, BluetoothDevice> mAllConnectedDevices = new HashMap<>(); Loading @@ -85,9 +88,14 @@ public class BluetoothDeviceProcessor public void onDeviceConnected(@NonNull BluetoothDevice device) { final MacAddress macAddress = MacAddress.fromString(device.getAddress()); synchronized (mAllConnectedDevices) { if (mAllConnectedDevices.put(macAddress, device) != null) { Slog.i(TAG, "Device " + device.getAddress() + " already marked as connected. Skipping duplicate event."); return; } } onDeviceConnectivityChanged(device, true); } Loading @@ -102,9 +110,13 @@ public class BluetoothDeviceProcessor int reason) { final MacAddress macAddress = MacAddress.fromString(device.getAddress()); synchronized (mAllConnectedDevices) { if (mAllConnectedDevices.remove(macAddress) == null) { Slog.i(TAG, "Device " + device.getAddress() + " not found as connected. Skipping disconnect event"); return; } } onDeviceConnectivityChanged(device, false); } Loading Loading @@ -140,9 +152,15 @@ public class BluetoothDeviceProcessor @Override public void onAssociationAdded(AssociationInfo association) { synchronized (mAllConnectedDevices) { if (mAllConnectedDevices.containsKey(association.getDeviceMacAddress())) { mCallback.onBluetoothCompanionDeviceConnected( association.getId(), association.getUserId()); } else { Slog.i(TAG, "onAssociationAdded: Device " + association.getDeviceMacAddress() + " is not currently connected."); } } } } Loading
services/companion/java/com/android/server/companion/devicepresence/BluetoothDeviceProcessor.java +25 −7 Original line number Diff line number Diff line Loading @@ -29,7 +29,9 @@ import android.os.Handler; import android.os.HandlerExecutor; import android.os.ParcelUuid; import android.os.UserHandle; import android.util.Slog; import com.android.internal.annotations.GuardedBy; import com.android.internal.util.ArrayUtils; import com.android.server.companion.association.AssociationStore; Loading Loading @@ -61,6 +63,7 @@ public class BluetoothDeviceProcessor private final Callback mCallback; /** A set of ALL connected BT device (not only companion.) */ @GuardedBy("mAllConnectedDevices") @NonNull private final Map<MacAddress, BluetoothDevice> mAllConnectedDevices = new HashMap<>(); Loading @@ -85,9 +88,14 @@ public class BluetoothDeviceProcessor public void onDeviceConnected(@NonNull BluetoothDevice device) { final MacAddress macAddress = MacAddress.fromString(device.getAddress()); synchronized (mAllConnectedDevices) { if (mAllConnectedDevices.put(macAddress, device) != null) { Slog.i(TAG, "Device " + device.getAddress() + " already marked as connected. Skipping duplicate event."); return; } } onDeviceConnectivityChanged(device, true); } Loading @@ -102,9 +110,13 @@ public class BluetoothDeviceProcessor int reason) { final MacAddress macAddress = MacAddress.fromString(device.getAddress()); synchronized (mAllConnectedDevices) { if (mAllConnectedDevices.remove(macAddress) == null) { Slog.i(TAG, "Device " + device.getAddress() + " not found as connected. Skipping disconnect event"); return; } } onDeviceConnectivityChanged(device, false); } Loading Loading @@ -140,9 +152,15 @@ public class BluetoothDeviceProcessor @Override public void onAssociationAdded(AssociationInfo association) { synchronized (mAllConnectedDevices) { if (mAllConnectedDevices.containsKey(association.getDeviceMacAddress())) { mCallback.onBluetoothCompanionDeviceConnected( association.getId(), association.getUserId()); } else { Slog.i(TAG, "onAssociationAdded: Device " + association.getDeviceMacAddress() + " is not currently connected."); } } } }