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

Commit 9a18aa50 authored by Arpan Kaphle's avatar Arpan Kaphle
Browse files

Primary Info in Candidate Metric

This adds a bit to indicate which candidate provider is a candidate in
the candidate metric, within the flow where we know who the candidates
are, but not who the calling app is.

Bug: 271135048
Test: Build Test
Change-Id: I531c1be0ed67c29ebd01c6d8a52d08ec83144421
parent 8fad04bb
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ public class MetricUtilities {
            int[] candidateAuthEntryCountList = new int[providerSize];
            int[] candidateRemoteEntryCountList = new int[providerSize];
            String[] frameworkExceptionList = new String[providerSize];
            boolean[] candidatePrimaryProviderList = new boolean[providerSize];
            int index = 0;
            for (var session : providerSessions) {
                CandidatePhaseMetric metric = session.mProviderSessionMetric
@@ -339,6 +340,7 @@ public class MetricUtilities {
                candidateRemoteEntryCountList[index] = metric.getResponseCollective()
                        .getCountForEntry(EntryEnum.REMOTE_ENTRY);
                frameworkExceptionList[index] = metric.getFrameworkException();
                candidatePrimaryProviderList[index] = metric.isPrimary();
                index++;
            }
            FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_CANDIDATE_PHASE_REPORTED,
@@ -372,7 +374,7 @@ public class MetricUtilities {
                    /* api_name */
                    initialPhaseMetric.getApiName(),
                    /* primary_candidates_indicated */
                    DEFAULT_REPEATED_BOOL
                    candidatePrimaryProviderList
            );
        } catch (Exception e) {
            Slog.w(TAG, "Unexpected error during candidate provider uid metric emit: " + e);
+3 −1
Original line number Diff line number Diff line
@@ -214,9 +214,11 @@ public abstract class ProviderSession<T, R>
    protected void updateStatusAndInvokeCallback(@NonNull Status status,
            CredentialsSource source) {
        setStatus(status);
        boolean isPrimary = mProviderInfo != null && mProviderInfo.isPrimary();
        mProviderSessionMetric.collectCandidateMetricUpdate(isTerminatingStatus(status),
                isCompletionStatus(status), mProviderSessionUid,
                source == CredentialsSource.AUTH_ENTRY);
                /*isAuthEntry*/source == CredentialsSource.AUTH_ENTRY,
                /*isPrimary*/isPrimary);
        mCallbacks.onProviderStatusChanged(status, mComponentName, source);
    }
    /** Common method that transfers metrics from the init phase to candidates */
+10 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ public class CandidatePhaseMetric {
    // Stores the response credential information, as well as the response entry information which
    // by default, contains empty info
    private ResponseCollective mResponseCollective = new ResponseCollective(Map.of(), Map.of());
    // Indicates if this candidate is a primary provider, false by default
    private boolean mIsPrimary = false;

    public CandidatePhaseMetric(int sessionIdTrackTwo) {
        mSessionIdProvider = sessionIdTrackTwo;
@@ -185,4 +187,12 @@ public class CandidatePhaseMetric {
    public String getFrameworkException() {
        return mFrameworkException;
    }

    public void setPrimary(boolean primary) {
        mIsPrimary = primary;
    }

    public boolean isPrimary() {
        return mIsPrimary;
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -149,14 +149,17 @@ public class ProviderSessionMetric {
     * @param isFailureStatus indicates the candidate provider sent back a terminated response
     * @param isCompletionStatus indicates the candidate provider sent back a completion response
     * @param providerSessionUid the uid of the provider
     * @param isPrimary indicates if this candidate provider was the primary provider
     */
    public void collectCandidateMetricUpdate(boolean isFailureStatus,
            boolean isCompletionStatus, int providerSessionUid, boolean isAuthEntry) {
            boolean isCompletionStatus, int providerSessionUid, boolean isAuthEntry,
            boolean isPrimary) {
        try {
            if (isAuthEntry) {
                collectAuthEntryUpdate(isFailureStatus, isCompletionStatus, providerSessionUid);
                return;
            }
            mCandidatePhasePerProviderMetric.setPrimary(isPrimary);
            mCandidatePhasePerProviderMetric.setCandidateUid(providerSessionUid);
            mCandidatePhasePerProviderMetric
                    .setQueryFinishTimeNanoseconds(System.nanoTime());