Loading android/app/src/com/android/bluetooth/Utils.java +20 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ import android.provider.DeviceConfig; import android.provider.Telephony; import android.util.Log; import androidx.annotation.RequiresApi; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.ProfileService; Loading @@ -76,6 +78,7 @@ import java.nio.charset.CharsetDecoder; import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Objects; import java.util.UUID; import java.util.concurrent.TimeUnit; Loading Loading @@ -350,7 +353,7 @@ public final class Utils { + " is inaccurate for calling uid " + callingUid); } for (AssociationInfo association : cdm.getAllAssociations()) { for (AssociationInfo association : getCdmAssociations(cdm)) { if (association.getPackageName().equals(callingPackage) && !association.isSelfManaged() && device.getAddress() != null && association.getDeviceMacAddress() != null Loading @@ -363,6 +366,22 @@ public final class Utils { + " does not have a CDM association with the Bluetooth Device"); } /** * Obtains the complete list of registered CDM associations. * * @param cdm the CompanionDeviceManager object * @return the list of AssociationInfo objects */ @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") @RequiresApi(Build.VERSION_CODES.TIRAMISU) // TODO(b/193460475): Android Lint handles change from SystemApi to public incorrectly. // CompanionDeviceManager#getAllAssociations() is public in U, // but existed in T as an identical SystemApi. @SuppressLint("NewApi") public static List<AssociationInfo> getCdmAssociations(CompanionDeviceManager cdm) { return cdm.getAllAssociations(); } /** * Verifies whether the calling package name matches the calling app uid * @param context the Bluetooth AdapterService context Loading android/app/src/com/android/bluetooth/gatt/GattService.java +1 −1 Original line number Diff line number Diff line Loading @@ -2967,7 +2967,7 @@ public class GattService extends ProfileService { final long identity = Binder.clearCallingIdentity(); try { for (AssociationInfo info : mCompanionManager.getAllAssociations()) { for (AssociationInfo info : Utils.getCdmAssociations(mCompanionManager)) { if (info.getPackageName().equals(callingPackage) && !info.isSelfManaged() && info.getDeviceMacAddress() != null) { macAddresses.add(info.getDeviceMacAddress().toString()); Loading Loading
android/app/src/com/android/bluetooth/Utils.java +20 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ import android.provider.DeviceConfig; import android.provider.Telephony; import android.util.Log; import androidx.annotation.RequiresApi; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.ProfileService; Loading @@ -76,6 +78,7 @@ import java.nio.charset.CharsetDecoder; import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Objects; import java.util.UUID; import java.util.concurrent.TimeUnit; Loading Loading @@ -350,7 +353,7 @@ public final class Utils { + " is inaccurate for calling uid " + callingUid); } for (AssociationInfo association : cdm.getAllAssociations()) { for (AssociationInfo association : getCdmAssociations(cdm)) { if (association.getPackageName().equals(callingPackage) && !association.isSelfManaged() && device.getAddress() != null && association.getDeviceMacAddress() != null Loading @@ -363,6 +366,22 @@ public final class Utils { + " does not have a CDM association with the Bluetooth Device"); } /** * Obtains the complete list of registered CDM associations. * * @param cdm the CompanionDeviceManager object * @return the list of AssociationInfo objects */ @RequiresPermission("android.permission.MANAGE_COMPANION_DEVICES") @RequiresApi(Build.VERSION_CODES.TIRAMISU) // TODO(b/193460475): Android Lint handles change from SystemApi to public incorrectly. // CompanionDeviceManager#getAllAssociations() is public in U, // but existed in T as an identical SystemApi. @SuppressLint("NewApi") public static List<AssociationInfo> getCdmAssociations(CompanionDeviceManager cdm) { return cdm.getAllAssociations(); } /** * Verifies whether the calling package name matches the calling app uid * @param context the Bluetooth AdapterService context Loading
android/app/src/com/android/bluetooth/gatt/GattService.java +1 −1 Original line number Diff line number Diff line Loading @@ -2967,7 +2967,7 @@ public class GattService extends ProfileService { final long identity = Binder.clearCallingIdentity(); try { for (AssociationInfo info : mCompanionManager.getAllAssociations()) { for (AssociationInfo info : Utils.getCdmAssociations(mCompanionManager)) { if (info.getPackageName().equals(callingPackage) && !info.isSelfManaged() && info.getDeviceMacAddress() != null) { macAddresses.add(info.getDeviceMacAddress().toString()); Loading