diff options
| author | 2022-12-20 22:48:22 +0000 | |
|---|---|---|
| committer | 2022-12-20 22:48:22 +0000 | |
| commit | e31dc4d42c5983e3378cf3cb47b270e4dd107d30 (patch) | |
| tree | b5584c267660ba164de7d71ba7784c74613e28cf | |
| parent | 468d4e8dc21b179a846ae8abc7dec5ea80944c16 (diff) | |
Revert "Fix update of services for multiple backend mode"
This reverts commit 468d4e8dc21b179a846ae8abc7dec5ea80944c16.
Reason for revert: Change causing NPE b/20797663
Change-Id: Ia71efac2d8583cc5ac79879f10209784c700fbb0
| -rw-r--r-- | services/core/java/com/android/server/infra/AbstractMasterSystemService.java | 22 | ||||
| -rw-r--r-- | services/core/java/com/android/server/infra/AbstractPerUserSystemService.java | 28 |
2 files changed, 18 insertions, 32 deletions
diff --git a/services/core/java/com/android/server/infra/AbstractMasterSystemService.java b/services/core/java/com/android/server/infra/AbstractMasterSystemService.java index 1395d685eeb7..b813995f1c08 100644 --- a/services/core/java/com/android/server/infra/AbstractMasterSystemService.java +++ b/services/core/java/com/android/server/infra/AbstractMasterSystemService.java @@ -684,15 +684,6 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem */ @GuardedBy("mLock") protected List<S> updateCachedServiceListLocked(@UserIdInt int userId, boolean disabled) { - if (mServiceNameResolver.isConfiguredInMultipleMode()) { - // In multiple mode, we have multiple instances of AbstractPerUserSystemService, per - // user where each instance holds information needed to connect to a backend. An - // update operation in this mode needs to account for addition, deletion, change - // of backends and cannot be executed in the scope of a given - // AbstractPerUserSystemService. - return updateCachedServiceListMultiModeLocked(userId, disabled); - } - // isConfiguredInMultipleMode is false final List<S> services = getServiceListForUserLocked(userId); if (services == null) { return null; @@ -713,19 +704,6 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem return services; } - @GuardedBy("mLock") - private List<S> updateCachedServiceListMultiModeLocked(int userId, boolean disabled) { - final int resolvedUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(), - Binder.getCallingUid(), userId, false, false, null, - null); - List<S> services = new ArrayList<>(); - synchronized (mLock) { - removeCachedServiceListLocked(resolvedUserId); - services = getServiceListForUserLocked(userId); - } - return services; - } - /** * Gets the Settings property that defines the name of the component name used to bind this * service to an external service, or {@code null} when the service is not defined by such diff --git a/services/core/java/com/android/server/infra/AbstractPerUserSystemService.java b/services/core/java/com/android/server/infra/AbstractPerUserSystemService.java index d4a29c7f1b62..b8f1db402a55 100644 --- a/services/core/java/com/android/server/infra/AbstractPerUserSystemService.java +++ b/services/core/java/com/android/server/infra/AbstractPerUserSystemService.java @@ -154,14 +154,7 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst if (mMaster.mServiceNameResolver != null && mMaster.mServiceNameResolver.isConfiguredInMultipleMode()) { - // Update of multi configured mode should always happen in AbstractMasterSystemService - // as this class is not aware of the complete list of multiple backends. Since we - // should never end up in this state, it is safe to not do anything if we end up here - // through a different code path. - if (mMaster.debug) { - Slog.d(mTag, "Should not end up in updateLocked when " - + "isConfiguredInMultipleMode is true"); - } + updateServiceInfoListLocked(); } else { updateServiceInfoLocked(); } @@ -173,14 +166,29 @@ public abstract class AbstractPerUserSystemService<S extends AbstractPerUserSyst */ @GuardedBy("mLock") protected final ComponentName updateServiceInfoLocked() { + ComponentName[] componentNames = updateServiceInfoListLocked(); + return componentNames == null || componentNames.length == 0 ? null : componentNames[0]; + } + + /** + * Updates the internal reference to the service info, and returns the service's component. + */ + @GuardedBy("mLock") + protected final ComponentName[] updateServiceInfoListLocked() { if (mMaster.mServiceNameResolver == null) { return null; } if (!mMaster.mServiceNameResolver.isConfiguredInMultipleMode()) { final String componentName = getComponentNameLocked(); - return getServiceComponent(componentName); + return new ComponentName[] { getServiceComponent(componentName) }; } - return null; + final String[] componentNames = mMaster.mServiceNameResolver.getServiceNameList( + mUserId); + ComponentName[] serviceComponents = new ComponentName[componentNames.length]; + for (int i = 0; i < componentNames.length; i++) { + serviceComponents[i] = getServiceComponent(componentNames[i]); + } + return serviceComponents; } private ComponentName getServiceComponent(String componentName) { |