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

Commit c7ac88d4 authored by Omer Ozer's avatar Omer Ozer Committed by Android (Google) Code Review
Browse files

Merge "Add metrics coverage to Cred Reg flow." into udc-dev

parents 0f59388c 7785cb0a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ public class ProviderRegistryGetSession extends ProviderSession<CredentialOption

    @Override
    protected void invokeSession() {
        startCandidateMetrics();
        mProviderResponse = mCredentialDescriptionRegistry
                .getFilteredResultForProvider(mCredentialProviderPackageName,
                        mElementKeys);
@@ -266,7 +267,7 @@ public class ProviderRegistryGetSession extends ProviderSession<CredentialOption
                .collect(Collectors.toList());
        updateStatusAndInvokeCallback(Status.CREDENTIALS_RECEIVED,
                /*source=*/ CredentialsSource.REGISTRY);
        // TODO(b/273353677) : metric should be emitted similarly to sibling classes
        mProviderSessionMetric.collectCandidateEntryMetrics(mCredentialEntries);
    }

    @Nullable
+29 −0
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@ import static com.android.server.credentials.MetricUtilities.generateMetricKey;
import android.annotation.NonNull;
import android.service.credentials.BeginCreateCredentialResponse;
import android.service.credentials.BeginGetCredentialResponse;
import android.service.credentials.CredentialEntry;
import android.util.Slog;

import com.android.server.credentials.MetricUtilities;
import com.android.server.credentials.metrics.shared.ResponseCollective;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
@@ -149,6 +151,33 @@ public class ProviderSessionMetric {
        }
    }

    /**
     * Once entries are received from the registry, this helps collect their info for metric
     * purposes.
     *
     * @param entries contains matching entries from the Credential Registry.
     */
    public void collectCandidateEntryMetrics(List<CredentialEntry> entries) {
        int numCredEntries = entries.size();
        int numRemoteEntry = MetricUtilities.ZERO;
        int numActionEntries = MetricUtilities.ZERO;
        int numAuthEntries = MetricUtilities.ZERO;
        Map<EntryEnum, Integer> entryCounts = new LinkedHashMap<>();
        Map<String, Integer> responseCounts = new LinkedHashMap<>();
        entryCounts.put(EntryEnum.REMOTE_ENTRY, numRemoteEntry);
        entryCounts.put(EntryEnum.CREDENTIAL_ENTRY, numCredEntries);
        entryCounts.put(EntryEnum.ACTION_ENTRY, numActionEntries);
        entryCounts.put(EntryEnum.AUTHENTICATION_ENTRY, numAuthEntries);

        entries.forEach(entry -> {
            String entryKey = generateMetricKey(entry.getType(), DELTA_CUT);
            responseCounts.put(entryKey, responseCounts.getOrDefault(entryKey, 0) + 1);
        });

        ResponseCollective responseCollective = new ResponseCollective(responseCounts, entryCounts);
        mCandidatePhasePerProviderMetric.setResponseCollective(responseCollective);
    }

    private void beginCreateCredentialResponseCollectionCandidateEntryMetrics(
            BeginCreateCredentialResponse response) {
        Map<EntryEnum, Integer> entryCounts = new LinkedHashMap<>();