[CDM bug] Fix CDM crash when there's no CDM service

Move the service connector empty check before adding it to the service
connectors map. So when there's no CDM services, there won't be a value in the map.

Bug: 219784113

Test: manually tested no services case using CDM test app. The app
doesn't crash now.

Change-Id: Ib236d42a43c001c0ea5fa4debf5f832daee811c4
This commit is contained in:
Guojing Yuan
2022-02-23 18:12:14 +00:00
parent ba688138fb
commit c1c451fc3b

View File

@@ -118,13 +118,14 @@ class CompanionApplicationController {
serviceConnectors = CollectionUtils.map(companionServices, componentName ->
new CompanionDeviceServiceConnector(mContext, userId, componentName));
mBoundCompanionApplications.setValueForPackage(userId, packageName, serviceConnectors);
}
if (serviceConnectors.isEmpty()) {
Slog.e(TAG, "Can't find CompanionDeviceService implementer in package: "
+ packageName + ". Please check if they are correctly declared.");
return;
if (serviceConnectors.isEmpty()) {
Slog.e(TAG, "Can't find CompanionDeviceService implementer in package: "
+ packageName + ". Please check if they are correctly declared.");
return;
}
mBoundCompanionApplications.setValueForPackage(userId, packageName, serviceConnectors);
}
// The first connector in the list is always the primary connector: set a listener to it.