Loading services/credentials/java/com/android/server/credentials/ClearRequestSession.java +17 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.credentials.ClearCredentialStateRequest; import android.credentials.IClearCredentialStateCallback; import android.credentials.ui.ProviderData; import android.credentials.ui.RequestInfo; import android.os.CancellationSignal; import android.os.RemoteException; import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; Loading @@ -41,9 +42,9 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta public ClearRequestSession(Context context, int userId, int callingUid, IClearCredentialStateCallback callback, ClearCredentialStateRequest request, CallingAppInfo callingAppInfo) { CallingAppInfo callingAppInfo, CancellationSignal cancellationSignal) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_UNDEFINED, callingAppInfo); callingAppInfo, cancellationSignal); } /** Loading Loading @@ -111,6 +112,12 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta private void respondToClientWithResponseAndFinish() { Log.i(TAG, "respondToClientWithResponseAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onSuccess(); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); Loading @@ -118,18 +125,24 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta Log.i(TAG, "Issue while propagating the response to the client"); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); } finishSession(); finishSession(/*propagateCancellation=*/false); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { e.printStackTrace(); } logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); finishSession(); finishSession(/*propagateCancellation=*/false); } private void processResponses() { Loading services/credentials/java/com/android/server/credentials/CreateRequestSession.java +18 −4 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.credentials.CredentialManager; import android.credentials.ICreateCredentialCallback; import android.credentials.ui.ProviderData; import android.credentials.ui.RequestInfo; import android.os.CancellationSignal; import android.os.RemoteException; import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; Loading @@ -47,9 +48,10 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR CreateRequestSession(@NonNull Context context, int userId, int callingUid, CreateCredentialRequest request, ICreateCredentialCallback callback, CallingAppInfo callingAppInfo) { CallingAppInfo callingAppInfo, CancellationSignal cancellationSignal) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_CREATE, callingAppInfo); callingAppInfo, cancellationSignal); } /** Loading Loading @@ -119,6 +121,12 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR private void respondToClientWithResponseAndFinish(CreateCredentialResponse response) { Log.i(TAG, "respondToClientWithResponseAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onResponse(response); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); Loading @@ -126,18 +134,24 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR Log.i(TAG, "Issue while responding to client: " + e.getMessage()); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); } finishSession(); finishSession(/*propagateCancellation=*/false); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client: " + e.getMessage()); } logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); finishSession(); finishSession(/*propagateCancellation=*/false); } @Override Loading services/credentials/java/com/android/server/credentials/CredentialManagerService.java +8 −10 Original line number Diff line number Diff line Loading @@ -194,7 +194,6 @@ public final class CredentialManagerService } @GuardedBy("mLock") private List<CredentialManagerServiceImpl> getOrConstructSystemServiceListLock( int resolvedUserId) { Loading Loading @@ -338,7 +337,8 @@ public final class CredentialManagerService callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); constructCallingAppInfo(callingPackage, userId), CancellationSignal.fromTransport(cancelTransport)); List<ProviderSession> providerSessions; Loading Loading @@ -404,8 +404,6 @@ public final class CredentialManagerService + e.getMessage()); } } // Iterate over all provider sessions and invoke the request providerSessions.forEach(ProviderSession::invokeSession); return cancelTransport; Loading @@ -430,7 +428,8 @@ public final class CredentialManagerService callingUid, request, callback, constructCallingAppInfo(callingPackage, userId)); constructCallingAppInfo(callingPackage, userId), CancellationSignal.fromTransport(cancelTransport)); // Initiate all provider sessions List<ProviderSession> providerSessions = Loading @@ -450,8 +449,7 @@ public final class CredentialManagerService } // Iterate over all provider sessions and invoke the request providerSessions.forEach( ProviderSession::invokeSession); providerSessions.forEach(ProviderSession::invokeSession); return cancelTransport; } Loading Loading @@ -542,7 +540,8 @@ public final class CredentialManagerService callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); constructCallingAppInfo(callingPackage, userId), CancellationSignal.fromTransport(cancelTransport)); // Initiate all provider sessions // TODO: Determine if provider needs to have clear capability in their manifest Loading @@ -563,8 +562,7 @@ public final class CredentialManagerService } // Iterate over all provider sessions and invoke the request providerSessions.forEach( ProviderSession::invokeSession); providerSessions.forEach(ProviderSession::invokeSession); return cancelTransport; } Loading services/credentials/java/com/android/server/credentials/GetRequestSession.java +17 −5 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.credentials.GetCredentialResponse; import android.credentials.IGetCredentialCallback; import android.credentials.ui.ProviderData; import android.credentials.ui.RequestInfo; import android.os.CancellationSignal; import android.os.RemoteException; import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; Loading @@ -43,8 +44,9 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest public GetRequestSession(Context context, int userId, int callingUid, IGetCredentialCallback callback, GetCredentialRequest request, CallingAppInfo callingAppInfo) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_GET, callingAppInfo); CallingAppInfo callingAppInfo, CancellationSignal cancellationSignal) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_GET, callingAppInfo, cancellationSignal); } /** Loading Loading @@ -102,6 +104,12 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest } private void respondToClientWithResponseAndFinish(GetCredentialResponse response) { if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onResponse(response); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ true); Loading @@ -109,18 +117,22 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage()); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); } finishSession(); finishSession(/*propagateCancellation=*/false); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { if (isSessionCancelled()) { logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client with error : " + e.getMessage()); } logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(); finishSession(/*propagateCancellation=*/false); } @Override Loading services/credentials/java/com/android/server/credentials/ProviderSession.java +16 −0 Original line number Diff line number Diff line Loading @@ -23,8 +23,11 @@ import android.content.Context; import android.credentials.Credential; import android.credentials.ui.ProviderData; import android.credentials.ui.ProviderPendingIntentResponse; import android.os.ICancellationSignal; import android.os.RemoteException; import android.service.credentials.CredentialEntry; import android.service.credentials.CredentialProviderInfo; import android.util.Log; import android.util.Pair; import java.util.UUID; Loading @@ -47,6 +50,7 @@ public abstract class ProviderSession<T, R> @NonNull protected Status mStatus = Status.NOT_STARTED; @Nullable protected final ProviderInternalCallback mCallbacks; @Nullable protected Credential mFinalCredentialResponse; @Nullable protected ICancellationSignal mProviderCancellationSignal; @NonNull protected final T mProviderRequest; @Nullable protected R mProviderResponse; @NonNull protected Boolean mProviderResponseSet = false; Loading Loading @@ -149,6 +153,18 @@ public abstract class ProviderSession<T, R> return mFinalCredentialResponse; } /** Propagates cancellation signal to the remote provider service. */ public void cancelProviderRemoteSession() { try { if (mProviderCancellationSignal != null) { mProviderCancellationSignal.cancel(); } setStatus(Status.CANCELED); } catch (RemoteException e) { Log.i(TAG, "Issue while cancelling provider session: " + e.getMessage()); } } protected void setStatus(@NonNull Status status) { mStatus = status; } Loading Loading
services/credentials/java/com/android/server/credentials/ClearRequestSession.java +17 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.credentials.ClearCredentialStateRequest; import android.credentials.IClearCredentialStateCallback; import android.credentials.ui.ProviderData; import android.credentials.ui.RequestInfo; import android.os.CancellationSignal; import android.os.RemoteException; import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; Loading @@ -41,9 +42,9 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta public ClearRequestSession(Context context, int userId, int callingUid, IClearCredentialStateCallback callback, ClearCredentialStateRequest request, CallingAppInfo callingAppInfo) { CallingAppInfo callingAppInfo, CancellationSignal cancellationSignal) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_UNDEFINED, callingAppInfo); callingAppInfo, cancellationSignal); } /** Loading Loading @@ -111,6 +112,12 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta private void respondToClientWithResponseAndFinish() { Log.i(TAG, "respondToClientWithResponseAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onSuccess(); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); Loading @@ -118,18 +125,24 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta Log.i(TAG, "Issue while propagating the response to the client"); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); } finishSession(); finishSession(/*propagateCancellation=*/false); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { e.printStackTrace(); } logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); finishSession(); finishSession(/*propagateCancellation=*/false); } private void processResponses() { Loading
services/credentials/java/com/android/server/credentials/CreateRequestSession.java +18 −4 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.credentials.CredentialManager; import android.credentials.ICreateCredentialCallback; import android.credentials.ui.ProviderData; import android.credentials.ui.RequestInfo; import android.os.CancellationSignal; import android.os.RemoteException; import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; Loading @@ -47,9 +48,10 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR CreateRequestSession(@NonNull Context context, int userId, int callingUid, CreateCredentialRequest request, ICreateCredentialCallback callback, CallingAppInfo callingAppInfo) { CallingAppInfo callingAppInfo, CancellationSignal cancellationSignal) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_CREATE, callingAppInfo); callingAppInfo, cancellationSignal); } /** Loading Loading @@ -119,6 +121,12 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR private void respondToClientWithResponseAndFinish(CreateCredentialResponse response) { Log.i(TAG, "respondToClientWithResponseAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onResponse(response); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); Loading @@ -126,18 +134,24 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR Log.i(TAG, "Issue while responding to client: " + e.getMessage()); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); } finishSession(); finishSession(/*propagateCancellation=*/false); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client: " + e.getMessage()); } logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); finishSession(); finishSession(/*propagateCancellation=*/false); } @Override Loading
services/credentials/java/com/android/server/credentials/CredentialManagerService.java +8 −10 Original line number Diff line number Diff line Loading @@ -194,7 +194,6 @@ public final class CredentialManagerService } @GuardedBy("mLock") private List<CredentialManagerServiceImpl> getOrConstructSystemServiceListLock( int resolvedUserId) { Loading Loading @@ -338,7 +337,8 @@ public final class CredentialManagerService callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); constructCallingAppInfo(callingPackage, userId), CancellationSignal.fromTransport(cancelTransport)); List<ProviderSession> providerSessions; Loading Loading @@ -404,8 +404,6 @@ public final class CredentialManagerService + e.getMessage()); } } // Iterate over all provider sessions and invoke the request providerSessions.forEach(ProviderSession::invokeSession); return cancelTransport; Loading @@ -430,7 +428,8 @@ public final class CredentialManagerService callingUid, request, callback, constructCallingAppInfo(callingPackage, userId)); constructCallingAppInfo(callingPackage, userId), CancellationSignal.fromTransport(cancelTransport)); // Initiate all provider sessions List<ProviderSession> providerSessions = Loading @@ -450,8 +449,7 @@ public final class CredentialManagerService } // Iterate over all provider sessions and invoke the request providerSessions.forEach( ProviderSession::invokeSession); providerSessions.forEach(ProviderSession::invokeSession); return cancelTransport; } Loading Loading @@ -542,7 +540,8 @@ public final class CredentialManagerService callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); constructCallingAppInfo(callingPackage, userId), CancellationSignal.fromTransport(cancelTransport)); // Initiate all provider sessions // TODO: Determine if provider needs to have clear capability in their manifest Loading @@ -563,8 +562,7 @@ public final class CredentialManagerService } // Iterate over all provider sessions and invoke the request providerSessions.forEach( ProviderSession::invokeSession); providerSessions.forEach(ProviderSession::invokeSession); return cancelTransport; } Loading
services/credentials/java/com/android/server/credentials/GetRequestSession.java +17 −5 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.credentials.GetCredentialResponse; import android.credentials.IGetCredentialCallback; import android.credentials.ui.ProviderData; import android.credentials.ui.RequestInfo; import android.os.CancellationSignal; import android.os.RemoteException; import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; Loading @@ -43,8 +44,9 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest public GetRequestSession(Context context, int userId, int callingUid, IGetCredentialCallback callback, GetCredentialRequest request, CallingAppInfo callingAppInfo) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_GET, callingAppInfo); CallingAppInfo callingAppInfo, CancellationSignal cancellationSignal) { super(context, userId, callingUid, request, callback, RequestInfo.TYPE_GET, callingAppInfo, cancellationSignal); } /** Loading Loading @@ -102,6 +104,12 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest } private void respondToClientWithResponseAndFinish(GetCredentialResponse response) { if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onResponse(response); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ true); Loading @@ -109,18 +117,22 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage()); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); } finishSession(); finishSession(/*propagateCancellation=*/false); } private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { if (isSessionCancelled()) { logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(/*propagateCancellation=*/true); return; } try { mClientCallback.onError(errorType, errorMsg); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client with error : " + e.getMessage()); } logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(); finishSession(/*propagateCancellation=*/false); } @Override Loading
services/credentials/java/com/android/server/credentials/ProviderSession.java +16 −0 Original line number Diff line number Diff line Loading @@ -23,8 +23,11 @@ import android.content.Context; import android.credentials.Credential; import android.credentials.ui.ProviderData; import android.credentials.ui.ProviderPendingIntentResponse; import android.os.ICancellationSignal; import android.os.RemoteException; import android.service.credentials.CredentialEntry; import android.service.credentials.CredentialProviderInfo; import android.util.Log; import android.util.Pair; import java.util.UUID; Loading @@ -47,6 +50,7 @@ public abstract class ProviderSession<T, R> @NonNull protected Status mStatus = Status.NOT_STARTED; @Nullable protected final ProviderInternalCallback mCallbacks; @Nullable protected Credential mFinalCredentialResponse; @Nullable protected ICancellationSignal mProviderCancellationSignal; @NonNull protected final T mProviderRequest; @Nullable protected R mProviderResponse; @NonNull protected Boolean mProviderResponseSet = false; Loading Loading @@ -149,6 +153,18 @@ public abstract class ProviderSession<T, R> return mFinalCredentialResponse; } /** Propagates cancellation signal to the remote provider service. */ public void cancelProviderRemoteSession() { try { if (mProviderCancellationSignal != null) { mProviderCancellationSignal.cancel(); } setStatus(Status.CANCELED); } catch (RemoteException e) { Log.i(TAG, "Issue while cancelling provider session: " + e.getMessage()); } } protected void setStatus(@NonNull Status status) { mStatus = status; } Loading