Loading services/credentials/java/com/android/server/credentials/ClearRequestSession.java +9 −3 Original line number Diff line number Diff line Loading @@ -39,15 +39,17 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta implements ProviderSession.ProviderInternalCallback<Void> { private static final String TAG = "GetRequestSession"; public ClearRequestSession(Context context, int userId, public ClearRequestSession(Context context, int userId, int callingUid, IClearCredentialStateCallback callback, ClearCredentialStateRequest request, CallingAppInfo callingAppInfo) { super(context, userId, request, callback, RequestInfo.TYPE_UNDEFINED, callingAppInfo); super(context, userId, callingUid, request, callback, RequestInfo.TYPE_UNDEFINED, callingAppInfo); } /** * Creates a new provider session, and adds it list of providers that are contributing to * this session. * * @return the provider session created within this request session, for the given provider * info. */ Loading Loading @@ -111,8 +113,10 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta Log.i(TAG, "respondToClientWithResponseAndFinish"); try { mClientCallback.onSuccess(); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { Log.i(TAG, "Issue while propagating the response to the client"); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); } finishSession(); } Loading @@ -124,8 +128,10 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta } catch (RemoteException e) { e.printStackTrace(); } logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); finishSession(); } private void processResponses() { for (ProviderSession session : mProviders.values()) { if (session.isProviderResponseSet()) { Loading services/credentials/java/com/android/server/credentials/CreateRequestSession.java +7 −3 Original line number Diff line number Diff line Loading @@ -44,11 +44,12 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR implements ProviderSession.ProviderInternalCallback<CreateCredentialResponse> { private static final String TAG = "CreateRequestSession"; CreateRequestSession(@NonNull Context context, int userId, CreateRequestSession(@NonNull Context context, int userId, int callingUid, CreateCredentialRequest request, ICreateCredentialCallback callback, CallingAppInfo callingAppInfo) { super(context, userId, request, callback, RequestInfo.TYPE_CREATE, callingAppInfo); super(context, userId, callingUid, request, callback, RequestInfo.TYPE_CREATE, callingAppInfo); } /** Loading Loading @@ -115,8 +116,10 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR Log.i(TAG, "respondToClientWithResponseAndFinish"); try { mClientCallback.onResponse(response); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client: " + e.getMessage()); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); } finishSession(); } Loading @@ -128,6 +131,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client: " + e.getMessage()); } logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); finishSession(); } Loading services/credentials/java/com/android/server/credentials/CredentialManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -269,11 +269,13 @@ public final class CredentialManagerService ICancellationSignal cancelTransport = CancellationSignal.createTransport(); int userId = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); // New request session, scoped for this request only. final GetRequestSession session = new GetRequestSession( getContext(), userId, callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); Loading Loading @@ -319,10 +321,12 @@ public final class CredentialManagerService // New request session, scoped for this request only. int userId = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); final CreateRequestSession session = new CreateRequestSession( getContext(), userId, callingUid, request, callback, constructCallingAppInfo(callingPackage, userId)); Loading Loading @@ -434,10 +438,12 @@ public final class CredentialManagerService // New request session, scoped for this request only. int userId = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); final ClearRequestSession session = new ClearRequestSession( getContext(), userId, callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); Loading services/credentials/java/com/android/server/credentials/GetRequestSession.java +5 −2 Original line number Diff line number Diff line Loading @@ -41,10 +41,10 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest implements ProviderSession.ProviderInternalCallback<GetCredentialResponse> { private static final String TAG = "GetRequestSession"; public GetRequestSession(Context context, int userId, public GetRequestSession(Context context, int userId, int callingUid, IGetCredentialCallback callback, GetCredentialRequest request, CallingAppInfo callingAppInfo) { super(context, userId, request, callback, RequestInfo.TYPE_GET, callingAppInfo); super(context, userId, callingUid, request, callback, RequestInfo.TYPE_GET, callingAppInfo); } /** Loading Loading @@ -104,8 +104,10 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest private void respondToClientWithResponseAndFinish(GetCredentialResponse response) { try { mClientCallback.onResponse(response); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage()); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); } finishSession(); } Loading @@ -117,6 +119,7 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest Log.i(TAG, "Issue while responding to client with error : " + e.getMessage()); } logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(); } Loading services/credentials/java/com/android/server/credentials/RequestSession.java +72 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,13 @@ package com.android.server.credentials; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_FAILURE; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_SUCCESS; import android.annotation.NonNull; import android.annotation.UserIdInt; import android.content.Context; Loading @@ -29,6 +36,8 @@ import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; import android.util.Log; import com.android.internal.util.FrameworkStatsLog; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; Loading @@ -40,25 +49,50 @@ import java.util.Map; abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialManagerUiCallback { private static final String TAG = "RequestSession"; // Metrics constants private static final int METRICS_API_NAME_UNKNOWN = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN; private static final int METRICS_API_NAME_GET_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL; private static final int METRICS_API_NAME_CREATE_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL; private static final int METRICS_API_NAME_CLEAR_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL; private static final int METRICS_API_STATUS_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_SUCCESS; private static final int METRICS_API_STATUS_FAILURE = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_FAILURE; // TODO: Revise access levels of attributes @NonNull protected final T mClientRequest; @NonNull protected final U mClientCallback; @NonNull protected final IBinder mRequestId; @NonNull protected final Context mContext; @NonNull protected final CredentialManagerUi mCredentialManagerUi; @NonNull protected final String mRequestType; @NonNull protected final Handler mHandler; @UserIdInt protected final int mUserId; @NonNull protected final CallingAppInfo mClientAppInfo; @NonNull protected final T mClientRequest; @NonNull protected final U mClientCallback; @NonNull protected final IBinder mRequestId; @NonNull protected final Context mContext; @NonNull protected final CredentialManagerUi mCredentialManagerUi; @NonNull protected final String mRequestType; @NonNull protected final Handler mHandler; @UserIdInt protected final int mUserId; private final int mCallingUid; @NonNull protected final CallingAppInfo mClientAppInfo; protected final Map<String, ProviderSession> mProviders = new HashMap<>(); protected RequestSession(@NonNull Context context, @UserIdInt int userId, @NonNull T clientRequest, U clientCallback, @UserIdInt int userId, int callingUid, @NonNull T clientRequest, U clientCallback, @NonNull String requestType, CallingAppInfo callingAppInfo) { mContext = context; mUserId = userId; mCallingUid = callingUid; mClientRequest = clientRequest; mClientCallback = clientCallback; mRequestType = requestType; Loading Loading @@ -117,6 +151,33 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan return false; } // TODO: move these definitions to a separate logging focused class. enum RequestType { GET_CREDENTIALS, CREATE_CREDENTIALS, CLEAR_CREDENTIALS, } private static int getApiNameFromRequestType(RequestType requestType) { switch (requestType) { case GET_CREDENTIALS: return METRICS_API_NAME_GET_CREDENTIAL; case CREATE_CREDENTIALS: return METRICS_API_NAME_CREATE_CREDENTIAL; case CLEAR_CREDENTIALS: return METRICS_API_NAME_CLEAR_CREDENTIAL; default: return METRICS_API_NAME_UNKNOWN; } } protected void logApiCalled(RequestType requestType, boolean isSuccessful) { FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED, /* api_name */getApiNameFromRequestType(requestType), /* caller_uid */ mCallingUid, /* api_status */ isSuccessful ? METRICS_API_STATUS_SUCCESS : METRICS_API_STATUS_FAILURE); } /** * Returns true if at least one provider is ready for UI invocation, and no * provider is pending a response. Loading Loading
services/credentials/java/com/android/server/credentials/ClearRequestSession.java +9 −3 Original line number Diff line number Diff line Loading @@ -39,15 +39,17 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta implements ProviderSession.ProviderInternalCallback<Void> { private static final String TAG = "GetRequestSession"; public ClearRequestSession(Context context, int userId, public ClearRequestSession(Context context, int userId, int callingUid, IClearCredentialStateCallback callback, ClearCredentialStateRequest request, CallingAppInfo callingAppInfo) { super(context, userId, request, callback, RequestInfo.TYPE_UNDEFINED, callingAppInfo); super(context, userId, callingUid, request, callback, RequestInfo.TYPE_UNDEFINED, callingAppInfo); } /** * Creates a new provider session, and adds it list of providers that are contributing to * this session. * * @return the provider session created within this request session, for the given provider * info. */ Loading Loading @@ -111,8 +113,10 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta Log.i(TAG, "respondToClientWithResponseAndFinish"); try { mClientCallback.onSuccess(); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { Log.i(TAG, "Issue while propagating the response to the client"); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); } finishSession(); } Loading @@ -124,8 +128,10 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta } catch (RemoteException e) { e.printStackTrace(); } logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); finishSession(); } private void processResponses() { for (ProviderSession session : mProviders.values()) { if (session.isProviderResponseSet()) { Loading
services/credentials/java/com/android/server/credentials/CreateRequestSession.java +7 −3 Original line number Diff line number Diff line Loading @@ -44,11 +44,12 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR implements ProviderSession.ProviderInternalCallback<CreateCredentialResponse> { private static final String TAG = "CreateRequestSession"; CreateRequestSession(@NonNull Context context, int userId, CreateRequestSession(@NonNull Context context, int userId, int callingUid, CreateCredentialRequest request, ICreateCredentialCallback callback, CallingAppInfo callingAppInfo) { super(context, userId, request, callback, RequestInfo.TYPE_CREATE, callingAppInfo); super(context, userId, callingUid, request, callback, RequestInfo.TYPE_CREATE, callingAppInfo); } /** Loading Loading @@ -115,8 +116,10 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR Log.i(TAG, "respondToClientWithResponseAndFinish"); try { mClientCallback.onResponse(response); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client: " + e.getMessage()); logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); } finishSession(); } Loading @@ -128,6 +131,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client: " + e.getMessage()); } logApiCalled(RequestType.CREATE_CREDENTIALS, /* isSuccessful */ false); finishSession(); } Loading
services/credentials/java/com/android/server/credentials/CredentialManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -269,11 +269,13 @@ public final class CredentialManagerService ICancellationSignal cancelTransport = CancellationSignal.createTransport(); int userId = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); // New request session, scoped for this request only. final GetRequestSession session = new GetRequestSession( getContext(), userId, callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); Loading Loading @@ -319,10 +321,12 @@ public final class CredentialManagerService // New request session, scoped for this request only. int userId = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); final CreateRequestSession session = new CreateRequestSession( getContext(), userId, callingUid, request, callback, constructCallingAppInfo(callingPackage, userId)); Loading Loading @@ -434,10 +438,12 @@ public final class CredentialManagerService // New request session, scoped for this request only. int userId = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); final ClearRequestSession session = new ClearRequestSession( getContext(), userId, callingUid, callback, request, constructCallingAppInfo(callingPackage, userId)); Loading
services/credentials/java/com/android/server/credentials/GetRequestSession.java +5 −2 Original line number Diff line number Diff line Loading @@ -41,10 +41,10 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest implements ProviderSession.ProviderInternalCallback<GetCredentialResponse> { private static final String TAG = "GetRequestSession"; public GetRequestSession(Context context, int userId, public GetRequestSession(Context context, int userId, int callingUid, IGetCredentialCallback callback, GetCredentialRequest request, CallingAppInfo callingAppInfo) { super(context, userId, request, callback, RequestInfo.TYPE_GET, callingAppInfo); super(context, userId, callingUid, request, callback, RequestInfo.TYPE_GET, callingAppInfo); } /** Loading Loading @@ -104,8 +104,10 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest private void respondToClientWithResponseAndFinish(GetCredentialResponse response) { try { mClientCallback.onResponse(response); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage()); logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); } finishSession(); } Loading @@ -117,6 +119,7 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest Log.i(TAG, "Issue while responding to client with error : " + e.getMessage()); } logApiCalled(RequestType.GET_CREDENTIALS, /* isSuccessful */ false); finishSession(); } Loading
services/credentials/java/com/android/server/credentials/RequestSession.java +72 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,13 @@ package com.android.server.credentials; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_FAILURE; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_SUCCESS; import android.annotation.NonNull; import android.annotation.UserIdInt; import android.content.Context; Loading @@ -29,6 +36,8 @@ import android.service.credentials.CallingAppInfo; import android.service.credentials.CredentialProviderInfo; import android.util.Log; import com.android.internal.util.FrameworkStatsLog; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; Loading @@ -40,25 +49,50 @@ import java.util.Map; abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialManagerUiCallback { private static final String TAG = "RequestSession"; // Metrics constants private static final int METRICS_API_NAME_UNKNOWN = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN; private static final int METRICS_API_NAME_GET_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL; private static final int METRICS_API_NAME_CREATE_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL; private static final int METRICS_API_NAME_CLEAR_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL; private static final int METRICS_API_STATUS_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_SUCCESS; private static final int METRICS_API_STATUS_FAILURE = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_FAILURE; // TODO: Revise access levels of attributes @NonNull protected final T mClientRequest; @NonNull protected final U mClientCallback; @NonNull protected final IBinder mRequestId; @NonNull protected final Context mContext; @NonNull protected final CredentialManagerUi mCredentialManagerUi; @NonNull protected final String mRequestType; @NonNull protected final Handler mHandler; @UserIdInt protected final int mUserId; @NonNull protected final CallingAppInfo mClientAppInfo; @NonNull protected final T mClientRequest; @NonNull protected final U mClientCallback; @NonNull protected final IBinder mRequestId; @NonNull protected final Context mContext; @NonNull protected final CredentialManagerUi mCredentialManagerUi; @NonNull protected final String mRequestType; @NonNull protected final Handler mHandler; @UserIdInt protected final int mUserId; private final int mCallingUid; @NonNull protected final CallingAppInfo mClientAppInfo; protected final Map<String, ProviderSession> mProviders = new HashMap<>(); protected RequestSession(@NonNull Context context, @UserIdInt int userId, @NonNull T clientRequest, U clientCallback, @UserIdInt int userId, int callingUid, @NonNull T clientRequest, U clientCallback, @NonNull String requestType, CallingAppInfo callingAppInfo) { mContext = context; mUserId = userId; mCallingUid = callingUid; mClientRequest = clientRequest; mClientCallback = clientCallback; mRequestType = requestType; Loading Loading @@ -117,6 +151,33 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan return false; } // TODO: move these definitions to a separate logging focused class. enum RequestType { GET_CREDENTIALS, CREATE_CREDENTIALS, CLEAR_CREDENTIALS, } private static int getApiNameFromRequestType(RequestType requestType) { switch (requestType) { case GET_CREDENTIALS: return METRICS_API_NAME_GET_CREDENTIAL; case CREATE_CREDENTIALS: return METRICS_API_NAME_CREATE_CREDENTIAL; case CLEAR_CREDENTIALS: return METRICS_API_NAME_CLEAR_CREDENTIAL; default: return METRICS_API_NAME_UNKNOWN; } } protected void logApiCalled(RequestType requestType, boolean isSuccessful) { FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED, /* api_name */getApiNameFromRequestType(requestType), /* caller_uid */ mCallingUid, /* api_status */ isSuccessful ? METRICS_API_STATUS_SUCCESS : METRICS_API_STATUS_FAILURE); } /** * Returns true if at least one provider is ready for UI invocation, and no * provider is pending a response. Loading