Loading core/java/android/credentials/CredentialManager.java +71 −8 Original line number Diff line number Diff line Loading @@ -62,10 +62,10 @@ public final class CredentialManager { * <p>The execution can potentially launch UI flows to collect user consent to using a * credential, display a picker when multiple credentials exist, etc. * * @param request the request specifying type(s) of credentials to get from the user. * @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. * @param request the request specifying type(s) of credentials to get from the user * @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 */ public void executeGetCredential( @NonNull GetCredentialRequest request, Loading Loading @@ -101,10 +101,10 @@ public final class CredentialManager { * <p>The execution can potentially launch UI flows to collect user consent to creating * or storing the new credential, etc. * * @param request the request specifying type(s) of credentials to get from the user. * @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. * @param request the request specifying type(s) of credentials to get from the user * @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 */ public void executeCreateCredential( @NonNull CreateCredentialRequest request, Loading Loading @@ -135,6 +135,44 @@ public final class CredentialManager { } } /** * Clears the current user credential session from all credential providers. * * <p>Usually invoked after your user signs out of your app so that they will not be * automatically signed in the next time. * * @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 */ public void clearCredentialSession( @Nullable CancellationSignal cancellationSignal, @CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<Void, CredentialManagerException> callback) { requireNonNull(executor, "executor must not be null"); requireNonNull(callback, "callback must not be null"); if (cancellationSignal != null && cancellationSignal.isCanceled()) { Log.w(TAG, "executeCreateCredential already canceled"); return; } ICancellationSignal cancelRemote = null; try { cancelRemote = mService.clearCredentialSession( new ClearCredentialSessionTransport(executor, callback), mContext.getOpPackageName()); } catch (RemoteException e) { e.rethrowFromSystemServer(); } if (cancellationSignal != null && cancelRemote != null) { cancellationSignal.setRemote(cancelRemote); } } private static class GetCredentialTransport extends IGetCredentialCallback.Stub { // TODO: listen for cancellation to release callback. Loading Loading @@ -184,4 +222,29 @@ public final class CredentialManager { () -> mCallback.onError(new CredentialManagerException(errorCode, message))); } } private static class ClearCredentialSessionTransport extends IClearCredentialSessionCallback.Stub { // TODO: listen for cancellation to release callback. private final Executor mExecutor; private final OutcomeReceiver<Void, CredentialManagerException> mCallback; private ClearCredentialSessionTransport(Executor executor, OutcomeReceiver<Void, CredentialManagerException> callback) { mExecutor = executor; mCallback = callback; } @Override public void onSuccess() { mCallback.onResult(null); } @Override public void onError(int errorCode, String message) { mExecutor.execute( () -> mCallback.onError(new CredentialManagerException(errorCode, message))); } } } core/java/android/credentials/IClearCredentialSessionCallback.aidl 0 → 100644 +27 −0 Original line number Diff line number Diff line /* * Copyright 2022 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; /** * Listener for clearCredentialSession request. * * @hide */ interface IClearCredentialSessionCallback { oneway void onSuccess(); oneway void onError(int errorCode, String message); } No newline at end of file core/java/android/credentials/ICredentialManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.credentials; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialRequest; import android.credentials.IClearCredentialSessionCallback; import android.credentials.ICreateCredentialCallback; import android.credentials.IGetCredentialCallback; import android.os.ICancellationSignal; Loading @@ -32,4 +33,6 @@ interface ICredentialManager { @nullable ICancellationSignal executeGetCredential(in GetCredentialRequest request, in IGetCredentialCallback callback, String callingPackage); @nullable ICancellationSignal executeCreateCredential(in CreateCredentialRequest request, in ICreateCredentialCallback callback, String callingPackage); @nullable ICancellationSignal clearCredentialSession(in IClearCredentialSessionCallback callback, String callingPackage); } services/credentials/java/com/android/server/credentials/CredentialManagerService.java +10 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import android.content.pm.PackageManager; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialRequest; import android.credentials.IClearCredentialSessionCallback; import android.credentials.ICreateCredentialCallback; import android.credentials.ICredentialManager; import android.credentials.IGetCredentialCallback; Loading Loading @@ -155,5 +156,14 @@ public final class CredentialManagerService extends ICancellationSignal cancelTransport = CancellationSignal.createTransport(); return cancelTransport; } @Override public ICancellationSignal clearCredentialSession( IClearCredentialSessionCallback callback, String callingPackage) { // TODO: implement. Log.i(TAG, "clearCredentialSession"); ICancellationSignal cancelTransport = CancellationSignal.createTransport(); return cancelTransport; } } } Loading
core/java/android/credentials/CredentialManager.java +71 −8 Original line number Diff line number Diff line Loading @@ -62,10 +62,10 @@ public final class CredentialManager { * <p>The execution can potentially launch UI flows to collect user consent to using a * credential, display a picker when multiple credentials exist, etc. * * @param request the request specifying type(s) of credentials to get from the user. * @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. * @param request the request specifying type(s) of credentials to get from the user * @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 */ public void executeGetCredential( @NonNull GetCredentialRequest request, Loading Loading @@ -101,10 +101,10 @@ public final class CredentialManager { * <p>The execution can potentially launch UI flows to collect user consent to creating * or storing the new credential, etc. * * @param request the request specifying type(s) of credentials to get from the user. * @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. * @param request the request specifying type(s) of credentials to get from the user * @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 */ public void executeCreateCredential( @NonNull CreateCredentialRequest request, Loading Loading @@ -135,6 +135,44 @@ public final class CredentialManager { } } /** * Clears the current user credential session from all credential providers. * * <p>Usually invoked after your user signs out of your app so that they will not be * automatically signed in the next time. * * @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 */ public void clearCredentialSession( @Nullable CancellationSignal cancellationSignal, @CallbackExecutor @NonNull Executor executor, @NonNull OutcomeReceiver<Void, CredentialManagerException> callback) { requireNonNull(executor, "executor must not be null"); requireNonNull(callback, "callback must not be null"); if (cancellationSignal != null && cancellationSignal.isCanceled()) { Log.w(TAG, "executeCreateCredential already canceled"); return; } ICancellationSignal cancelRemote = null; try { cancelRemote = mService.clearCredentialSession( new ClearCredentialSessionTransport(executor, callback), mContext.getOpPackageName()); } catch (RemoteException e) { e.rethrowFromSystemServer(); } if (cancellationSignal != null && cancelRemote != null) { cancellationSignal.setRemote(cancelRemote); } } private static class GetCredentialTransport extends IGetCredentialCallback.Stub { // TODO: listen for cancellation to release callback. Loading Loading @@ -184,4 +222,29 @@ public final class CredentialManager { () -> mCallback.onError(new CredentialManagerException(errorCode, message))); } } private static class ClearCredentialSessionTransport extends IClearCredentialSessionCallback.Stub { // TODO: listen for cancellation to release callback. private final Executor mExecutor; private final OutcomeReceiver<Void, CredentialManagerException> mCallback; private ClearCredentialSessionTransport(Executor executor, OutcomeReceiver<Void, CredentialManagerException> callback) { mExecutor = executor; mCallback = callback; } @Override public void onSuccess() { mCallback.onResult(null); } @Override public void onError(int errorCode, String message) { mExecutor.execute( () -> mCallback.onError(new CredentialManagerException(errorCode, message))); } } }
core/java/android/credentials/IClearCredentialSessionCallback.aidl 0 → 100644 +27 −0 Original line number Diff line number Diff line /* * Copyright 2022 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; /** * Listener for clearCredentialSession request. * * @hide */ interface IClearCredentialSessionCallback { oneway void onSuccess(); oneway void onError(int errorCode, String message); } No newline at end of file
core/java/android/credentials/ICredentialManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.credentials; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialRequest; import android.credentials.IClearCredentialSessionCallback; import android.credentials.ICreateCredentialCallback; import android.credentials.IGetCredentialCallback; import android.os.ICancellationSignal; Loading @@ -32,4 +33,6 @@ interface ICredentialManager { @nullable ICancellationSignal executeGetCredential(in GetCredentialRequest request, in IGetCredentialCallback callback, String callingPackage); @nullable ICancellationSignal executeCreateCredential(in CreateCredentialRequest request, in ICreateCredentialCallback callback, String callingPackage); @nullable ICancellationSignal clearCredentialSession(in IClearCredentialSessionCallback callback, String callingPackage); }
services/credentials/java/com/android/server/credentials/CredentialManagerService.java +10 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import android.content.pm.PackageManager; import android.credentials.CreateCredentialRequest; import android.credentials.GetCredentialRequest; import android.credentials.IClearCredentialSessionCallback; import android.credentials.ICreateCredentialCallback; import android.credentials.ICredentialManager; import android.credentials.IGetCredentialCallback; Loading Loading @@ -155,5 +156,14 @@ public final class CredentialManagerService extends ICancellationSignal cancelTransport = CancellationSignal.createTransport(); return cancelTransport; } @Override public ICancellationSignal clearCredentialSession( IClearCredentialSessionCallback callback, String callingPackage) { // TODO: implement. Log.i(TAG, "clearCredentialSession"); ICancellationSignal cancelTransport = CancellationSignal.createTransport(); return cancelTransport; } } }