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

Commit e013d741 authored by Arpan Kaphle's avatar Arpan Kaphle Committed by Android (Google) Code Review
Browse files

Merge "[Metrics] Utilize API Prepared Bit to Emit" into main

parents b794463f d219f378
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -383,7 +383,9 @@ public class MetricUtilities {
                    /* api_name */
                    initialPhaseMetric.getApiName(),
                    /* primary_candidates_indicated */
                    candidatePrimaryProviderList
                    candidatePrimaryProviderList,
                    /* api_prepared */
                    initialPhaseMetric.hasApiUsedPrepareFlow()
            );
        } catch (Exception e) {
            Slog.w(TAG, "Unexpected error during candidate provider uid metric emit: " + e);
@@ -442,7 +444,9 @@ public class MetricUtilities {
                    /* autofill_session_id */
                    initialPhaseMetric.getAutofillSessionId(),
                    /* autofill_request_id */
                    initialPhaseMetric.getAutofillRequestId()
                    initialPhaseMetric.getAutofillRequestId(),
                    /* api_prepared */
                    initialPhaseMetric.hasApiUsedPrepareFlow()
            );
        } catch (Exception e) {
            Slog.w(TAG, "Unexpected error during initial metric emit: " + e);
+7 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.credentials.GetCredentialRequest;
import android.credentials.IGetCredentialCallback;
import android.credentials.IPrepareGetCredentialCallback;
import android.credentials.PrepareGetCredentialResponseInternal;
import android.credentials.flags.Flags;
import android.credentials.selection.GetCredentialProviderData;
import android.credentials.selection.ProviderData;
import android.credentials.selection.RequestInfo;
@@ -60,7 +61,12 @@ public class PrepareGetRequestSession extends GetRequestSession {
        int numTypes = (request.getCredentialOptions().stream()
                .map(CredentialOption::getType).collect(
                        Collectors.toSet())).size(); // Dedupe type strings
        if (!Flags.fixMetricDuplicationEmits()) {
            mRequestSessionMetric.collectGetFlowInitialMetricInfo(request);
        } else {
            mRequestSessionMetric.collectGetFlowInitialMetricInfo(request,
                    /*isApiPrepared=*/ true);
        }
        mPrepareGetCredentialCallback = prepareGetCredentialCallback;

        Slog.i(TAG, "PrepareGetRequestSession constructed.");
+16 −0
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ public class InitialPhaseMetric {
    // The request id of autofill if the request is from autofill, defaults to -1
    private int mAutofillRequestId = -1;

    // Indicates if this API call used the prepare flow, defaults to false
    private boolean mApiUsedPrepareFlow = false;


    public InitialPhaseMetric(int sessionIdTrackOne) {
        mSessionIdCaller = sessionIdTrackOne;
@@ -173,4 +176,17 @@ public class InitialPhaseMetric {
    public int[] getUniqueRequestCounts() {
        return mRequestCounts.values().stream().mapToInt(Integer::intValue).toArray();
    }

    /* ------ API Prepared ------ */

    public void setApiUsedPrepareFlow(boolean apiUsedPrepareFlow) {
        mApiUsedPrepareFlow = apiUsedPrepareFlow;
    }

    /**
     * @return a boolean indicating if this API call utilized a prepare flow
     */
    public boolean hasApiUsedPrepareFlow() {
        return mApiUsedPrepareFlow;
    }
}
+16 −0
Original line number Diff line number Diff line
@@ -224,6 +224,22 @@ public class RequestSessionMetric {
        }
    }

    /**
     * Collects initializations for Get flow metrics.
     *
     * @param request the get credential request containing information to parse for metrics
     * @param isApiPrepared indicates this API flow utilized the 'prepare' flow
     */
    public void collectGetFlowInitialMetricInfo(GetCredentialRequest request,
            boolean isApiPrepared) {
        try {
            collectGetFlowInitialMetricInfo(request);
            mInitialPhaseMetric.setApiUsedPrepareFlow(isApiPrepared);
        } catch (Exception e) {
            Slog.i(TAG, "Unexpected error collecting get flow initial metric: " + e);
        }
    }

    /**
     * During browsing, where multiple entries can be selected, this collects the browsing phase
     * metric information. This is emitted together with the final phase, and the recursive path