summaryrefslogtreecommitdiff
path: root/services/credentials/java
diff options
context:
space:
mode:
author Arpan Kaphle <akaphle@google.com> 2023-03-10 21:08:43 +0000
committer Arpan Kaphle <akaphle@google.com> 2023-03-16 21:24:28 +0000
commit2f62f4ead549e2d8539b91d1dedfd7dd1bf3917c (patch)
tree915ce18a4357e7d17f69aa7ba2e4ed7700654634 /services/credentials/java
parent7f58d2a702ed052699f447e8878a4af0ffd422cd (diff)
Unite collection of metrics across all phases
This unites metric collection across the multiple phases, and adds missing collections such as the entries and exception bits. It also adds to the final chosen phase collection object in order to allow this collection to occur. Bug: 270403549 Test: Builds for now, chaining later. Change-Id: If915f7aaeb45bbf5ac7106854c15700a1a37d6af
Diffstat (limited to 'services/credentials/java')
-rw-r--r--services/credentials/java/com/android/server/credentials/ClearRequestSession.java32
-rw-r--r--services/credentials/java/com/android/server/credentials/CreateRequestSession.java41
-rw-r--r--services/credentials/java/com/android/server/credentials/CredentialManagerService.java2
-rw-r--r--services/credentials/java/com/android/server/credentials/GetRequestSession.java35
-rw-r--r--services/credentials/java/com/android/server/credentials/MetricUtilities.java174
-rw-r--r--services/credentials/java/com/android/server/credentials/ProviderClearSession.java2
-rw-r--r--services/credentials/java/com/android/server/credentials/ProviderCreateSession.java24
-rw-r--r--services/credentials/java/com/android/server/credentials/ProviderGetSession.java18
-rw-r--r--services/credentials/java/com/android/server/credentials/ProviderSession.java5
-rw-r--r--services/credentials/java/com/android/server/credentials/RequestSession.java46
-rw-r--r--services/credentials/java/com/android/server/credentials/metrics/ApiName.java20
-rw-r--r--services/credentials/java/com/android/server/credentials/metrics/ApiStatus.java16
-rw-r--r--services/credentials/java/com/android/server/credentials/metrics/CandidatePhaseMetric.java6
-rw-r--r--services/credentials/java/com/android/server/credentials/metrics/ChosenProviderFinalPhaseMetric.java130
-rw-r--r--services/credentials/java/com/android/server/credentials/metrics/EntryEnum.java21
-rw-r--r--services/credentials/java/com/android/server/credentials/metrics/ProviderStatusForMetrics.java20
16 files changed, 418 insertions, 174 deletions
diff --git a/services/credentials/java/com/android/server/credentials/ClearRequestSession.java b/services/credentials/java/com/android/server/credentials/ClearRequestSession.java
index e09c0a2c2280..38dadc6b5b21 100644
--- a/services/credentials/java/com/android/server/credentials/ClearRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/ClearRequestSession.java
@@ -121,33 +121,36 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
private void respondToClientWithResponseAndFinish() {
Log.i(TAG, "respondToClientWithResponseAndFinish");
+ collectFinalPhaseMetricStatus(false, ProviderStatusForMetrics.FINAL_SUCCESS);
if (isSessionCancelled()) {
- mChosenProviderFinalPhaseMetric.setChosenProviderStatus(
- ProviderStatusForMetrics.FINAL_SUCCESS.getMetricCode());
- logApiCall(ApiName.CLEAR_CREDENTIAL, /* apiStatus */
- ApiStatus.CLIENT_CANCELED);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.CLIENT_CANCELED.getMetricCode());
finishSession(/*propagateCancellation=*/true);
return;
}
try {
mClientCallback.onSuccess();
- logApiCall(ApiName.CLEAR_CREDENTIAL, /* apiStatus */
- ApiStatus.SUCCESS);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.SUCCESS.getMetricCode());
} catch (RemoteException e) {
- mChosenProviderFinalPhaseMetric.setChosenProviderStatus(
- ProviderStatusForMetrics.FINAL_FAILURE.getMetricCode());
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
Log.i(TAG, "Issue while propagating the response to the client");
- logApiCall(ApiName.CLEAR_CREDENTIAL, /* apiStatus */
- ApiStatus.FAILURE);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.FAILURE.getMetricCode());
}
finishSession(/*propagateCancellation=*/false);
}
private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) {
Log.i(TAG, "respondToClientWithErrorAndFinish");
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
if (isSessionCancelled()) {
- logApiCall(ApiName.CLEAR_CREDENTIAL, /* apiStatus */
- ApiStatus.CLIENT_CANCELED);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.CLIENT_CANCELED.getMetricCode());
finishSession(/*propagateCancellation=*/true);
return;
}
@@ -156,8 +159,9 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
} catch (RemoteException e) {
e.printStackTrace();
}
- logApiCall(ApiName.CLEAR_CREDENTIAL, /* apiStatus */
- ApiStatus.FAILURE);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.FAILURE.getMetricCode());
finishSession(/*propagateCancellation=*/false);
}
diff --git a/services/credentials/java/com/android/server/credentials/CreateRequestSession.java b/services/credentials/java/com/android/server/credentials/CreateRequestSession.java
index 4f8235a11b2a..06fe4f0b874b 100644
--- a/services/credentials/java/com/android/server/credentials/CreateRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/CreateRequestSession.java
@@ -142,40 +142,47 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
private void respondToClientWithResponseAndFinish(CreateCredentialResponse response) {
Log.i(TAG, "respondToClientWithResponseAndFinish");
- // TODO immediately add exception bit to chosen provider and do final emits across all
- // including sequenceCounter!
+ // TODO(b/271135048) - Improve Metrics super/sub class setup and emit.
+ collectFinalPhaseMetricStatus(false, ProviderStatusForMetrics.FINAL_SUCCESS);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
Log.i(TAG, "Request has already been completed. This is strange.");
return;
}
if (isSessionCancelled()) {
- logApiCall(ApiName.CREATE_CREDENTIAL, /* apiStatus */
- ApiStatus.CLIENT_CANCELED);
+ // TODO(b/271135048) - Migrate to superclass utilities (post beta1 cleanup) - applies
+ // for all
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.CLIENT_CANCELED.getMetricCode());
finishSession(/*propagateCancellation=*/true);
return;
}
try {
mClientCallback.onResponse(response);
- logApiCall(ApiName.CREATE_CREDENTIAL, /* apiStatus */
- ApiStatus.SUCCESS);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.SUCCESS.getMetricCode());
} catch (RemoteException e) {
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
Log.i(TAG, "Issue while responding to client: " + e.getMessage());
- logApiCall(ApiName.CREATE_CREDENTIAL, /* apiStatus */
- ApiStatus.FAILURE);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.FAILURE.getMetricCode());
}
finishSession(/*propagateCancellation=*/false);
}
private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) {
Log.i(TAG, "respondToClientWithErrorAndFinish");
- // TODO add exception bit
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
Log.i(TAG, "Request has already been completed. This is strange.");
return;
}
if (isSessionCancelled()) {
- logApiCall(ApiName.CREATE_CREDENTIAL, /* apiStatus */
- ApiStatus.CLIENT_CANCELED);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.CLIENT_CANCELED.getMetricCode());
finishSession(/*propagateCancellation=*/true);
return;
}
@@ -189,12 +196,16 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
}
private void logFailureOrUserCancel(String errorType) {
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
if (CreateCredentialException.TYPE_USER_CANCELED.equals(errorType)) {
- logApiCall(ApiName.CREATE_CREDENTIAL,
- /* apiStatus */ ApiStatus.USER_CANCELED);
+ mChosenProviderFinalPhaseMetric.setHasException(false);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.USER_CANCELED.getMetricCode());
} else {
- logApiCall(ApiName.CREATE_CREDENTIAL,
- /* apiStatus */ ApiStatus.FAILURE);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.FAILURE.getMetricCode());
}
}
diff --git a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java
index 85a48d9838d1..8f9b9495b137 100644
--- a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java
+++ b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java
@@ -595,7 +595,7 @@ public final class CredentialManagerService
try {
var initMetric = session.mInitialPhaseMetric;
initMetric.setCredentialServiceBeginQueryTimeNanoseconds(System.nanoTime());
- MetricUtilities.logApiCalled(initMetric);
+ MetricUtilities.logApiCalled(initMetric, ++session.mSequenceCounter);
} catch (Exception e) {
Log.w(TAG, "Unexpected error during metric logging: " + e);
}
diff --git a/services/credentials/java/com/android/server/credentials/GetRequestSession.java b/services/credentials/java/com/android/server/credentials/GetRequestSession.java
index 00fbbba7cea5..4e058a8e05e2 100644
--- a/services/credentials/java/com/android/server/credentials/GetRequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/GetRequestSession.java
@@ -123,36 +123,43 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
}
private void respondToClientWithResponseAndFinish(GetCredentialResponse response) {
+ collectFinalPhaseMetricStatus(false, ProviderStatusForMetrics.FINAL_SUCCESS);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
Log.i(TAG, "Request has already been completed. This is strange.");
return;
}
if (isSessionCancelled()) {
- logApiCall(ApiName.GET_CREDENTIAL, /* apiStatus */
- ApiStatus.CLIENT_CANCELED);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.CLIENT_CANCELED.getMetricCode());
finishSession(/*propagateCancellation=*/true);
return;
}
try {
mClientCallback.onResponse(response);
- logApiCall(ApiName.GET_CREDENTIAL, /* apiStatus */
- ApiStatus.SUCCESS);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.SUCCESS.getMetricCode());
} catch (RemoteException e) {
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
Log.i(TAG, "Issue while responding to client with a response : " + e.getMessage());
- logApiCall(ApiName.GET_CREDENTIAL, /* apiStatus */
- ApiStatus.FAILURE);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.FAILURE.getMetricCode());
}
finishSession(/*propagateCancellation=*/false);
}
private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) {
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
Log.i(TAG, "Request has already been completed. This is strange.");
return;
}
if (isSessionCancelled()) {
- logApiCall(ApiName.GET_CREDENTIAL, /* apiStatus */
- ApiStatus.CLIENT_CANCELED);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.CLIENT_CANCELED.getMetricCode());
finishSession(/*propagateCancellation=*/true);
return;
}
@@ -167,12 +174,16 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
}
private void logFailureOrUserCancel(String errorType) {
+ collectFinalPhaseMetricStatus(true, ProviderStatusForMetrics.FINAL_FAILURE);
if (GetCredentialException.TYPE_USER_CANCELED.equals(errorType)) {
- logApiCall(ApiName.GET_CREDENTIAL,
- /* apiStatus */ ApiStatus.USER_CANCELED);
+ mChosenProviderFinalPhaseMetric.setHasException(false);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.USER_CANCELED.getMetricCode());
} else {
- logApiCall(ApiName.GET_CREDENTIAL,
- /* apiStatus */ ApiStatus.FAILURE);
+ logApiCall(mChosenProviderFinalPhaseMetric,
+ mCandidateBrowsingPhaseMetric,
+ /* apiStatus */ ApiStatus.FAILURE.getMetricCode());
}
}
diff --git a/services/credentials/java/com/android/server/credentials/MetricUtilities.java b/services/credentials/java/com/android/server/credentials/MetricUtilities.java
index 99f3b3efe838..65fb3681d24d 100644
--- a/services/credentials/java/com/android/server/credentials/MetricUtilities.java
+++ b/services/credentials/java/com/android/server/credentials/MetricUtilities.java
@@ -24,10 +24,12 @@ import android.util.Log;
import com.android.internal.util.FrameworkStatsLog;
import com.android.server.credentials.metrics.ApiName;
import com.android.server.credentials.metrics.ApiStatus;
+import com.android.server.credentials.metrics.CandidateBrowsingPhaseMetric;
import com.android.server.credentials.metrics.CandidatePhaseMetric;
import com.android.server.credentials.metrics.ChosenProviderFinalPhaseMetric;
import com.android.server.credentials.metrics.InitialPhaseMetric;
+import java.util.List;
import java.util.Map;
/**
@@ -81,77 +83,138 @@ public class MetricUtilities {
}
/**
- * A logging utility used primarily for the candidate phase of the current metric setup.
+ * A logging utility used primarily for the final phase of the current metric setup.
*
- * @param providers a map with known providers
+ * @param finalPhaseMetric the coalesced data of the chosen provider
+ * @param browsingPhaseMetrics the coalesced data of the browsing phase
+ * @param apiStatus the final status of this particular api call
* @param emitSequenceId an emitted sequence id for the current session
*/
- protected static void logApiCalled(Map<String, ProviderSession> providers,
+ protected static void logApiCalled(ChosenProviderFinalPhaseMetric finalPhaseMetric,
+ List<CandidateBrowsingPhaseMetric> browsingPhaseMetrics, int apiStatus,
int emitSequenceId) {
try {
- var providerSessions = providers.values();
- int providerSize = providerSessions.size();
- int[] candidateUidList = new int[providerSize];
- int[] candidateQueryRoundTripTimeList = new int[providerSize];
- int[] candidateStatusList = new int[providerSize];
+ int browsedSize = browsingPhaseMetrics.size();
+ int[] browsedClickedEntries = new int[browsedSize];
+ int[] browsedProviderUid = new int[browsedSize];
int index = 0;
- for (var session : providerSessions) {
- CandidatePhaseMetric metric = session.mCandidatePhasePerProviderMetric;
- candidateUidList[index] = metric.getCandidateUid();
- candidateQueryRoundTripTimeList[index] = metric.getQueryLatencyMicroseconds();
- candidateStatusList[index] = metric.getProviderQueryStatus();
+ for (CandidateBrowsingPhaseMetric metric : browsingPhaseMetrics) {
+ browsedClickedEntries[index] = metric.getEntryEnum();
+ browsedProviderUid[index] = metric.getProviderUid();
index++;
}
- // TODO Handle the emit here
+ FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE,
+ /* session_id */ finalPhaseMetric.getSessionId(),
+ /* sequence_num */ emitSequenceId,
+ /* ui_returned_final_start */ finalPhaseMetric.isUiReturned(),
+ /* chosen_provider_uid */ finalPhaseMetric.getChosenUid(),
+ /* chosen_provider_query_start_timestamp_microseconds */
+ finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
+ .getQueryStartTimeNanoseconds()),
+ /* chosen_provider_query_end_timestamp_microseconds */
+ finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
+ .getQueryEndTimeNanoseconds()),
+ /* chosen_provider_ui_invoked_timestamp_microseconds */
+ finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
+ .getUiCallStartTimeNanoseconds()),
+ /* chosen_provider_ui_finished_timestamp_microseconds */
+ finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
+ .getUiCallEndTimeNanoseconds()),
+ /* chosen_provider_finished_timestamp_microseconds */
+ finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
+ .getFinalFinishTimeNanoseconds()),
+ /* chosen_provider_status */ finalPhaseMetric.getChosenProviderStatus(),
+ /* chosen_provider_has_exception */ finalPhaseMetric.isHasException(),
+ /* chosen_provider_available_entries */ finalPhaseMetric.getAvailableEntries()
+ .stream().mapToInt(i -> i).toArray(),
+ /* chosen_provider_action_entry_count */ finalPhaseMetric.getActionEntryCount(),
+ /* chosen_provider_credential_entry_count */
+ finalPhaseMetric.getCredentialEntryCount(),
+ /* chosen_provider_credential_entry_type_count */
+ finalPhaseMetric.getCredentialEntryTypeCount(),
+ /* chosen_provider_remote_entry_count */
+ finalPhaseMetric.getRemoteEntryCount(),
+ /* chosen_provider_authentication_entry_count */
+ finalPhaseMetric.getAuthenticationEntryCount(),
+ /* clicked_entries */ browsedClickedEntries,
+ /* provider_of_clicked_entry */ browsedProviderUid,
+ /* api_status */ apiStatus
+ );
} catch (Exception e) {
Log.w(TAG, "Unexpected error during metric logging: " + e);
}
}
/**
- * The most common logging helper, handles the overall status of the API request with the
- * provider status and latencies. Other versions of this method may be more useful depending
- * on the situation, as this is geared towards the logging of {@link ProviderSession} types.
+ * A logging utility used primarily for the candidate phase of the current metric setup.
*
- * @param apiName the api type to log
- * @param apiStatus the api status to log
- * @param providers a map with known providers
- * @param callingUid the calling UID of the client app
- * @param chosenProviderFinalPhaseMetric the metric data type of the final chosen provider
- * TODO remove soon
+ * @param providers a map with known providers and their held metric objects
+ * @param emitSequenceId an emitted sequence id for the current session
*/
- protected static void logApiCalled(ApiName apiName, ApiStatus apiStatus,
- Map<String, ProviderSession> providers, int callingUid,
- ChosenProviderFinalPhaseMetric chosenProviderFinalPhaseMetric) {
+ protected static void logApiCalled(Map<String, ProviderSession> providers,
+ int emitSequenceId) {
try {
var providerSessions = providers.values();
int providerSize = providerSessions.size();
+ int sessionId = -1;
+ boolean queryReturned = false;
int[] candidateUidList = new int[providerSize];
- int[] candidateQueryRoundTripTimeList = new int[providerSize];
+ int[] candidateQueryStartTimeStampList = new int[providerSize];
+ int[] candidateQueryEndTimeStampList = new int[providerSize];
int[] candidateStatusList = new int[providerSize];
+ boolean[] candidateHasExceptionList = new boolean[providerSize];
+ int[] candidateTotalEntryCountList = new int[providerSize];
+ int[] candidateCredentialEntryCountList = new int[providerSize];
+ int[] candidateCredentialTypeCountList = new int[providerSize];
+ int[] candidateActionEntryCountList = new int[providerSize];
+ int[] candidateAuthEntryCountList = new int[providerSize];
+ int[] candidateRemoteEntryCountList = new int[providerSize];
int index = 0;
for (var session : providerSessions) {
CandidatePhaseMetric metric = session.mCandidatePhasePerProviderMetric;
+ if (sessionId == -1) {
+ sessionId = metric.getSessionId();
+ }
+ if (!queryReturned) {
+ queryReturned = metric.isQueryReturned();
+ }
candidateUidList[index] = metric.getCandidateUid();
- candidateQueryRoundTripTimeList[index] = metric.getQueryLatencyMicroseconds();
+ candidateQueryStartTimeStampList[index] =
+ metric.getTimestampFromReferenceStartMicroseconds(
+ metric.getStartQueryTimeNanoseconds());
+ candidateQueryEndTimeStampList[index] =
+ metric.getTimestampFromReferenceStartMicroseconds(
+ metric.getQueryFinishTimeNanoseconds());
candidateStatusList[index] = metric.getProviderQueryStatus();
+ candidateHasExceptionList[index] = metric.isHasException();
+ candidateTotalEntryCountList[index] = metric.getNumEntriesTotal();
+ candidateCredentialEntryCountList[index] = metric.getCredentialEntryCount();
+ candidateCredentialTypeCountList[index] = metric.getCredentialEntryTypeCount();
+ candidateActionEntryCountList[index] = metric.getActionEntryCount();
+ candidateAuthEntryCountList[index] = metric.getAuthenticationEntryCount();
+ candidateRemoteEntryCountList[index] = metric.getRemoteEntryCount();
index++;
}
- FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED,
- /* api_name */apiName.getMetricCode(),
- /* caller_uid */ callingUid,
- /* api_status */ apiStatus.getMetricCode(),
- /* repeated_candidate_provider_uid */ candidateUidList,
- /* repeated_candidate_provider_round_trip_time_query_microseconds */
- candidateQueryRoundTripTimeList,
- /* repeated_candidate_provider_status */ candidateStatusList,
- /* chosen_provider_uid */ chosenProviderFinalPhaseMetric.getChosenUid(),
- /* chosen_provider_round_trip_time_overall_microseconds */
- chosenProviderFinalPhaseMetric.getEntireProviderLatencyMicroseconds(),
- /* chosen_provider_final_phase_microseconds (backwards compat only) */
- DEFAULT_INT_32,
- /* chosen_provider_status */ chosenProviderFinalPhaseMetric
- .getChosenProviderStatus());
+ FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_CANDIDATE_PHASE,
+ /* session_id */ sessionId,
+ /* sequence_num */ emitSequenceId,
+ /* query_returned */ queryReturned,
+ /* candidate_provider_uid_list */ candidateUidList,
+ /* candidate_provider_query_start_timestamp_microseconds */
+ candidateQueryStartTimeStampList,
+ /* candidate_provider_query_end_timestamp_microseconds */
+ candidateQueryEndTimeStampList,
+ /* candidate_provider_status */ candidateStatusList,
+ /* candidate_provider_has_exception */ candidateHasExceptionList,
+ /* candidate_provider_num_entries */ candidateTotalEntryCountList,
+ /* candidate_provider_action_entry_count */ candidateActionEntryCountList,
+ /* candidate_provider_credential_entry_count */
+ candidateCredentialEntryCountList,
+ /* candidate_provider_credential_entry_type_count */
+ candidateCredentialTypeCountList,
+ /* candidate_provider_remote_entry_count */ candidateRemoteEntryCountList,
+ /* candidate_provider_authentication_entry_count */ candidateAuthEntryCountList
+ );
} catch (Exception e) {
Log.w(TAG, "Unexpected error during metric logging: " + e);
}
@@ -162,7 +225,6 @@ public class MetricUtilities {
* contain default values for all other optional parameters.
*
* TODO(b/271135048) - given space requirements, this may be a good candidate for another atom
- * TODO immediately remove and carry over TODO to new log for this setup
*
* @param apiName the api name to log
* @param apiStatus the status to log
@@ -194,14 +256,24 @@ public class MetricUtilities {
* Handles the metric emit for the initial phase.
*
* @param initialPhaseMetric contains all the data for this emit
+ * @param sequenceNum the sequence number for this api call session emit
*/
- protected static void logApiCalled(InitialPhaseMetric initialPhaseMetric) {
- /*
- FrameworkStatsLog.write(FrameworkStatsLog.INITIAL_PHASE,
- .. session_id .. initialPhaseMetric.getSessionId(),
- ...
- TODO Immediately - Fill in asap now that the split atom is checked in.
- */
+ protected static void logApiCalled(InitialPhaseMetric initialPhaseMetric, int sequenceNum) {
+ try {
+ FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_INIT_PHASE,
+ /* api_name */ initialPhaseMetric.getApiName(),
+ /* caller_uid */ initialPhaseMetric.getCallerUid(),
+ /* session_id */ initialPhaseMetric.getSessionId(),
+ /* sequence_num */ sequenceNum,
+ /* initial_timestamp_reference_nanoseconds */
+ initialPhaseMetric.getCredentialServiceStartedTimeNanoseconds(),
+ /* count_credential_request_classtypes */
+ initialPhaseMetric.getCountRequestClassType()
+ // TODO(b/271135048) - add total count of request options
+ );
+ } catch (Exception e) {
+ Log.w(TAG, "Unexpected error during metric logging: " + e);
+ }
}
}
diff --git a/services/credentials/java/com/android/server/credentials/ProviderClearSession.java b/services/credentials/java/com/android/server/credentials/ProviderClearSession.java
index b86dabaa8503..69a642d87ff6 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderClearSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderClearSession.java
@@ -91,7 +91,7 @@ public final class ProviderClearSession extends ProviderSession<ClearCredentialS
if (exception instanceof ClearCredentialStateException) {
mProviderException = (ClearCredentialStateException) exception;
}
- captureCandidateFailure();
+ captureCandidateFailureInMetrics();
updateStatusAndInvokeCallback(toStatus(errorCode));
}
diff --git a/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java b/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java
index bbbb15666028..2ba9c226f5b4 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderCreateSession.java
@@ -158,7 +158,7 @@ public final class ProviderCreateSession extends ProviderSession<
// Store query phase exception for aggregation with final response
mProviderException = (CreateCredentialException) exception;
}
- captureCandidateFailure();
+ captureCandidateFailureInMetrics();
updateStatusAndInvokeCallback(toStatus(errorCode));
}
@@ -179,24 +179,32 @@ public final class ProviderCreateSession extends ProviderSession<
mProviderResponseDataHandler.addResponseContent(response.getCreateEntries(),
response.getRemoteCreateEntry());
if (mProviderResponseDataHandler.isEmptyResponse(response)) {
- gatheCandidateEntryMetrics(response);
+ gatherCandidateEntryMetrics(response);
updateStatusAndInvokeCallback(Status.EMPTY_RESPONSE);
} else {
- gatheCandidateEntryMetrics(response);
+ gatherCandidateEntryMetrics(response);
updateStatusAndInvokeCallback(Status.SAVE_ENTRIES_RECEIVED);
}
}
- private void gatheCandidateEntryMetrics(BeginCreateCredentialResponse response) {
+ private void gatherCandidateEntryMetrics(BeginCreateCredentialResponse response) {
try {
var createEntries = response.getCreateEntries();
- int numCreateEntries = createEntries == null ? 0 : createEntries.size();
- // TODO confirm how to get types from slice
- if (numCreateEntries > 0) {
+ int numRemoteEntry = MetricUtilities.ZERO;
+ if (response.getRemoteCreateEntry() != null) {
+ numRemoteEntry = MetricUtilities.UNIT;
+ mCandidatePhasePerProviderMetric.addEntry(EntryEnum.REMOTE_ENTRY);
+ }
+ int numCreateEntries =
+ createEntries == null ? MetricUtilities.ZERO : createEntries.size();
+ if (numCreateEntries > MetricUtilities.ZERO) {
createEntries.forEach(c ->
mCandidatePhasePerProviderMetric.addEntry(EntryEnum.CREDENTIAL_ENTRY));
}
- mCandidatePhasePerProviderMetric.setNumEntriesTotal(numCreateEntries);
+ mCandidatePhasePerProviderMetric.setNumEntriesTotal(numCreateEntries + numRemoteEntry);
+ mCandidatePhasePerProviderMetric.setRemoteEntryCount(numRemoteEntry);
+ mCandidatePhasePerProviderMetric.setCredentialEntryCount(numCreateEntries);
+ mCandidatePhasePerProviderMetric.setCredentialEntryTypeCount(MetricUtilities.UNIT);
} catch (Exception e) {
Log.w(TAG, "Unexpected error during metric logging: " + e);
}
diff --git a/services/credentials/java/com/android/server/credentials/ProviderGetSession.java b/services/credentials/java/com/android/server/credentials/ProviderGetSession.java
index bf1db373446b..9bc5998802bd 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderGetSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderGetSession.java
@@ -50,6 +50,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
* Central provider session that listens for provider callbacks, and maintains provider state.
@@ -195,7 +196,7 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
if (exception instanceof GetCredentialException) {
mProviderException = (GetCredentialException) exception;
}
- captureCandidateFailure();
+ captureCandidateFailureInMetrics();
updateStatusAndInvokeCallback(toStatus(errorCode));
}
@@ -448,9 +449,11 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
int numCredEntries = response.getCredentialEntries().size();
int numActionEntries = response.getActions().size();
int numAuthEntries = response.getAuthenticationActions().size();
- // TODO immediately add remote entries
- // TODO immediately confirm how to get types from slice to get unique type count via
- // dedupe
+ int numRemoteEntry = MetricUtilities.ZERO;
+ if (response.getRemoteCredentialEntry() != null) {
+ numRemoteEntry = MetricUtilities.UNIT;
+ mCandidatePhasePerProviderMetric.addEntry(EntryEnum.REMOTE_ENTRY);
+ }
response.getCredentialEntries().forEach(c ->
mCandidatePhasePerProviderMetric.addEntry(EntryEnum.CREDENTIAL_ENTRY));
response.getActions().forEach(c ->
@@ -458,10 +461,15 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
response.getAuthenticationActions().forEach(c ->
mCandidatePhasePerProviderMetric.addEntry(EntryEnum.AUTHENTICATION_ENTRY));
mCandidatePhasePerProviderMetric.setNumEntriesTotal(numCredEntries + numAuthEntries
- + numActionEntries);
+ + numActionEntries + numRemoteEntry);
mCandidatePhasePerProviderMetric.setCredentialEntryCount(numCredEntries);
+ int numTypes = (response.getCredentialEntries().stream()
+ .map(CredentialEntry::getType).collect(
+ Collectors.toSet())).size(); // Dedupe type strings
+ mCandidatePhasePerProviderMetric.setCredentialEntryTypeCount(numTypes);
mCandidatePhasePerProviderMetric.setActionEntryCount(numActionEntries);
mCandidatePhasePerProviderMetric.setAuthenticationEntryCount(numAuthEntries);
+ mCandidatePhasePerProviderMetric.setRemoteEntryCount(numRemoteEntry);
} catch (Exception e) {
Log.w(TAG, "Unexpected error during metric logging: " + e);
}
diff --git a/services/credentials/java/com/android/server/credentials/ProviderSession.java b/services/credentials/java/com/android/server/credentials/ProviderSession.java
index faa91dce7b92..64ac9b3b4b94 100644
--- a/services/credentials/java/com/android/server/credentials/ProviderSession.java
+++ b/services/credentials/java/com/android/server/credentials/ProviderSession.java
@@ -209,10 +209,8 @@ public abstract class ProviderSession<T, R>
return mRemoteCredentialService;
}
- protected void captureCandidateFailure() {
+ protected void captureCandidateFailureInMetrics() {
mCandidatePhasePerProviderMetric.setHasException(true);
- // TODO(b/271135048) - this is a true exception, but what about the empty case?
- // Add more nuance in next iteration.
}
/** Updates the status . */
@@ -225,7 +223,6 @@ public abstract class ProviderSession<T, R>
private void updateCandidateMetric(Status status) {
try {
mCandidatePhasePerProviderMetric.setCandidateUid(mProviderSessionUid);
- // TODO immediately update the candidate phase here to have more new data
mCandidatePhasePerProviderMetric
.setQueryFinishTimeNanoseconds(System.nanoTime());
if (isTerminatingStatus(status)) {
diff --git a/services/credentials/java/com/android/server/credentials/RequestSession.java b/services/credentials/java/com/android/server/credentials/RequestSession.java
index 3ac10c9a7d22..0aa080b3c7e6 100644
--- a/services/credentials/java/com/android/server/credentials/RequestSession.java
+++ b/services/credentials/java/com/android/server/credentials/RequestSession.java
@@ -34,13 +34,12 @@ import android.service.credentials.CallingAppInfo;
import android.util.Log;
import com.android.internal.R;
-import com.android.server.credentials.metrics.ApiName;
-import com.android.server.credentials.metrics.ApiStatus;
import com.android.server.credentials.metrics.CandidateBrowsingPhaseMetric;
import com.android.server.credentials.metrics.CandidatePhaseMetric;
import com.android.server.credentials.metrics.ChosenProviderFinalPhaseMetric;
import com.android.server.credentials.metrics.EntryEnum;
import com.android.server.credentials.metrics.InitialPhaseMetric;
+import com.android.server.credentials.metrics.ProviderStatusForMetrics;
import java.util.ArrayList;
import java.util.HashMap;
@@ -185,7 +184,7 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan
EntryEnum.getMetricCodeFromString(selection.getEntryKey()));
browsingPhaseMetric.setProviderUid(providerSession.mCandidatePhasePerProviderMetric
.getCandidateUid());
- this.mCandidateBrowsingPhaseMetric.add(new CandidateBrowsingPhaseMetric());
+ this.mCandidateBrowsingPhaseMetric.add(browsingPhaseMetric);
} catch (Exception e) {
Log.w(TAG, "Unexpected error during metric logging: " + e);
}
@@ -209,16 +208,12 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan
return false;
}
- protected void logApiCall(ApiName apiName, ApiStatus apiStatus) {
- logApiCalled(apiName, apiStatus, mProviders, mCallingUid,
- mChosenProviderFinalPhaseMetric);
- }
-
protected void logApiCall(ChosenProviderFinalPhaseMetric finalPhaseMetric,
- List<CandidateBrowsingPhaseMetric> browsingPhaseMetrics) {
+ List<CandidateBrowsingPhaseMetric> browsingPhaseMetrics, int apiStatus) {
// TODO (b/270403549) - this browsing phase object is fine but also have a new emit
// For the returned types by authentication entries - i.e. a CandidatePhase During Browse
- // TODO call MetricUtilities with new setup
+ // Possibly think of adding in more atoms for other APIs as well.
+ logApiCalled(finalPhaseMetric, browsingPhaseMetrics, apiStatus, ++mSequenceCounter);
}
protected boolean isSessionCancelled() {
@@ -266,8 +261,20 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan
}
}
+ protected void collectFinalPhaseMetricStatus(boolean hasException,
+ ProviderStatusForMetrics finalSuccess) {
+ mChosenProviderFinalPhaseMetric.setHasException(hasException);
+ mChosenProviderFinalPhaseMetric.setChosenProviderStatus(
+ finalSuccess.getMetricCode());
+ }
+
/**
- * Called by RequestSession's upon chosen metric determination.
+ * Called by RequestSession's upon chosen metric determination. It's expected that most bits
+ * are transferred here. However, certain new information, such as the selected provider's final
+ * exception bit, the framework to ui and back latency, or the ui response bit are set at other
+ * locations. Other information, such browsing metrics, api_status, and the sequence id count
+ * are combined together during the final emit moment with the actual and official
+ * {@link com.android.internal.util.FrameworkStatsLog} metric generation.
*
* @param componentName the componentName to associate with a provider
*/
@@ -286,10 +293,19 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan
metric.getServiceBeganTimeNanoseconds());
mChosenProviderFinalPhaseMetric.setQueryStartTimeNanoseconds(
metric.getStartQueryTimeNanoseconds());
-
- // TODO immediately update with the entry count numbers from the candidate metrics
- // TODO immediately add the exception bit for candidates and providers
-
+ mChosenProviderFinalPhaseMetric.setQueryEndTimeNanoseconds(metric
+ .getQueryFinishTimeNanoseconds());
+
+ mChosenProviderFinalPhaseMetric.setNumEntriesTotal(metric.getNumEntriesTotal());
+ mChosenProviderFinalPhaseMetric.setCredentialEntryCount(metric
+ .getCredentialEntryCount());
+ mChosenProviderFinalPhaseMetric.setCredentialEntryTypeCount(
+ metric.getCredentialEntryTypeCount());
+ mChosenProviderFinalPhaseMetric.setActionEntryCount(metric.getActionEntryCount());
+ mChosenProviderFinalPhaseMetric.setRemoteEntryCount(metric.getRemoteEntryCount());
+ mChosenProviderFinalPhaseMetric.setAuthenticationEntryCount(
+ metric.getAuthenticationEntryCount());
+ mChosenProviderFinalPhaseMetric.setAvailableEntries(metric.getAvailableEntries());
mChosenProviderFinalPhaseMetric.setFinalFinishTimeNanoseconds(System.nanoTime());
} catch (Exception e) {
Log.w(TAG, "Unexpected error during metric logging: " + e);
diff --git a/services/credentials/java/com/android/server/credentials/metrics/ApiName.java b/services/credentials/java/com/android/server/credentials/metrics/ApiName.java
index d4b51dfcc299..abd749c38985 100644
--- a/services/credentials/java/com/android/server/credentials/metrics/ApiName.java
+++ b/services/credentials/java/com/android/server/credentials/metrics/ApiName.java
@@ -16,19 +16,19 @@
package com.android.server.credentials.metrics;
-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_IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE;
-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_INITIAL_PHASE__API_NAME__API_NAME_CLEAR_CREDENTIAL;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_CREATE_CREDENTIAL;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_GET_CREDENTIAL;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_UNKNOWN;
public enum ApiName {
- UNKNOWN(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN),
- GET_CREDENTIAL(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL),
- CREATE_CREDENTIAL(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL),
- CLEAR_CREDENTIAL(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL),
+ UNKNOWN(CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_UNKNOWN),
+ GET_CREDENTIAL(CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_GET_CREDENTIAL),
+ CREATE_CREDENTIAL(CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_CREATE_CREDENTIAL),
+ CLEAR_CREDENTIAL(CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_CLEAR_CREDENTIAL),
IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE(
- CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE
+ CREDENTIAL_MANAGER_INITIAL_PHASE__API_NAME__API_NAME_IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE
);
private final int mInnerMetricCode;
diff --git a/services/credentials/java/com/android/server/credentials/metrics/ApiStatus.java b/services/credentials/java/com/android/server/credentials/metrics/ApiStatus.java
index 22cab707387d..8fea36903a5c 100644
--- a/services/credentials/java/com/android/server/credentials/metrics/ApiStatus.java
+++ b/services/credentials/java/com/android/server/credentials/metrics/ApiStatus.java
@@ -16,18 +16,18 @@
package com.android.server.credentials.metrics;
-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_FINAL_PHASE__API_STATUS__API_STATUS_CLIENT_CANCELED;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__API_STATUS__API_STATUS_FAILURE;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__API_STATUS__API_STATUS_SUCCESS;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__API_STATUS__API_STATUS_USER_CANCELED;
public enum ApiStatus {
- SUCCESS(CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_SUCCESS),
- FAILURE(CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_FAILURE),
+ SUCCESS(CREDENTIAL_MANAGER_FINAL_PHASE__API_STATUS__API_STATUS_SUCCESS),
+ FAILURE(CREDENTIAL_MANAGER_FINAL_PHASE__API_STATUS__API_STATUS_FAILURE),
CLIENT_CANCELED(
- CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_CLIENT_CANCELED),
+ CREDENTIAL_MANAGER_FINAL_PHASE__API_STATUS__API_STATUS_CLIENT_CANCELED),
USER_CANCELED(
- CREDENTIAL_MANAGER_API_CALLED__API_STATUS__API_STATUS_USER_CANCELED);
+ CREDENTIAL_MANAGER_FINAL_PHASE__API_STATUS__API_STATUS_USER_CANCELED);
private final int mInnerMetricCode;
diff --git a/services/credentials/java/com/android/server/credentials/metrics/CandidatePhaseMetric.java b/services/credentials/java/com/android/server/credentials/metrics/CandidatePhaseMetric.java
index f00c7f46c5ae..40532946a5a0 100644
--- a/services/credentials/java/com/android/server/credentials/metrics/CandidatePhaseMetric.java
+++ b/services/credentials/java/com/android/server/credentials/metrics/CandidatePhaseMetric.java
@@ -70,7 +70,7 @@ public class CandidatePhaseMetric {
// The count of authentication entries from this provider, defaults to -1
private int mAuthenticationEntryCount = -1;
// Gathered to pass on to chosen provider when required
- private List<EntryEnum> mAvailableEntries = new ArrayList<>();
+ private final List<Integer> mAvailableEntries = new ArrayList<>();
public CandidatePhaseMetric() {
}
@@ -252,7 +252,7 @@ public class CandidatePhaseMetric {
* collector
*/
public void addEntry(EntryEnum e) {
- this.mAvailableEntries.add(e);
+ this.mAvailableEntries.add(e.getMetricCode());
}
/**
@@ -262,7 +262,7 @@ public class CandidatePhaseMetric {
* @return the full collection of entries encountered by the candidate provider associated with
* this metric
*/
- public List<EntryEnum> getAvailableEntries() {
+ public List<Integer> getAvailableEntries() {
return new ArrayList<>(this.mAvailableEntries); // no alias copy
}
}
diff --git a/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderFinalPhaseMetric.java b/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderFinalPhaseMetric.java
index 32fe204d7814..2eef19732723 100644
--- a/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderFinalPhaseMetric.java
+++ b/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderFinalPhaseMetric.java
@@ -20,6 +20,9 @@ import android.util.Log;
import com.android.server.credentials.MetricUtilities;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* The central chosen provider metric object that mimics our defined metric setup. This is used
* in the final phase of the flow and emits final status metrics.
@@ -27,14 +30,13 @@ import com.android.server.credentials.MetricUtilities;
* these data-types are available at different moments of the flow (and typically, one can feed
* into the next).
* TODO(b/270403549) - iterate on this in V3+
- * TODO(Immediately) - finalize V3 only types
*/
public class ChosenProviderFinalPhaseMetric {
// TODO(b/270403549) - applies elsewhere, likely removed or replaced w/ some hashed/count index
private static final String TAG = "ChosenFinalPhaseMetric";
// The session id associated with this API call, used to unite split emits
- private long mSessionId = -1;
+ private int mSessionId = -1;
// Reveals if the UI was returned, false by default
private boolean mUiReturned = false;
private int mChosenUid = -1;
@@ -52,6 +54,8 @@ public class ChosenProviderFinalPhaseMetric {
// The first query timestamp, which upon emit is normalized to microseconds using the reference
// start timestamp
private long mQueryStartTimeNanoseconds = -1;
+ // The timestamp at query end, which upon emit will be normalized to microseconds with reference
+ private long mQueryEndTimeNanoseconds = -1;
// The UI call timestamp, which upon emit will be normalized to microseconds using reference
private long mUiCallStartTimeNanoseconds = -1;
// The UI return timestamp, which upon emit will be normalized to microseconds using reference
@@ -63,8 +67,23 @@ public class ChosenProviderFinalPhaseMetric {
// Other General Information, such as final api status, provider status, entry info, etc...
private int mChosenProviderStatus = -1;
- // TODO add remaining properties based on the Atom ; specifically, migrate the candidate
- // Entry information, and store final status here
+ // Indicates if an exception was thrown by this provider, false by default
+ private boolean mHasException = false;
+ // Indicates the number of total entries available, defaults to -1. Not presently emitted, but
+ // left as a utility
+ private int mNumEntriesTotal = -1;
+ // The count of action entries from this provider, defaults to -1
+ private int mActionEntryCount = -1;
+ // The count of credential entries from this provider, defaults to -1
+ private int mCredentialEntryCount = -1;
+ // The *type-count* of the credential entries, defaults to -1
+ private int mCredentialEntryTypeCount = -1;
+ // The count of remote entries from this provider, defaults to -1
+ private int mRemoteEntryCount = -1;
+ // The count of authentication entries from this provider, defaults to -1
+ private int mAuthenticationEntryCount = -1;
+ // Gathered to pass on to chosen provider when required
+ private List<Integer> mAvailableEntries = new ArrayList<>();
public ChosenProviderFinalPhaseMetric() {
@@ -159,6 +178,10 @@ public class ChosenProviderFinalPhaseMetric {
mQueryStartTimeNanoseconds = queryStartTimeNanoseconds;
}
+ public void setQueryEndTimeNanoseconds(long queryEndTimeNanoseconds) {
+ mQueryEndTimeNanoseconds = queryEndTimeNanoseconds;
+ }
+
public void setUiCallStartTimeNanoseconds(long uiCallStartTimeNanoseconds) {
this.mUiCallStartTimeNanoseconds = uiCallStartTimeNanoseconds;
}
@@ -179,6 +202,10 @@ public class ChosenProviderFinalPhaseMetric {
return mQueryStartTimeNanoseconds;
}
+ public long getQueryEndTimeNanoseconds() {
+ return mQueryEndTimeNanoseconds;
+ }
+
public long getUiCallStartTimeNanoseconds() {
return mUiCallStartTimeNanoseconds;
}
@@ -222,11 +249,11 @@ public class ChosenProviderFinalPhaseMetric {
/* ----------- Session ID -------------- */
- public void setSessionId(long sessionId) {
+ public void setSessionId(int sessionId) {
mSessionId = sessionId;
}
- public long getSessionId() {
+ public int getSessionId() {
return mSessionId;
}
@@ -239,4 +266,95 @@ public class ChosenProviderFinalPhaseMetric {
public boolean isUiReturned() {
return mUiReturned;
}
+
+ /* -------------- Number of Entries ---------------- */
+
+ public void setNumEntriesTotal(int numEntriesTotal) {
+ mNumEntriesTotal = numEntriesTotal;
+ }
+
+ public int getNumEntriesTotal() {
+ return mNumEntriesTotal;
+ }
+
+ /* -------------- Count of Action Entries ---------------- */
+
+ public void setActionEntryCount(int actionEntryCount) {
+ mActionEntryCount = actionEntryCount;
+ }
+
+ public int getActionEntryCount() {
+ return mActionEntryCount;
+ }
+
+ /* -------------- Count of Credential Entries ---------------- */
+
+ public void setCredentialEntryCount(int credentialEntryCount) {
+ mCredentialEntryCount = credentialEntryCount;
+ }
+
+ public int getCredentialEntryCount() {
+ return mCredentialEntryCount;
+ }
+
+ /* -------------- Count of Credential Entry Types ---------------- */
+
+ public void setCredentialEntryTypeCount(int credentialEntryTypeCount) {
+ mCredentialEntryTypeCount = credentialEntryTypeCount;
+ }
+
+ public int getCredentialEntryTypeCount() {
+ return mCredentialEntryTypeCount;
+ }
+
+ /* -------------- Count of Remote Entries ---------------- */
+
+ public void setRemoteEntryCount(int remoteEntryCount) {
+ mRemoteEntryCount = remoteEntryCount;
+ }
+
+ public int getRemoteEntryCount() {
+ return mRemoteEntryCount;
+ }
+
+ /* -------------- Count of Authentication Entries ---------------- */
+
+ public void setAuthenticationEntryCount(int authenticationEntryCount) {
+ mAuthenticationEntryCount = authenticationEntryCount;
+ }
+
+ public int getAuthenticationEntryCount() {
+ return mAuthenticationEntryCount;
+ }
+
+ /* -------------- The Entries Gathered ---------------- */
+
+ /**
+ * Sets the collected list of entries from the candidate phase to be retrievable in the
+ * chosen phase in a semantically correct way.
+ */
+ public void setAvailableEntries(List<Integer> entries) {
+ this.mAvailableEntries = new ArrayList<>(entries); // no alias copy
+ }
+
+ /**
+ * Returns a list of the entries captured by this metric collector associated
+ * with a particular chosen provider.
+ *
+ * @return the full collection of entries encountered by the chosen provider during the
+ * candidate phase.
+ */
+ public List<Integer> getAvailableEntries() {
+ return new ArrayList<>(this.mAvailableEntries); // no alias copy
+ }
+
+ /* -------------- Has Exception ---------------- */
+
+ public void setHasException(boolean hasException) {
+ mHasException = hasException;
+ }
+
+ public boolean isHasException() {
+ return mHasException;
+ }
}
diff --git a/services/credentials/java/com/android/server/credentials/metrics/EntryEnum.java b/services/credentials/java/com/android/server/credentials/metrics/EntryEnum.java
index 73403a67a233..440ac518cc4e 100644
--- a/services/credentials/java/com/android/server/credentials/metrics/EntryEnum.java
+++ b/services/credentials/java/com/android/server/credentials/metrics/EntryEnum.java
@@ -16,11 +16,11 @@
package com.android.server.credentials.metrics;
-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_IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE;
-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_FINAL_PHASE__CLICKED_ENTRIES__ACTION_ENTRY;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__AUTHENTICATION_ENTRY;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__CREDENTIAL_ENTRY;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__REMOTE_ENTRY;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__UNKNOWN;
import static com.android.server.credentials.ProviderGetSession.ACTION_ENTRY_KEY;
import static com.android.server.credentials.ProviderGetSession.AUTHENTICATION_ACTION_ENTRY_KEY;
import static com.android.server.credentials.ProviderGetSession.CREDENTIAL_ENTRY_KEY;
@@ -32,13 +32,12 @@ import java.util.AbstractMap;
import java.util.Map;
public enum EntryEnum {
- // TODO immediately, update with built entries
- UNKNOWN(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_UNKNOWN),
- ACTION_ENTRY(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_GET_CREDENTIAL),
- CREDENTIAL_ENTRY(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CREATE_CREDENTIAL),
- REMOTE_ENTRY(CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_CLEAR_CREDENTIAL),
+ UNKNOWN(CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__UNKNOWN),
+ ACTION_ENTRY(CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__ACTION_ENTRY),
+ CREDENTIAL_ENTRY(CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__CREDENTIAL_ENTRY),
+ REMOTE_ENTRY(CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__REMOTE_ENTRY),
AUTHENTICATION_ENTRY(
- CREDENTIAL_MANAGER_API_CALLED__API_NAME__API_NAME_IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE
+ CREDENTIAL_MANAGER_FINAL_PHASE__CLICKED_ENTRIES__AUTHENTICATION_ENTRY
);
private static final String TAG = "EntryEnum";
diff --git a/services/credentials/java/com/android/server/credentials/metrics/ProviderStatusForMetrics.java b/services/credentials/java/com/android/server/credentials/metrics/ProviderStatusForMetrics.java
index 08f1afa2f438..83713ab1c842 100644
--- a/services/credentials/java/com/android/server/credentials/metrics/ProviderStatusForMetrics.java
+++ b/services/credentials/java/com/android/server/credentials/metrics/ProviderStatusForMetrics.java
@@ -16,24 +16,24 @@
package com.android.server.credentials.metrics;
-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 static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_FINAL_FAILURE;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_FINAL_SUCCESS;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_QUERY_FAILURE;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_QUERY_SUCCESS;
+import static com.android.internal.util.FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_UNKNOWN;
public enum ProviderStatusForMetrics {
UNKNOWN(
- CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_UNKNOWN),
+ CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_UNKNOWN),
FINAL_FAILURE(
- CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_FAILURE),
+ CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_FINAL_FAILURE),
QUERY_FAILURE(
- CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_FAILURE),
+ CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_QUERY_FAILURE),
FINAL_SUCCESS(
- CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_FINAL_SUCCESS),
+ CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_FINAL_SUCCESS),
QUERY_SUCCESS(
- CREDENTIAL_MANAGER_API_CALLED__CANDIDATE_PROVIDER_STATUS__PROVIDER_QUERY_SUCCESS);
+ CREDENTIAL_MANAGER_FINAL_PHASE__CHOSEN_PROVIDER_STATUS__PROVIDER_QUERY_SUCCESS);
private final int mInnerMetricCode;