Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e68cc2f4 authored by Arpan Kaphle's avatar Arpan Kaphle
Browse files

Setting up the emit of the aggregate phase

This finds a proper spot to emit the aggregate phase of track 1. Since
we emit final phases of both track 1 and 2 using the same information
right afterwards, the aggregate phase can go right before that. That's
because it needs to fully collect the authentication entry clicks, which
may loop quite a while after the candidate finishes.

Bug: 271135048
Test: Build and won't submit without E2E Test
Change-Id: I94e95ead6e558fcb1f6be10d617f311b65eed7c3
parent 9d77683f
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ public class MetricUtilities {
                    /* auth_provider_status */
                    authenticationMetric.getProviderStatus(),
                    /* query_returned */
                    authenticationMetric.isQueryReturned()
                    authenticationMetric.isAuthReturned()
            );
        } catch (Exception e) {
            Slog.w(TAG, "Unexpected error during candidate get metric logging: " + e);
@@ -454,9 +454,13 @@ public class MetricUtilities {
                    /*query_returned*/ candidateAggregateMetric.isQueryReturned(),
                    /*num_query_providers*/ candidateAggregateMetric.getNumProviders(),
                    /*min_query_start_timestamp_microseconds*/
                    DEFAULT_INT_32,
                    getMetricTimestampDifferenceMicroseconds(
                            candidateAggregateMetric.getMinProviderTimestampNanoseconds(),
                            candidateAggregateMetric.getServiceBeganTimeNanoseconds()),
                    /*max_query_end_timestamp_microseconds*/
                    DEFAULT_INT_32,
                    getMetricTimestampDifferenceMicroseconds(
                            candidateAggregateMetric.getMaxProviderTimestampNanoseconds(),
                            candidateAggregateMetric.getServiceBeganTimeNanoseconds()),
                    /*query_response_unique_classtypes*/
                    candidateAggregateMetric.getAggregateCollectiveQuery()
                            .getUniqueResponseStrings(),
+2 −0
Original line number Diff line number Diff line
@@ -304,6 +304,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
     * @param response the response associated with the API call that just completed
     */
    protected void respondToClientWithResponseAndFinish(V response) {
        mRequestSessionMetric.logCandidateAggregateMetrics(mProviders);
        mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(/*has_exception=*/ false,
                ProviderStatusForMetrics.FINAL_SUCCESS);
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
@@ -337,6 +338,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
     * @param errorMsg  the error message given back in the flow
     */
    protected void respondToClientWithErrorAndFinish(String errorType, String errorMsg) {
        mRequestSessionMetric.logCandidateAggregateMetrics(mProviders);
        mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
                /*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
        if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
+5 −5
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ public class BrowsedAuthenticationMetric {
    // The status of this particular provider
    private int mProviderStatus = -1;
    // Indicates if this provider returned from the authentication entry query, default false
    private boolean mQueryReturned = false;
    private boolean mAuthReturned = false;

    // TODO(b/271135048) - Match the atom and provide a clean per provider session metric
    // encapsulation.
@@ -83,12 +83,12 @@ public class BrowsedAuthenticationMetric {
        mProviderStatus = providerStatus;
    }

    public void setQueryReturned(boolean queryReturned) {
        mQueryReturned = queryReturned;
    public void setAuthReturned(boolean authReturned) {
        mAuthReturned = authReturned;
    }

    public boolean isQueryReturned() {
        return mQueryReturned;
    public boolean isAuthReturned() {
        return mAuthReturned;
    }

    public int getProviderStatus() {
+9 −9
Original line number Diff line number Diff line
@@ -54,13 +54,13 @@ public class CandidateAggregateMetric {
    // The minimum of all the providers query start time, defaults to -1
    private long mMinProviderTimestampNanoseconds = -1;
    // The maximum of all the providers query finish time, defaults to -1
    private long mMaxProviderTimestampsNanoseconds = -1;
    // The total number of failures across all the providers, defaults to -1
    private int mTotalQueryFailures = -1;
    private long mMaxProviderTimestampNanoseconds = -1;
    // The total number of failures across all the providers, defaults to 0
    private int mTotalQueryFailures = 0;
    // The map of all seen framework exceptions and their counts across all providers, default empty
    private Map<String, Integer> mExceptionCountQuery = new LinkedHashMap<>();
    // The total number of failures across all auth entries, defaults to -1
    private int mTotalAuthFailures = -1;
    // The total number of failures across all auth entries, defaults to 0
    private int mTotalAuthFailures = 0;
    // The map of all seen framework exceptions and their counts across auth entries, default empty
    private Map<String, Integer> mExceptionCountAuth = new LinkedHashMap<>();

@@ -114,7 +114,7 @@ public class CandidateAggregateMetric {
            }
        }
        mMinProviderTimestampNanoseconds = min_query_start;
        mMaxProviderTimestampsNanoseconds = max_query_end;
        mMaxProviderTimestampNanoseconds = max_query_end;
        mAggregateCollectiveQuery = new ResponseCollective(responseCountQuery, entryCountQuery);
    }

@@ -128,7 +128,7 @@ public class CandidateAggregateMetric {
            var authMetrics = sessionMetric.getBrowsedAuthenticationMetric();
            mNumAuthEntriesTapped += authMetrics.size();
            for (var authMetric : authMetrics) {
                mAuthReturned = mAuthReturned || authMetric.isQueryReturned();
                mAuthReturned = mAuthReturned || authMetric.isAuthReturned();
                ResponseCollective authCollective = authMetric.getAuthEntryCollective();
                ResponseCollective.combineTypeCountMaps(responseCountAuth,
                        authCollective.getResponseCountsMap());
@@ -170,8 +170,8 @@ public class CandidateAggregateMetric {
        return mAuthReturned;
    }

    public long getMaxProviderTimestampsNanoseconds() {
        return mMaxProviderTimestampsNanoseconds;
    public long getMaxProviderTimestampNanoseconds() {
        return mMaxProviderTimestampNanoseconds;
    }

    public long getMinProviderTimestampNanoseconds() {
+2 −2
Original line number Diff line number Diff line
@@ -126,12 +126,12 @@ public class ProviderSessionMetric {
                getUsedAuthenticationMetric();
        mostRecentAuthenticationMetric.setProviderUid(providerSessionUid);
        if (isFailureStatus) {
            mostRecentAuthenticationMetric.setQueryReturned(false);
            mostRecentAuthenticationMetric.setAuthReturned(false);
            mostRecentAuthenticationMetric.setProviderStatus(
                    ProviderStatusForMetrics.QUERY_FAILURE
                            .getMetricCode());
        } else if (isCompletionStatus) {
            mostRecentAuthenticationMetric.setQueryReturned(true);
            mostRecentAuthenticationMetric.setAuthReturned(true);
            mostRecentAuthenticationMetric.setProviderStatus(
                    ProviderStatusForMetrics.QUERY_SUCCESS
                            .getMetricCode());
Loading