Need to check isManagedByCompanionApp before calling getMacAddress()

Since AssociationInfo.getIdOfType() might return null,
we need to to check !Association.isManagedByCompanionApp
before calling getMacAddress()

Test: cts verifier
bug: 198539218
Change-Id: Idd2e6940aea511adc08804ab4c23ea199584808d
This commit is contained in:
Evan Chen
2021-11-01 01:09:17 +00:00
parent a74fd7552a
commit 8377f912d6

View File

@@ -775,12 +775,14 @@ public class CompanionDeviceManagerService extends SystemService {
exemptFromAutoRevoke(packageInfo.packageName, packageInfo.applicationInfo.uid);
if (mCurrentlyConnectedDevices.contains(association.getDeviceMacAddress())) {
grantDeviceProfile(association);
}
if (!association.isManagedByCompanionApp()) {
if (mCurrentlyConnectedDevices.contains(association.getDeviceMacAddress())) {
grantDeviceProfile(association);
}
if (association.isNotifyOnDeviceNearby()) {
restartBleScan();
if (association.isNotifyOnDeviceNearby()) {
restartBleScan();
}
}
}
@@ -1213,6 +1215,9 @@ public class CompanionDeviceManagerService extends SystemService {
ArrayList<ScanFilter> result = new ArrayList<>();
ArraySet<String> addressesSeen = new ArraySet<>();
for (AssociationInfo association : getAllAssociations()) {
if (association.isManagedByCompanionApp()) {
continue;
}
String address = association.getDeviceMacAddress();
if (addressesSeen.contains(address)) {
continue;