Loading core/api/test-current.txt +34 −0 Original line number Diff line number Diff line Loading @@ -1072,6 +1072,40 @@ package android.content.rollback { } package android.credentials { public final class CredentialManager { method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.QUERY_ALL_PACKAGES, "android.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS"}) public java.util.List<android.credentials.CredentialProviderInfo> getCredentialProviderServicesForTesting(int); method public static boolean isServiceEnabled(@NonNull android.content.Context); field public static final int PROVIDER_FILTER_ALL_PROVIDERS = 0; // 0x0 field public static final int PROVIDER_FILTER_SYSTEM_PROVIDERS_ONLY = 1; // 0x1 field public static final int PROVIDER_FILTER_USER_PROVIDERS_ONLY = 2; // 0x2 } public final class CredentialProviderInfo implements android.os.Parcelable { method public int describeContents(); method @NonNull public java.util.List<java.lang.String> getCapabilities(); method @NonNull public android.content.ComponentName getComponentName(); method @Nullable public CharSequence getLabel(@NonNull android.content.Context); method @Nullable public android.graphics.drawable.Drawable getServiceIcon(@NonNull android.content.Context); method @NonNull public android.content.pm.ServiceInfo getServiceInfo(); method @NonNull public boolean hasCapability(@NonNull String); method public boolean isEnabled(); method public boolean isSystemProvider(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.credentials.CredentialProviderInfo> CREATOR; } public static final class CredentialProviderInfo.Builder { ctor public CredentialProviderInfo.Builder(@NonNull android.content.pm.ServiceInfo); method @NonNull public android.credentials.CredentialProviderInfo.Builder addCapabilities(@NonNull java.util.List<java.lang.String>); method @NonNull public android.credentials.CredentialProviderInfo build(); method @NonNull public android.credentials.CredentialProviderInfo.Builder setEnabled(boolean); method @NonNull public android.credentials.CredentialProviderInfo.Builder setSystemProvider(boolean); } } package android.credentials.ui { public final class AuthenticationEntry implements android.os.Parcelable { Loading core/java/android/credentials/CredentialManager.java +27 −83 Original line number Diff line number Diff line Loading @@ -26,12 +26,12 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemService; import android.annotation.TestApi; import android.app.Activity; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.IntentSender; import android.content.pm.ServiceInfo; import android.os.CancellationSignal; import android.os.ICancellationSignal; import android.os.OutcomeReceiver; Loading Loading @@ -75,21 +75,21 @@ public final class CredentialManager { * * @hide */ public static final int PROVIDER_FILTER_ALL_PROVIDERS = 0; @TestApi public static final int PROVIDER_FILTER_ALL_PROVIDERS = 0; /** * Returns system credential providers only. * * @hide */ public static final int PROVIDER_FILTER_SYSTEM_PROVIDERS_ONLY = 1; @TestApi public static final int PROVIDER_FILTER_SYSTEM_PROVIDERS_ONLY = 1; /** * Returns user credential providers only. * * @hide */ public static final int PROVIDER_FILTER_USER_PROVIDERS_ONLY = 2; @TestApi public static final int PROVIDER_FILTER_USER_PROVIDERS_ONLY = 2; private final Context mContext; private final ICredentialManager mService; Loading Loading @@ -262,44 +262,6 @@ public final class CredentialManager { } } /** * Gets a list of all user configurable credential providers registered on the system. This API * is intended for browsers and settings apps. * * @param cancellationSignal an optional signal that allows for cancelling this call * @param executor the callback will take place on this {@link Executor} * @param callback the callback invoked when the request succeeds or fails * @hide */ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void listEnabledProviders( @Nullable CancellationSignal cancellationSignal, @CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<ListEnabledProvidersResponse, ListEnabledProvidersException> callback) { requireNonNull(executor, "executor must not be null"); requireNonNull(callback, "callback must not be null"); if (cancellationSignal != null && cancellationSignal.isCanceled()) { Log.w(TAG, "listEnabledProviders already canceled"); return; } ICancellationSignal cancelRemote = null; try { cancelRemote = mService.listEnabledProviders( new ListEnabledProvidersTransport(executor, callback)); } catch (RemoteException e) { e.rethrowFromSystemServer(); } if (cancellationSignal != null && cancelRemote != null) { cancellationSignal.setRemote(cancelRemote); } } /** * Sets a list of all user configurable credential providers registered on the system. This API * is intended for settings apps. Loading Loading @@ -348,36 +310,43 @@ public final class CredentialManager { } /** * Returns the list of ServiceInfo for all discovered credential providers on this device. * Returns the list of CredentialProviderInfo for all discovered credential providers on this * device but will include test system providers as well. * * @hide */ @NonNull @RequiresPermission(android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS) public List<ServiceInfo> getCredentialProviderServicesForTesting( @TestApi @RequiresPermission( anyOf = { android.Manifest.permission.QUERY_ALL_PACKAGES, android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS }) public List<CredentialProviderInfo> getCredentialProviderServicesForTesting( @ProviderFilter int providerFilter) { try { return mService.getCredentialProviderServices( mContext.getUserId(), /* disableSystemAppVerificationForTests= */ true, providerFilter); return mService.getCredentialProviderServicesForTesting(providerFilter); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the list of ServiceInfo for all discovered credential providers on this device. * Returns the list of CredentialProviderInfo for all discovered credential providers on this * device. * * @hide */ @NonNull @RequiresPermission(android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS) public List<ServiceInfo> getCredentialProviderServices( @RequiresPermission( anyOf = { android.Manifest.permission.QUERY_ALL_PACKAGES, android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS }) public List<CredentialProviderInfo> getCredentialProviderServices( int userId, @ProviderFilter int providerFilter) { try { return mService.getCredentialProviderServices( userId, /* disableSystemAppVerificationForTests= */ false, providerFilter); return mService.getCredentialProviderServices(userId, providerFilter); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -388,7 +357,9 @@ public final class CredentialManager { * * @hide */ public static boolean isServiceEnabled(Context context) { @TestApi public static boolean isServiceEnabled(@NonNull Context context) { requireNonNull(context, "context must not be null"); if (context == null) { return false; } Loading Loading @@ -578,33 +549,6 @@ public final class CredentialManager { } } private static class ListEnabledProvidersTransport extends IListEnabledProvidersCallback.Stub { // TODO: listen for cancellation to release callback. private final Executor mExecutor; private final OutcomeReceiver<ListEnabledProvidersResponse, ListEnabledProvidersException> mCallback; private ListEnabledProvidersTransport( Executor executor, OutcomeReceiver<ListEnabledProvidersResponse, ListEnabledProvidersException> callback) { mExecutor = executor; mCallback = callback; } @Override public void onResponse(ListEnabledProvidersResponse response) { mExecutor.execute(() -> mCallback.onResult(response)); } @Override public void onError(String errorType, String message) { mExecutor.execute( () -> mCallback.onError(new ListEnabledProvidersException(errorType, message))); } } private static class SetEnabledProvidersTransport extends ISetEnabledProvidersCallback.Stub { // TODO: listen for cancellation to release callback. Loading core/java/android/credentials/IListEnabledProvidersCallback.aidl→core/java/android/credentials/CredentialProviderInfo.aidl +2 −12 Original line number Diff line number Diff line /* * Copyright 2022 The Android Open Source Project * Copyright 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -16,14 +16,4 @@ package android.credentials; import android.credentials.ListEnabledProvidersResponse; /** * Listener for an listEnabledProviders request. * * @hide */ interface IListEnabledProvidersCallback { oneway void onResponse(in ListEnabledProvidersResponse response); oneway void onError(String errorType, String message); } No newline at end of file parcelable CredentialProviderInfo; No newline at end of file core/java/android/credentials/CredentialProviderInfo.java 0 → 100644 +215 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.credentials; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.content.ComponentName; import android.content.Context; import android.content.pm.ServiceInfo; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * {@link ServiceInfo} and meta-data about a credential provider. * * @hide */ @TestApi public final class CredentialProviderInfo implements Parcelable { @NonNull private final ServiceInfo mServiceInfo; @NonNull private final List<String> mCapabilities = new ArrayList<>(); @Nullable private final CharSequence mOverrideLabel; private final boolean mIsSystemProvider; private final boolean mIsEnabled; /** * Constructs an information instance of the credential provider. * * @param builder the builder object. */ private CredentialProviderInfo(@NonNull Builder builder) { mServiceInfo = builder.mServiceInfo; mCapabilities.addAll(builder.mCapabilities); mIsSystemProvider = builder.mIsSystemProvider; mIsEnabled = builder.mIsEnabled; mOverrideLabel = builder.mOverrideLabel; } /** Returns true if the service supports the given {@code credentialType}, false otherwise. */ @NonNull public boolean hasCapability(@NonNull String credentialType) { return mCapabilities.contains(credentialType); } /** Returns the service info. */ @NonNull public ServiceInfo getServiceInfo() { return mServiceInfo; } /** Returns whether it is a system provider. */ public boolean isSystemProvider() { return mIsSystemProvider; } /** Returns the service icon. */ @Nullable public Drawable getServiceIcon(@NonNull Context context) { return mServiceInfo.loadIcon(context.getPackageManager()); } /** Returns the service label. */ @Nullable public CharSequence getLabel(@NonNull Context context) { if (mOverrideLabel != null) { return mOverrideLabel; } return mServiceInfo.loadSafeLabel(context.getPackageManager()); } /** Returns a list of capabilities this provider service can support. */ @NonNull public List<String> getCapabilities() { return Collections.unmodifiableList(mCapabilities); } /** Returns whether the provider is enabled by the user. */ public boolean isEnabled() { return mIsEnabled; } /** Returns the component name for the service. */ @NonNull public ComponentName getComponentName() { return mServiceInfo.getComponentName(); } @Override public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeTypedObject(mServiceInfo, flags); dest.writeBoolean(mIsSystemProvider); dest.writeStringList(mCapabilities); dest.writeBoolean(mIsEnabled); TextUtils.writeToParcel(mOverrideLabel, dest, flags); } @Override public int describeContents() { return 0; } @Override public String toString() { return "CredentialProviderInfo {" + "serviceInfo=" + mServiceInfo + ", " + "isSystemProvider=" + mIsSystemProvider + ", " + "isEnabled=" + mIsEnabled + ", " + "overrideLabel=" + mOverrideLabel + ", " + "capabilities=" + String.join(",", mCapabilities) + "}"; } private CredentialProviderInfo(@NonNull Parcel in) { mServiceInfo = in.readTypedObject(ServiceInfo.CREATOR); mIsSystemProvider = in.readBoolean(); in.readStringList(mCapabilities); mIsEnabled = in.readBoolean(); mOverrideLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); } public static final @NonNull Parcelable.Creator<CredentialProviderInfo> CREATOR = new Parcelable.Creator<CredentialProviderInfo>() { @Override public CredentialProviderInfo[] newArray(int size) { return new CredentialProviderInfo[size]; } @Override public CredentialProviderInfo createFromParcel(@NonNull Parcel in) { return new CredentialProviderInfo(in); } }; /** A builder for {@link CredentialProviderInfo} objects. */ public static final class Builder { @NonNull private ServiceInfo mServiceInfo; @NonNull private List<String> mCapabilities = new ArrayList<>(); private boolean mIsSystemProvider = false; private boolean mIsEnabled = false; @Nullable private CharSequence mOverrideLabel = null; /** * Creates a new builder. * * @param serviceInfo the service info of the credential provider service. */ public Builder(@NonNull ServiceInfo serviceInfo) { mServiceInfo = serviceInfo; } /** Sets whether it is a system provider. */ public @NonNull Builder setSystemProvider(boolean isSystemProvider) { mIsSystemProvider = isSystemProvider; return this; } /** * Sets the label to be used instead of getting from the system (for unit tests). * * @hide */ public @NonNull Builder setOverrideLabel(@NonNull CharSequence overrideLabel) { mOverrideLabel = overrideLabel; return this; } /** Sets a list of capabilities this provider service can support. */ public @NonNull Builder addCapabilities(@NonNull List<String> capabilities) { mCapabilities.addAll(capabilities); return this; } /** Sets whether it is enabled by the user. */ public @NonNull Builder setEnabled(boolean isEnabled) { mIsEnabled = isEnabled; return this; } /** Builds a new {@link CredentialProviderInfo} instance. */ public @NonNull CredentialProviderInfo build() { return new CredentialProviderInfo(this); } } } core/java/android/credentials/ICredentialManager.aidl +4 −5 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package android.credentials; import java.util.List; import android.content.pm.ServiceInfo; import android.credentials.CredentialProviderInfo; import android.credentials.ClearCredentialStateRequest; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialRequest; Loading @@ -27,7 +27,6 @@ import android.credentials.UnregisterCredentialDescriptionRequest; import android.credentials.IClearCredentialStateCallback; import android.credentials.ICreateCredentialCallback; import android.credentials.IGetCredentialCallback; import android.credentials.IListEnabledProvidersCallback; import android.credentials.ISetEnabledProvidersCallback; import android.content.ComponentName; import android.os.ICancellationSignal; Loading @@ -45,8 +44,6 @@ interface ICredentialManager { @nullable ICancellationSignal clearCredentialState(in ClearCredentialStateRequest request, in IClearCredentialStateCallback callback, String callingPackage); @nullable ICancellationSignal listEnabledProviders(in IListEnabledProvidersCallback callback); void setEnabledProviders(in List<String> providers, in int userId, in ISetEnabledProvidersCallback callback); void registerCredentialDescription(in RegisterCredentialDescriptionRequest request, String callingPackage); Loading @@ -55,6 +52,8 @@ interface ICredentialManager { boolean isEnabledCredentialProviderService(in ComponentName componentName, String callingPackage); List<ServiceInfo> getCredentialProviderServices(in int userId, in boolean disableSystemAppVerificationForTests, in int providerFilter); List<CredentialProviderInfo> getCredentialProviderServices(in int userId, in int providerFilter); List<CredentialProviderInfo> getCredentialProviderServicesForTesting(in int providerFilter); } Loading
core/api/test-current.txt +34 −0 Original line number Diff line number Diff line Loading @@ -1072,6 +1072,40 @@ package android.content.rollback { } package android.credentials { public final class CredentialManager { method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.QUERY_ALL_PACKAGES, "android.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS"}) public java.util.List<android.credentials.CredentialProviderInfo> getCredentialProviderServicesForTesting(int); method public static boolean isServiceEnabled(@NonNull android.content.Context); field public static final int PROVIDER_FILTER_ALL_PROVIDERS = 0; // 0x0 field public static final int PROVIDER_FILTER_SYSTEM_PROVIDERS_ONLY = 1; // 0x1 field public static final int PROVIDER_FILTER_USER_PROVIDERS_ONLY = 2; // 0x2 } public final class CredentialProviderInfo implements android.os.Parcelable { method public int describeContents(); method @NonNull public java.util.List<java.lang.String> getCapabilities(); method @NonNull public android.content.ComponentName getComponentName(); method @Nullable public CharSequence getLabel(@NonNull android.content.Context); method @Nullable public android.graphics.drawable.Drawable getServiceIcon(@NonNull android.content.Context); method @NonNull public android.content.pm.ServiceInfo getServiceInfo(); method @NonNull public boolean hasCapability(@NonNull String); method public boolean isEnabled(); method public boolean isSystemProvider(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.credentials.CredentialProviderInfo> CREATOR; } public static final class CredentialProviderInfo.Builder { ctor public CredentialProviderInfo.Builder(@NonNull android.content.pm.ServiceInfo); method @NonNull public android.credentials.CredentialProviderInfo.Builder addCapabilities(@NonNull java.util.List<java.lang.String>); method @NonNull public android.credentials.CredentialProviderInfo build(); method @NonNull public android.credentials.CredentialProviderInfo.Builder setEnabled(boolean); method @NonNull public android.credentials.CredentialProviderInfo.Builder setSystemProvider(boolean); } } package android.credentials.ui { public final class AuthenticationEntry implements android.os.Parcelable { Loading
core/java/android/credentials/CredentialManager.java +27 −83 Original line number Diff line number Diff line Loading @@ -26,12 +26,12 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SystemService; import android.annotation.TestApi; import android.app.Activity; import android.app.PendingIntent; import android.content.ComponentName; import android.content.Context; import android.content.IntentSender; import android.content.pm.ServiceInfo; import android.os.CancellationSignal; import android.os.ICancellationSignal; import android.os.OutcomeReceiver; Loading Loading @@ -75,21 +75,21 @@ public final class CredentialManager { * * @hide */ public static final int PROVIDER_FILTER_ALL_PROVIDERS = 0; @TestApi public static final int PROVIDER_FILTER_ALL_PROVIDERS = 0; /** * Returns system credential providers only. * * @hide */ public static final int PROVIDER_FILTER_SYSTEM_PROVIDERS_ONLY = 1; @TestApi public static final int PROVIDER_FILTER_SYSTEM_PROVIDERS_ONLY = 1; /** * Returns user credential providers only. * * @hide */ public static final int PROVIDER_FILTER_USER_PROVIDERS_ONLY = 2; @TestApi public static final int PROVIDER_FILTER_USER_PROVIDERS_ONLY = 2; private final Context mContext; private final ICredentialManager mService; Loading Loading @@ -262,44 +262,6 @@ public final class CredentialManager { } } /** * Gets a list of all user configurable credential providers registered on the system. This API * is intended for browsers and settings apps. * * @param cancellationSignal an optional signal that allows for cancelling this call * @param executor the callback will take place on this {@link Executor} * @param callback the callback invoked when the request succeeds or fails * @hide */ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public void listEnabledProviders( @Nullable CancellationSignal cancellationSignal, @CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<ListEnabledProvidersResponse, ListEnabledProvidersException> callback) { requireNonNull(executor, "executor must not be null"); requireNonNull(callback, "callback must not be null"); if (cancellationSignal != null && cancellationSignal.isCanceled()) { Log.w(TAG, "listEnabledProviders already canceled"); return; } ICancellationSignal cancelRemote = null; try { cancelRemote = mService.listEnabledProviders( new ListEnabledProvidersTransport(executor, callback)); } catch (RemoteException e) { e.rethrowFromSystemServer(); } if (cancellationSignal != null && cancelRemote != null) { cancellationSignal.setRemote(cancelRemote); } } /** * Sets a list of all user configurable credential providers registered on the system. This API * is intended for settings apps. Loading Loading @@ -348,36 +310,43 @@ public final class CredentialManager { } /** * Returns the list of ServiceInfo for all discovered credential providers on this device. * Returns the list of CredentialProviderInfo for all discovered credential providers on this * device but will include test system providers as well. * * @hide */ @NonNull @RequiresPermission(android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS) public List<ServiceInfo> getCredentialProviderServicesForTesting( @TestApi @RequiresPermission( anyOf = { android.Manifest.permission.QUERY_ALL_PACKAGES, android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS }) public List<CredentialProviderInfo> getCredentialProviderServicesForTesting( @ProviderFilter int providerFilter) { try { return mService.getCredentialProviderServices( mContext.getUserId(), /* disableSystemAppVerificationForTests= */ true, providerFilter); return mService.getCredentialProviderServicesForTesting(providerFilter); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Returns the list of ServiceInfo for all discovered credential providers on this device. * Returns the list of CredentialProviderInfo for all discovered credential providers on this * device. * * @hide */ @NonNull @RequiresPermission(android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS) public List<ServiceInfo> getCredentialProviderServices( @RequiresPermission( anyOf = { android.Manifest.permission.QUERY_ALL_PACKAGES, android.Manifest.permission.LIST_ENABLED_CREDENTIAL_PROVIDERS }) public List<CredentialProviderInfo> getCredentialProviderServices( int userId, @ProviderFilter int providerFilter) { try { return mService.getCredentialProviderServices( userId, /* disableSystemAppVerificationForTests= */ false, providerFilter); return mService.getCredentialProviderServices(userId, providerFilter); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -388,7 +357,9 @@ public final class CredentialManager { * * @hide */ public static boolean isServiceEnabled(Context context) { @TestApi public static boolean isServiceEnabled(@NonNull Context context) { requireNonNull(context, "context must not be null"); if (context == null) { return false; } Loading Loading @@ -578,33 +549,6 @@ public final class CredentialManager { } } private static class ListEnabledProvidersTransport extends IListEnabledProvidersCallback.Stub { // TODO: listen for cancellation to release callback. private final Executor mExecutor; private final OutcomeReceiver<ListEnabledProvidersResponse, ListEnabledProvidersException> mCallback; private ListEnabledProvidersTransport( Executor executor, OutcomeReceiver<ListEnabledProvidersResponse, ListEnabledProvidersException> callback) { mExecutor = executor; mCallback = callback; } @Override public void onResponse(ListEnabledProvidersResponse response) { mExecutor.execute(() -> mCallback.onResult(response)); } @Override public void onError(String errorType, String message) { mExecutor.execute( () -> mCallback.onError(new ListEnabledProvidersException(errorType, message))); } } private static class SetEnabledProvidersTransport extends ISetEnabledProvidersCallback.Stub { // TODO: listen for cancellation to release callback. Loading
core/java/android/credentials/IListEnabledProvidersCallback.aidl→core/java/android/credentials/CredentialProviderInfo.aidl +2 −12 Original line number Diff line number Diff line /* * Copyright 2022 The Android Open Source Project * Copyright 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -16,14 +16,4 @@ package android.credentials; import android.credentials.ListEnabledProvidersResponse; /** * Listener for an listEnabledProviders request. * * @hide */ interface IListEnabledProvidersCallback { oneway void onResponse(in ListEnabledProvidersResponse response); oneway void onError(String errorType, String message); } No newline at end of file parcelable CredentialProviderInfo; No newline at end of file
core/java/android/credentials/CredentialProviderInfo.java 0 → 100644 +215 −0 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.credentials; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.content.ComponentName; import android.content.Context; import android.content.pm.ServiceInfo; import android.graphics.drawable.Drawable; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * {@link ServiceInfo} and meta-data about a credential provider. * * @hide */ @TestApi public final class CredentialProviderInfo implements Parcelable { @NonNull private final ServiceInfo mServiceInfo; @NonNull private final List<String> mCapabilities = new ArrayList<>(); @Nullable private final CharSequence mOverrideLabel; private final boolean mIsSystemProvider; private final boolean mIsEnabled; /** * Constructs an information instance of the credential provider. * * @param builder the builder object. */ private CredentialProviderInfo(@NonNull Builder builder) { mServiceInfo = builder.mServiceInfo; mCapabilities.addAll(builder.mCapabilities); mIsSystemProvider = builder.mIsSystemProvider; mIsEnabled = builder.mIsEnabled; mOverrideLabel = builder.mOverrideLabel; } /** Returns true if the service supports the given {@code credentialType}, false otherwise. */ @NonNull public boolean hasCapability(@NonNull String credentialType) { return mCapabilities.contains(credentialType); } /** Returns the service info. */ @NonNull public ServiceInfo getServiceInfo() { return mServiceInfo; } /** Returns whether it is a system provider. */ public boolean isSystemProvider() { return mIsSystemProvider; } /** Returns the service icon. */ @Nullable public Drawable getServiceIcon(@NonNull Context context) { return mServiceInfo.loadIcon(context.getPackageManager()); } /** Returns the service label. */ @Nullable public CharSequence getLabel(@NonNull Context context) { if (mOverrideLabel != null) { return mOverrideLabel; } return mServiceInfo.loadSafeLabel(context.getPackageManager()); } /** Returns a list of capabilities this provider service can support. */ @NonNull public List<String> getCapabilities() { return Collections.unmodifiableList(mCapabilities); } /** Returns whether the provider is enabled by the user. */ public boolean isEnabled() { return mIsEnabled; } /** Returns the component name for the service. */ @NonNull public ComponentName getComponentName() { return mServiceInfo.getComponentName(); } @Override public void writeToParcel(@NonNull Parcel dest, int flags) { dest.writeTypedObject(mServiceInfo, flags); dest.writeBoolean(mIsSystemProvider); dest.writeStringList(mCapabilities); dest.writeBoolean(mIsEnabled); TextUtils.writeToParcel(mOverrideLabel, dest, flags); } @Override public int describeContents() { return 0; } @Override public String toString() { return "CredentialProviderInfo {" + "serviceInfo=" + mServiceInfo + ", " + "isSystemProvider=" + mIsSystemProvider + ", " + "isEnabled=" + mIsEnabled + ", " + "overrideLabel=" + mOverrideLabel + ", " + "capabilities=" + String.join(",", mCapabilities) + "}"; } private CredentialProviderInfo(@NonNull Parcel in) { mServiceInfo = in.readTypedObject(ServiceInfo.CREATOR); mIsSystemProvider = in.readBoolean(); in.readStringList(mCapabilities); mIsEnabled = in.readBoolean(); mOverrideLabel = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); } public static final @NonNull Parcelable.Creator<CredentialProviderInfo> CREATOR = new Parcelable.Creator<CredentialProviderInfo>() { @Override public CredentialProviderInfo[] newArray(int size) { return new CredentialProviderInfo[size]; } @Override public CredentialProviderInfo createFromParcel(@NonNull Parcel in) { return new CredentialProviderInfo(in); } }; /** A builder for {@link CredentialProviderInfo} objects. */ public static final class Builder { @NonNull private ServiceInfo mServiceInfo; @NonNull private List<String> mCapabilities = new ArrayList<>(); private boolean mIsSystemProvider = false; private boolean mIsEnabled = false; @Nullable private CharSequence mOverrideLabel = null; /** * Creates a new builder. * * @param serviceInfo the service info of the credential provider service. */ public Builder(@NonNull ServiceInfo serviceInfo) { mServiceInfo = serviceInfo; } /** Sets whether it is a system provider. */ public @NonNull Builder setSystemProvider(boolean isSystemProvider) { mIsSystemProvider = isSystemProvider; return this; } /** * Sets the label to be used instead of getting from the system (for unit tests). * * @hide */ public @NonNull Builder setOverrideLabel(@NonNull CharSequence overrideLabel) { mOverrideLabel = overrideLabel; return this; } /** Sets a list of capabilities this provider service can support. */ public @NonNull Builder addCapabilities(@NonNull List<String> capabilities) { mCapabilities.addAll(capabilities); return this; } /** Sets whether it is enabled by the user. */ public @NonNull Builder setEnabled(boolean isEnabled) { mIsEnabled = isEnabled; return this; } /** Builds a new {@link CredentialProviderInfo} instance. */ public @NonNull CredentialProviderInfo build() { return new CredentialProviderInfo(this); } } }
core/java/android/credentials/ICredentialManager.aidl +4 −5 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ package android.credentials; import java.util.List; import android.content.pm.ServiceInfo; import android.credentials.CredentialProviderInfo; import android.credentials.ClearCredentialStateRequest; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialRequest; Loading @@ -27,7 +27,6 @@ import android.credentials.UnregisterCredentialDescriptionRequest; import android.credentials.IClearCredentialStateCallback; import android.credentials.ICreateCredentialCallback; import android.credentials.IGetCredentialCallback; import android.credentials.IListEnabledProvidersCallback; import android.credentials.ISetEnabledProvidersCallback; import android.content.ComponentName; import android.os.ICancellationSignal; Loading @@ -45,8 +44,6 @@ interface ICredentialManager { @nullable ICancellationSignal clearCredentialState(in ClearCredentialStateRequest request, in IClearCredentialStateCallback callback, String callingPackage); @nullable ICancellationSignal listEnabledProviders(in IListEnabledProvidersCallback callback); void setEnabledProviders(in List<String> providers, in int userId, in ISetEnabledProvidersCallback callback); void registerCredentialDescription(in RegisterCredentialDescriptionRequest request, String callingPackage); Loading @@ -55,6 +52,8 @@ interface ICredentialManager { boolean isEnabledCredentialProviderService(in ComponentName componentName, String callingPackage); List<ServiceInfo> getCredentialProviderServices(in int userId, in boolean disableSystemAppVerificationForTests, in int providerFilter); List<CredentialProviderInfo> getCredentialProviderServices(in int userId, in int providerFilter); List<CredentialProviderInfo> getCredentialProviderServicesForTesting(in int providerFilter); }