Merge "[CDM bug] Fix CDM crash when there's no CDM service" into tm-dev
diff --git a/services/companion/java/com/android/server/companion/CompanionApplicationController.java b/services/companion/java/com/android/server/companion/CompanionApplicationController.java
index c39b59a..ec4bfe0 100644
--- a/services/companion/java/com/android/server/companion/CompanionApplicationController.java
+++ b/services/companion/java/com/android/server/companion/CompanionApplicationController.java
@@ -118,13 +118,14 @@
 
             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.