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

Commit 40b3810b authored by Arpan Kaphle's avatar Arpan Kaphle
Browse files

Collecting query framework exception and origin

This collects, for the candidate phase, specifically for Track 2 (but
this code will collect for both Tracks 1 and 2, with 1 just requiring
aggregators/totals), information about the origin and if a framework
exception occured or not. The length of the exception strings are still
to be decided by the team and this CL should be another place to discuss
that. Further E2E testing may also give good clarifications.

Bug: 271135048
Test: Build and E2E Test in Progress (Won't Submit till done)
Change-Id: Ic7baac708f64c9eea5eaca8c3426fb05286d0c33
parent dc02288f
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -178,9 +178,11 @@ public class MetricUtilities {
     *
     * @param providers      a map with known providers and their held metric objects
     * @param emitSequenceId an emitted sequence id for the current session
     * @param initialPhaseMetric contains initial phase data to avoid repetition for candidate
     *                           phase, track 2, logging
     */
    public static void logApiCalledCandidatePhase(Map<String, ProviderSession> providers,
            int emitSequenceId) {
            int emitSequenceId, InitialPhaseMetric initialPhaseMetric) {
        try {
            if (!LOG_FLAG) {
                return;
@@ -200,6 +202,7 @@ public class MetricUtilities {
            int[] candidateActionEntryCountList = new int[providerSize];
            int[] candidateAuthEntryCountList = new int[providerSize];
            int[] candidateRemoteEntryCountList = new int[providerSize];
            String[] frameworkExceptionList = new String[providerSize];
            int index = 0;
            for (var session : providerSessions) {
                CandidatePhaseMetric metric = session.mProviderSessionMetric
@@ -225,7 +228,7 @@ public class MetricUtilities {
                candidateActionEntryCountList[index] = metric.getActionEntryCount();
                candidateAuthEntryCountList[index] = metric.getAuthenticationEntryCount();
                candidateRemoteEntryCountList[index] = metric.getRemoteEntryCount();
                // frameworkExceptionList[index] = metric.getFrameworkException();
                frameworkExceptionList[index] = metric.getFrameworkException();
                index++;
            }
            FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_CANDIDATE_PHASE_REPORTED,
@@ -246,11 +249,16 @@ public class MetricUtilities {
                    /* candidate_provider_credential_entry_type_count */
                    candidateCredentialTypeCountList,
                    /* candidate_provider_remote_entry_count */ candidateRemoteEntryCountList,
                    /* candidate_provider_authentication_entry_count */ candidateAuthEntryCountList,
                    DEFAULT_REPEATED_STR,
                    false,
                    DEFAULT_REPEATED_STR,
                    DEFAULT_REPEATED_INT_32
                    /* candidate_provider_authentication_entry_count */
                    candidateAuthEntryCountList,
                    /* framework_exception_per_provider */
                    frameworkExceptionList,
                    /* origin_specified originSpecified */
                    initialPhaseMetric.isOriginSpecified(),
                    /* request_unique_classtypes */
                    initialPhaseMetric.getUniqueRequestStrings(),
                    /* per_classtype_counts */
                    initialPhaseMetric.getUniqueRequestCounts()
            );
        } catch (Exception e) {
            Log.w(TAG, "Unexpected error during metric logging: " + e);
+2 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ public final class ProviderClearSession extends ProviderSession<ClearCredentialS
    public void onProviderResponseFailure(int errorCode, Exception exception) {
        if (exception instanceof ClearCredentialStateException) {
            mProviderException = (ClearCredentialStateException) exception;
            // TODO(b/271135048) : Decide on exception type length
            mProviderSessionMetric.collectCandidateFrameworkException(mProviderException.getType());
        }
        mProviderSessionMetric.collectCandidateExceptionStatus(/*hasException=*/true);
        updateStatusAndInvokeCallback(toStatus(errorCode),
+2 −0
Original line number Diff line number Diff line
@@ -155,6 +155,8 @@ public final class ProviderCreateSession extends ProviderSession<
        if (exception instanceof CreateCredentialException) {
            // Store query phase exception for aggregation with final response
            mProviderException = (CreateCredentialException) exception;
            // TODO(b/271135048) : Decide on exception type length
            mProviderSessionMetric.collectCandidateFrameworkException(mProviderException.getType());
        }
        mProviderSessionMetric.collectCandidateExceptionStatus(/*hasException=*/true);
        updateStatusAndInvokeCallback(toStatus(errorCode),
+2 −0
Original line number Diff line number Diff line
@@ -217,6 +217,8 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
    public void onProviderResponseFailure(int errorCode, Exception exception) {
        if (exception instanceof GetCredentialException) {
            mProviderException = (GetCredentialException) exception;
            // TODO(b/271135048) : Decide on exception type length
            mProviderSessionMetric.collectCandidateFrameworkException(mProviderException.getType());
        }
        mProviderSessionMetric.collectCandidateExceptionStatus(/*hasException=*/true);
        updateStatusAndInvokeCallback(toStatus(errorCode),
+2 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ CREDENTIAL_MANAGER_INITIAL_PHASE_REPORTED__API_NAME__API_NAME_IS_ENABLED_CREDENT
    );

    ApiName(int innerMetricCode) {
        this.mInnerMetricCode = innerMetricCode;
        mInnerMetricCode = innerMetricCode;
    }

    /**
@@ -66,7 +66,7 @@ CREDENTIAL_MANAGER_INITIAL_PHASE_REPORTED__API_NAME__API_NAME_IS_ENABLED_CREDENT
     * @return a code corresponding to the west world metric name
     */
    public int getMetricCode() {
        return this.mInnerMetricCode;
        return mInnerMetricCode;
    }

    /**
Loading