Loading core/java/android/credentials/CredentialManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -437,7 +437,14 @@ public final class CredentialManager { * Returns {@code true} if the calling application provides a CredentialProviderService that is * enabled for the current user, or {@code false} otherwise. CredentialProviderServices are * enabled on a per-service basis so the individual component name of the service should be * passed in here. * passed in here. <strong>Usage of this API is discouraged as it is not fully functional, and * may throw a NullPointerException on certain devices and/or API versions.</strong> * * @throws IllegalArgumentException if the componentName package does not match the calling * package name this call will throw an exception * * @throws NullPointerException Usage of this API is discouraged as it is not fully * functional, and may throw a NullPointerException on certain devices and/or API versions * * @param componentName the component name to check is enabled */ Loading services/credentials/java/com/android/server/credentials/CredentialManagerService.java +30 −26 Original line number Diff line number Diff line Loading @@ -862,38 +862,42 @@ public final class CredentialManagerService Slog.i(TAG, "isEnabledCredentialProviderService with componentName: " + componentName.flattenToString()); // TODO(253157366): Check additional set of services. final int userId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); enforceCallingPackage(callingPackage, callingUid); synchronized (mLock) { final List<CredentialManagerServiceImpl> services = getServiceListForUserLocked(userId); for (CredentialManagerServiceImpl s : services) { final ComponentName serviceComponentName = s.getServiceComponentName(); if (serviceComponentName.equals(componentName)) { if (!s.getServicePackageName().equals(callingPackage)) { // The component name and the package name do not match. if (componentName == null) { Slog.w(TAG, "isEnabledCredentialProviderService componentName is null"); // If the component name was not specified then throw an error and // record a failure because the request failed due to invalid input. MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.FAILURE, callingUid); Slog.w( TAG, "isEnabledCredentialProviderService: Component name does " + "not match package name."); return false; } if (!componentName.getPackageName().equals(callingPackage)) { Slog.w(TAG, "isEnabledCredentialProviderService component name" + " does not match requested component"); // If the requested component name package name does not match // the calling package then throw an error and record a failure // metric (because the request failed due to invalid input). MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.SUCCESS, callingUid); return true; } } ApiStatus.FAILURE, callingUid); throw new IllegalArgumentException("provided component name does not match" + " does not match requesting component"); } final Set<ComponentName> enabledProviders = getEnabledProvidersForUser(userId); MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.SUCCESS, callingUid); if (enabledProviders == null) { return false; } return enabledProviders.contains(componentName); } @Override public List<CredentialProviderInfo> getCredentialProviderServices( Loading Loading
core/java/android/credentials/CredentialManager.java +8 −1 Original line number Diff line number Diff line Loading @@ -437,7 +437,14 @@ public final class CredentialManager { * Returns {@code true} if the calling application provides a CredentialProviderService that is * enabled for the current user, or {@code false} otherwise. CredentialProviderServices are * enabled on a per-service basis so the individual component name of the service should be * passed in here. * passed in here. <strong>Usage of this API is discouraged as it is not fully functional, and * may throw a NullPointerException on certain devices and/or API versions.</strong> * * @throws IllegalArgumentException if the componentName package does not match the calling * package name this call will throw an exception * * @throws NullPointerException Usage of this API is discouraged as it is not fully * functional, and may throw a NullPointerException on certain devices and/or API versions * * @param componentName the component name to check is enabled */ Loading
services/credentials/java/com/android/server/credentials/CredentialManagerService.java +30 −26 Original line number Diff line number Diff line Loading @@ -862,38 +862,42 @@ public final class CredentialManagerService Slog.i(TAG, "isEnabledCredentialProviderService with componentName: " + componentName.flattenToString()); // TODO(253157366): Check additional set of services. final int userId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); enforceCallingPackage(callingPackage, callingUid); synchronized (mLock) { final List<CredentialManagerServiceImpl> services = getServiceListForUserLocked(userId); for (CredentialManagerServiceImpl s : services) { final ComponentName serviceComponentName = s.getServiceComponentName(); if (serviceComponentName.equals(componentName)) { if (!s.getServicePackageName().equals(callingPackage)) { // The component name and the package name do not match. if (componentName == null) { Slog.w(TAG, "isEnabledCredentialProviderService componentName is null"); // If the component name was not specified then throw an error and // record a failure because the request failed due to invalid input. MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.FAILURE, callingUid); Slog.w( TAG, "isEnabledCredentialProviderService: Component name does " + "not match package name."); return false; } if (!componentName.getPackageName().equals(callingPackage)) { Slog.w(TAG, "isEnabledCredentialProviderService component name" + " does not match requested component"); // If the requested component name package name does not match // the calling package then throw an error and record a failure // metric (because the request failed due to invalid input). MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.SUCCESS, callingUid); return true; } } ApiStatus.FAILURE, callingUid); throw new IllegalArgumentException("provided component name does not match" + " does not match requesting component"); } final Set<ComponentName> enabledProviders = getEnabledProvidersForUser(userId); MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.SUCCESS, callingUid); if (enabledProviders == null) { return false; } return enabledProviders.contains(componentName); } @Override public List<CredentialProviderInfo> getCredentialProviderServices( Loading