Loading services/credentials/java/com/android/server/credentials/ClearRequestSession.java +8 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,10 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta } @Override public void onFinalResponseReceived(ComponentName componentName, Void response) { public void onFinalResponseReceived( ComponentName componentName, Void response) { setChosenMetric(componentName); respondToClientWithResponseAndFinish(); } Loading Loading @@ -114,6 +117,8 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta Log.i(TAG, "respondToClientWithResponseAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false mChosenProviderMetric.setChosenProviderStatus( MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_SUCCESS); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; Loading @@ -122,6 +127,8 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta mClientCallback.onSuccess(); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { mChosenProviderMetric.setChosenProviderStatus( MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_FAILURE); Log.i(TAG, "Issue while propagating the response to the client"); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); } Loading services/credentials/java/com/android/server/credentials/CreateRequestSession.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.credentials; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_FAILURE; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_SUCCESS; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; Loading Loading @@ -94,9 +97,14 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR public void onFinalResponseReceived(ComponentName componentName, @Nullable CreateCredentialResponse response) { Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString()); setChosenMetric(componentName); if (response != null) { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_SUCCESS); respondToClientWithResponseAndFinish(response); } else { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_FAILURE); respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS, "Invalid response"); } Loading services/credentials/java/com/android/server/credentials/CredentialManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -357,7 +357,6 @@ public final class CredentialManagerService final int userId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); enforceCallingPackage(callingPackage, callingUid); // New request session, scoped for this request only. final GetRequestSession session = new GetRequestSession( Loading Loading @@ -497,6 +496,7 @@ public final class CredentialManagerService Log.i(TAG, "starting executeCreateCredential with callingPackage: " + callingPackage); ICancellationSignal cancelTransport = CancellationSignal.createTransport(); final int userId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); enforceCallingPackage(callingPackage, callingUid); Loading services/credentials/java/com/android/server/credentials/GetRequestSession.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.credentials; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_FAILURE; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_SUCCESS; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -87,9 +90,14 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest public void onFinalResponseReceived(ComponentName componentName, @Nullable GetCredentialResponse response) { Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString()); setChosenMetric(componentName); if (response != null) { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_SUCCESS); respondToClientWithResponseAndFinish(response); } else { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_FAILURE); respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL, "Invalid response from provider"); } Loading services/credentials/java/com/android/server/credentials/MetricUtilities.java 0 → 100644 +95 −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 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_CLIENT_CANCELED; 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 static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_USER_CANCELED; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_FAILURE; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_SUCCESS; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_FAILURE; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_SUCCESS; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_UNKNOWN; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.util.Log; /** * For all future metric additions, this will contain their names for local usage after importing * from {@link com.android.internal.util.FrameworkStatsLog}. */ public class MetricUtilities { private static final String TAG = "MetricUtilities"; // Metrics constants protected static final int METRICS_API_NAME_UNKNOWN = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN; protected static final int METRICS_API_NAME_GET_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL; protected static final int METRICS_API_NAME_CREATE_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL; protected static final int METRICS_API_NAME_CLEAR_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL; // TODO add isEnabled protected static final int METRICS_API_STATUS_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_SUCCESS; protected static final int METRICS_API_STATUS_FAILURE = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_FAILURE; protected static final int METRICS_API_STATUS_CLIENT_CANCEL = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_CLIENT_CANCELED; protected static final int METRICS_API_STATUS_USER_CANCEL = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_USER_CANCELED; protected static final int METRICS_PROVIDER_STATUS_FINAL_FAILURE = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_FAILURE; protected static final int METRICS_PROVIDER_STATUS_QUERY_FAILURE = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_FAILURE; protected static final int METRICS_PROVIDER_STATUS_FINAL_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_SUCCESS; protected static final int METRICS_PROVIDER_STATUS_QUERY_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_SUCCESS; protected static final int METRICS_PROVIDER_STATUS_UNKNOWN = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_UNKNOWN; /** * This retrieves the uid of any package name, given a context and a component name for the * package. By default, if the desired package uid cannot be found, it will fall back to a * bogus uid. * @return the uid of a given package */ protected static int getPackageUid(Context context, ComponentName componentName) { int sessUid = -1; try { // Only for T and above, which is fine for our use case sessUid = context.getPackageManager().getApplicationInfo( componentName.getPackageName(), PackageManager.ApplicationInfoFlags.of(0)).uid; } catch (Throwable t) { Log.i(TAG, "Couldn't find required uid"); } return sessUid; } } Loading
services/credentials/java/com/android/server/credentials/ClearRequestSession.java +8 −1 Original line number Diff line number Diff line Loading @@ -83,7 +83,10 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta } @Override public void onFinalResponseReceived(ComponentName componentName, Void response) { public void onFinalResponseReceived( ComponentName componentName, Void response) { setChosenMetric(componentName); respondToClientWithResponseAndFinish(); } Loading Loading @@ -114,6 +117,8 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta Log.i(TAG, "respondToClientWithResponseAndFinish"); if (isSessionCancelled()) { // TODO: Differentiate btw cancelled and false mChosenProviderMetric.setChosenProviderStatus( MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_SUCCESS); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); finishSession(/*propagateCancellation=*/true); return; Loading @@ -122,6 +127,8 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta mClientCallback.onSuccess(); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ true); } catch (RemoteException e) { mChosenProviderMetric.setChosenProviderStatus( MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_FAILURE); Log.i(TAG, "Issue while propagating the response to the client"); logApiCalled(RequestType.CLEAR_CREDENTIALS, /* isSuccessful */ false); } Loading
services/credentials/java/com/android/server/credentials/CreateRequestSession.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.credentials; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_FAILURE; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_SUCCESS; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; Loading Loading @@ -94,9 +97,14 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR public void onFinalResponseReceived(ComponentName componentName, @Nullable CreateCredentialResponse response) { Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString()); setChosenMetric(componentName); if (response != null) { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_SUCCESS); respondToClientWithResponseAndFinish(response); } else { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_FAILURE); respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS, "Invalid response"); } Loading
services/credentials/java/com/android/server/credentials/CredentialManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -357,7 +357,6 @@ public final class CredentialManagerService final int userId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); enforceCallingPackage(callingPackage, callingUid); // New request session, scoped for this request only. final GetRequestSession session = new GetRequestSession( Loading Loading @@ -497,6 +496,7 @@ public final class CredentialManagerService Log.i(TAG, "starting executeCreateCredential with callingPackage: " + callingPackage); ICancellationSignal cancelTransport = CancellationSignal.createTransport(); final int userId = UserHandle.getCallingUserId(); final int callingUid = Binder.getCallingUid(); enforceCallingPackage(callingPackage, callingUid); Loading
services/credentials/java/com/android/server/credentials/GetRequestSession.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.server.credentials; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_FAILURE; import static com.android.server.credentials.MetricUtilities.METRICS_PROVIDER_STATUS_FINAL_SUCCESS; import android.annotation.Nullable; import android.content.ComponentName; import android.content.Context; Loading Loading @@ -87,9 +90,14 @@ public final class GetRequestSession extends RequestSession<GetCredentialRequest public void onFinalResponseReceived(ComponentName componentName, @Nullable GetCredentialResponse response) { Log.i(TAG, "onFinalCredentialReceived from: " + componentName.flattenToString()); setChosenMetric(componentName); if (response != null) { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_SUCCESS); respondToClientWithResponseAndFinish(response); } else { mChosenProviderMetric.setChosenProviderStatus( METRICS_PROVIDER_STATUS_FINAL_FAILURE); respondToClientWithErrorAndFinish(GetCredentialException.TYPE_NO_CREDENTIAL, "Invalid response from provider"); } Loading
services/credentials/java/com/android/server/credentials/MetricUtilities.java 0 → 100644 +95 −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 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_CLIENT_CANCELED; 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 static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_USER_CANCELED; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_FAILURE; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_SUCCESS; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_FAILURE; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_SUCCESS; import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_UNKNOWN; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.util.Log; /** * For all future metric additions, this will contain their names for local usage after importing * from {@link com.android.internal.util.FrameworkStatsLog}. */ public class MetricUtilities { private static final String TAG = "MetricUtilities"; // Metrics constants protected static final int METRICS_API_NAME_UNKNOWN = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN; protected static final int METRICS_API_NAME_GET_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL; protected static final int METRICS_API_NAME_CREATE_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL; protected static final int METRICS_API_NAME_CLEAR_CREDENTIAL = CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL; // TODO add isEnabled protected static final int METRICS_API_STATUS_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_SUCCESS; protected static final int METRICS_API_STATUS_FAILURE = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_FAILURE; protected static final int METRICS_API_STATUS_CLIENT_CANCEL = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_CLIENT_CANCELED; protected static final int METRICS_API_STATUS_USER_CANCEL = CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_USER_CANCELED; protected static final int METRICS_PROVIDER_STATUS_FINAL_FAILURE = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_FAILURE; protected static final int METRICS_PROVIDER_STATUS_QUERY_FAILURE = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_FAILURE; protected static final int METRICS_PROVIDER_STATUS_FINAL_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_SUCCESS; protected static final int METRICS_PROVIDER_STATUS_QUERY_SUCCESS = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_SUCCESS; protected static final int METRICS_PROVIDER_STATUS_UNKNOWN = CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_UNKNOWN; /** * This retrieves the uid of any package name, given a context and a component name for the * package. By default, if the desired package uid cannot be found, it will fall back to a * bogus uid. * @return the uid of a given package */ protected static int getPackageUid(Context context, ComponentName componentName) { int sessUid = -1; try { // Only for T and above, which is fine for our use case sessUid = context.getPackageManager().getApplicationInfo( componentName.getPackageName(), PackageManager.ApplicationInfoFlags.of(0)).uid; } catch (Throwable t) { Log.i(TAG, "Couldn't find required uid"); } return sessUid; } }