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

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

Merge "Adding Final Phase {Deduped:Count} Objects" into udc-dev

parents 1030b6c6 79492ead
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import android.provider.Settings;
import android.service.credentials.CallingAppInfo;
import android.service.credentials.CredentialProviderInfoFactory;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
@@ -472,7 +471,7 @@ public final class CredentialManagerService
                            GetCredentialException.TYPE_NO_CREDENTIAL,
                            "No credentials available on this device.");
                } catch (RemoteException e) {
                    Log.i(
                    Slog.i(
                            TAG,
                            "Issue invoking onError on IGetCredentialCallback "
                                    + "callback: "
@@ -528,7 +527,7 @@ public final class CredentialManagerService
                                    false, null,
                                    false, false, null));
                } catch (RemoteException e) {
                    Log.i(
                    Slog.i(
                            TAG,
                            "Issue invoking onError on IGetCredentialCallback "
                                    + "callback: "
@@ -673,7 +672,7 @@ public final class CredentialManagerService
                MetricUtilities.logApiCalledInitialPhase(initMetric,
                        session.mRequestSessionMetric.returnIncrementSequence());
            } catch (Exception e) {
                Log.w(TAG, "Unexpected error during metric logging: ", e);
                Slog.w(TAG, "Unexpected error during metric logging: ", e);
            }
        }

@@ -706,7 +705,7 @@ public final class CredentialManagerService
                    Settings.Secure.CREDENTIAL_SERVICE,
                    storedValue,
                    userId)) {
                Log.e(TAG, "Failed to store setting containing enabled providers");
                Slog.e(TAG, "Failed to store setting containing enabled providers");
                try {
                    callback.onError(
                            "failed_setting_store",
@@ -962,7 +961,7 @@ public final class CredentialManagerService
        @Override
        @GuardedBy("mLock")
        public void onFinishRequestSession(@UserIdInt int userId, IBinder token) {
            Log.i(TAG, "In onFinishRequestSession");
            Slog.i(TAG, "In onFinishRequestSession");
            if (mRequestSessions.get(userId) != null) {
                mRequestSessions.get(userId).remove(token);
            }
+34 −27
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.server.credentials;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import android.util.Slog;

import com.android.internal.util.FrameworkStatsLog;
import com.android.server.credentials.metrics.ApiName;
@@ -27,6 +27,7 @@ import com.android.server.credentials.metrics.ApiStatus;
import com.android.server.credentials.metrics.CandidateBrowsingPhaseMetric;
import com.android.server.credentials.metrics.CandidatePhaseMetric;
import com.android.server.credentials.metrics.ChosenProviderFinalPhaseMetric;
import com.android.server.credentials.metrics.EntryEnum;
import com.android.server.credentials.metrics.InitialPhaseMetric;

import java.util.List;
@@ -69,7 +70,7 @@ public class MetricUtilities {
                    componentName.getPackageName(),
                    PackageManager.ApplicationInfoFlags.of(0)).uid;
        } catch (Throwable t) {
            Log.i(TAG, "Couldn't find required uid");
            Slog.i(TAG, "Couldn't find required uid");
        }
        return sessUid;
    }
@@ -147,28 +148,28 @@ public class MetricUtilities {
                            .getFinalFinishTimeNanoseconds()),
                    /* chosen_provider_status */ finalPhaseMetric.getChosenProviderStatus(),
                    /* chosen_provider_has_exception */ finalPhaseMetric.isHasException(),
                    /* chosen_provider_available_entries */ finalPhaseMetric.getAvailableEntries()
                            .stream().mapToInt(i -> i).toArray(),
                    /* chosen_provider_action_entry_count */ finalPhaseMetric.getActionEntryCount(),
                    /* chosen_provider_credential_entry_count */
                    finalPhaseMetric.getCredentialEntryCount(),
                    /* chosen_provider_credential_entry_type_count */
                    finalPhaseMetric.getCredentialEntryTypeCount(),
                    /* chosen_provider_remote_entry_count */
                    finalPhaseMetric.getRemoteEntryCount(),
                    /* chosen_provider_authentication_entry_count */
                    finalPhaseMetric.getAuthenticationEntryCount(),
                    /* chosen_provider_available_entries (deprecated) */ DEFAULT_REPEATED_INT_32,
                    /* chosen_provider_action_entry_count (deprecated) */ DEFAULT_INT_32,
                    /* chosen_provider_credential_entry_count (deprecated)*/DEFAULT_INT_32,
                    /* chosen_provider_credential_entry_type_count (deprecated) */ DEFAULT_INT_32,
                    /* chosen_provider_remote_entry_count (deprecated) */ DEFAULT_INT_32,
                    /* chosen_provider_authentication_entry_count (deprecated) */ DEFAULT_INT_32,
                    /* clicked_entries */ browsedClickedEntries,
                    /* provider_of_clicked_entry */ browsedProviderUid,
                    /* api_status */ apiStatus,
                    DEFAULT_REPEATED_INT_32,
                    DEFAULT_REPEATED_INT_32,
                    DEFAULT_REPEATED_STR,
                    DEFAULT_REPEATED_INT_32,
                    /* unique_entries */
                    finalPhaseMetric.getResponseCollective().getUniqueEntries(),
                    /* per_entry_counts */
                    finalPhaseMetric.getResponseCollective().getUniqueEntryCounts(),
                    /* unique_response_classtypes */
                    finalPhaseMetric.getResponseCollective().getUniqueResponseStrings(),
                    /* per_classtype_counts */
                    finalPhaseMetric.getResponseCollective().getUniqueResponseCounts(),
                    /* framework_exception_unique_classtypes */
                    DEFAULT_STRING
            );
        } catch (Exception e) {
            Log.w(TAG, "Unexpected error during metric logging: " + e);
            Slog.w(TAG, "Unexpected error during metric logging: " + e);
        }
    }

@@ -223,12 +224,18 @@ public class MetricUtilities {
                                metric.getQueryFinishTimeNanoseconds());
                candidateStatusList[index] = metric.getProviderQueryStatus();
                candidateHasExceptionList[index] = metric.isHasException();
                candidateTotalEntryCountList[index] = metric.getNumEntriesTotal();
                candidateCredentialEntryCountList[index] = metric.getCredentialEntryCount();
                candidateCredentialTypeCountList[index] = metric.getCredentialEntryTypeCount();
                candidateActionEntryCountList[index] = metric.getActionEntryCount();
                candidateAuthEntryCountList[index] = metric.getAuthenticationEntryCount();
                candidateRemoteEntryCountList[index] = metric.getRemoteEntryCount();
                candidateTotalEntryCountList[index] = metric.getResponseCollective()
                        .getNumEntriesTotal();
                candidateCredentialEntryCountList[index] = metric.getResponseCollective()
                        .getCountForEntry(EntryEnum.CREDENTIAL_ENTRY);
                candidateCredentialTypeCountList[index] = metric.getResponseCollective()
                        .getUniqueResponseStrings().length;
                candidateActionEntryCountList[index] = metric.getResponseCollective()
                        .getCountForEntry(EntryEnum.ACTION_ENTRY);
                candidateAuthEntryCountList[index] = metric.getResponseCollective()
                        .getCountForEntry(EntryEnum.AUTHENTICATION_ENTRY);
                candidateRemoteEntryCountList[index] = metric.getResponseCollective()
                        .getCountForEntry(EntryEnum.REMOTE_ENTRY);
                frameworkExceptionList[index] = metric.getFrameworkException();
                index++;
            }
@@ -262,7 +269,7 @@ public class MetricUtilities {
                    initialPhaseMetric.getUniqueRequestCounts()
            );
        } catch (Exception e) {
            Log.w(TAG, "Unexpected error during metric logging: " + e);
            Slog.w(TAG, "Unexpected error during metric logging: " + e);
        }
    }

@@ -298,7 +305,7 @@ public class MetricUtilities {
                    DEFAULT_INT_32,
                    /* chosen_provider_status */ DEFAULT_INT_32);
        } catch (Exception e) {
            Log.w(TAG, "Unexpected error during metric logging: " + e);
            Slog.w(TAG, "Unexpected error during metric logging: " + e);
        }
    }

@@ -331,7 +338,7 @@ public class MetricUtilities {
                    initialPhaseMetric.isOriginSpecified()
            );
        } catch (Exception e) {
            Log.w(TAG, "Unexpected error during metric logging: " + e);
            Slog.w(TAG, "Unexpected error during metric logging: " + e);
        }
    }
}
+11 −99
Original line number Diff line number Diff line
@@ -16,14 +16,12 @@

package com.android.server.credentials.metrics;

import android.util.IntArray;
import android.util.Log;

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

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Map;

/**
 * The central candidate provider metric object that mimics our defined metric setup.
@@ -55,23 +53,12 @@ public class CandidatePhaseMetric {
    private int mProviderQueryStatus = -1;
    // Indicates if an exception was thrown by this provider, false by default
    private boolean mHasException = false;
    // Indicates the number of total entries available, defaults to -1
    private int mNumEntriesTotal = -1;
    // The count of action entries from this provider, defaults to -1
    private int mActionEntryCount = -1;
    // The count of credential entries from this provider, defaults to -1
    private int mCredentialEntryCount = -1;
    // The *type-count* of the credential entries, defaults to -1
    private int mCredentialEntryTypeCount = -1;
    // The count of remote entries from this provider, defaults to -1
    private int mRemoteEntryCount = -1;
    // The count of authentication entries from this provider, defaults to -1
    private int mAuthenticationEntryCount = -1;
    // Gathered to pass on to chosen provider when required
    private final IntArray mAvailableEntries = new IntArray();
    // The *framework only* exception held by this provider, empty string by default
    private String mFrameworkException = "";

    // 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());

    public CandidatePhaseMetric() {
    }

@@ -182,88 +169,13 @@ public class CandidatePhaseMetric {
        return mHasException;
    }

    /* -------------- Number of Entries ---------------- */

    public void setNumEntriesTotal(int numEntriesTotal) {
        mNumEntriesTotal = numEntriesTotal;
    }

    public int getNumEntriesTotal() {
        return mNumEntriesTotal;
    }

    /* -------------- Count of Action Entries ---------------- */

    public void setActionEntryCount(int actionEntryCount) {
        mActionEntryCount = actionEntryCount;
    }

    public int getActionEntryCount() {
        return mActionEntryCount;
    }

    /* -------------- Count of Credential Entries ---------------- */

    public void setCredentialEntryCount(int credentialEntryCount) {
        mCredentialEntryCount = credentialEntryCount;
    }

    public int getCredentialEntryCount() {
        return mCredentialEntryCount;
    }

    /* -------------- Count of Credential Entry Types ---------------- */

    public void setCredentialEntryTypeCount(int credentialEntryTypeCount) {
        mCredentialEntryTypeCount = credentialEntryTypeCount;
    }

    public int getCredentialEntryTypeCount() {
        return mCredentialEntryTypeCount;
    /* -------------- The Entries and Responses Gathered ---------------- */
    public void setResponseCollective(ResponseCollective responseCollective) {
        mResponseCollective = responseCollective;
    }

    /* -------------- Count of Remote Entries ---------------- */

    public void setRemoteEntryCount(int remoteEntryCount) {
        mRemoteEntryCount = remoteEntryCount;
    }

    public int getRemoteEntryCount() {
        return mRemoteEntryCount;
    }

    /* -------------- Count of Authentication Entries ---------------- */

    public void setAuthenticationEntryCount(int authenticationEntryCount) {
        mAuthenticationEntryCount = authenticationEntryCount;
    }

    public int getAuthenticationEntryCount() {
        return mAuthenticationEntryCount;
    }

    /* -------------- The Entries Gathered ---------------- */

    /**
     * Allows adding an entry record to this metric collector, which can then be propagated to
     * the final phase to retain information on the data available to the candidate.
     *
     * @param e the entry enum collected by the candidate provider associated with this metric
     *          collector
     */
    public void addEntry(EntryEnum e) {
        mAvailableEntries.add(e.getMetricCode());
    }

    /**
     * Returns a safely copied list of the entries captured by this metric collector associated
     * with a particular candidate provider.
     *
     * @return the full collection of entries encountered by the candidate provider associated with
     * this metric
     */
    public List<Integer> getAvailableEntries() {
        return Arrays.stream(mAvailableEntries.toArray()).boxed().collect(Collectors.toList());
    public ResponseCollective getResponseCollective() {
        return mResponseCollective;
    }

    /* ------ Framework Exception for this Candidate ------ */
+16 −98
Original line number Diff line number Diff line
@@ -19,9 +19,9 @@ package com.android.server.credentials.metrics;
import android.util.Log;

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

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * The central chosen provider metric object that mimics our defined metric setup. This is used
@@ -66,21 +66,10 @@ public class ChosenProviderFinalPhaseMetric {
    private int mChosenProviderStatus = -1;
    // Indicates if an exception was thrown by this provider, false by default
    private boolean mHasException = false;
    // Indicates the number of total entries available, defaults to -1. Not presently emitted, but
    // left as a utility
    private int mNumEntriesTotal = -1;
    // The count of action entries from this provider, defaults to -1
    private int mActionEntryCount = -1;
    // The count of credential entries from this provider, defaults to -1
    private int mCredentialEntryCount = -1;
    // The *type-count* of the credential entries, defaults to -1
    private int mCredentialEntryTypeCount = -1;
    // The count of remote entries from this provider, defaults to -1
    private int mRemoteEntryCount = -1;
    // The count of authentication entries from this provider, defaults to -1
    private int mAuthenticationEntryCount = -1;
    // Gathered to pass on to chosen provider when required
    private List<Integer> mAvailableEntries = new ArrayList<>();

    // 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());


    public ChosenProviderFinalPhaseMetric() {
@@ -264,87 +253,6 @@ public class ChosenProviderFinalPhaseMetric {
        return mUiReturned;
    }

    /* -------------- Number of Entries ---------------- */

    public void setNumEntriesTotal(int numEntriesTotal) {
        mNumEntriesTotal = numEntriesTotal;
    }

    public int getNumEntriesTotal() {
        return mNumEntriesTotal;
    }

    /* -------------- Count of Action Entries ---------------- */

    public void setActionEntryCount(int actionEntryCount) {
        mActionEntryCount = actionEntryCount;
    }

    public int getActionEntryCount() {
        return mActionEntryCount;
    }

    /* -------------- Count of Credential Entries ---------------- */

    public void setCredentialEntryCount(int credentialEntryCount) {
        mCredentialEntryCount = credentialEntryCount;
    }

    public int getCredentialEntryCount() {
        return mCredentialEntryCount;
    }

    /* -------------- Count of Credential Entry Types ---------------- */

    public void setCredentialEntryTypeCount(int credentialEntryTypeCount) {
        mCredentialEntryTypeCount = credentialEntryTypeCount;
    }

    public int getCredentialEntryTypeCount() {
        return mCredentialEntryTypeCount;
    }

    /* -------------- Count of Remote Entries ---------------- */

    public void setRemoteEntryCount(int remoteEntryCount) {
        mRemoteEntryCount = remoteEntryCount;
    }

    public int getRemoteEntryCount() {
        return mRemoteEntryCount;
    }

    /* -------------- Count of Authentication Entries ---------------- */

    public void setAuthenticationEntryCount(int authenticationEntryCount) {
        mAuthenticationEntryCount = authenticationEntryCount;
    }

    public int getAuthenticationEntryCount() {
        return mAuthenticationEntryCount;
    }

    /* -------------- The Entries Gathered ---------------- */

    /**
     * Sets the collected list of entries from the candidate phase to be retrievable in the
     * chosen phase in a semantically correct way.
     */
    public void setAvailableEntries(List<Integer> entries) {
        mAvailableEntries = new ArrayList<>(entries); // no alias copy
    }

    /**
     * Returns a list of the entries captured by this metric collector associated
     * with a particular chosen provider.
     *
     * @return the full collection of entries encountered by the chosen provider during the
     * candidate phase.
     */
    public List<Integer> getAvailableEntries() {
        return new ArrayList<>(mAvailableEntries); // no alias copy
    }

    /* -------------- Has Exception ---------------- */

    public void setHasException(boolean hasException) {
@@ -354,4 +262,14 @@ public class ChosenProviderFinalPhaseMetric {
    public boolean isHasException() {
        return mHasException;
    }

    /* -------------- The Entries and Responses Gathered ---------------- */

    public void setResponseCollective(ResponseCollective responseCollective) {
        mResponseCollective = responseCollective;
    }

    public ResponseCollective getResponseCollective() {
        return mResponseCollective;
    }
}
+3 −3
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class InitialPhaseMetric {
    // Indicates if the origin was specified when making this API request
    private boolean mOriginSpecified = false;

    // Stores the deduped request information, particularly {"req":5}.
    // Stores the deduped request information, particularly {"req":5}
    private Map<String, Integer> mRequestCounts = new LinkedHashMap<>();


@@ -138,7 +138,7 @@ public class InitialPhaseMetric {
    }

    /**
     * Reruns the unique, deduped, request classtypes for logging.
     * Returns the unique, deduped, request classtypes for logging.
     * @return a string array for deduped classtypes
     */
    public String[] getUniqueRequestStrings() {
@@ -151,7 +151,7 @@ public class InitialPhaseMetric {
    }

    /**
     * Reruns the unique, deduped, request classtype counts for logging.
     * Returns the unique, deduped, request classtype counts for logging.
     * @return a string array for deduped classtype counts
     */
    public int[] getUniqueRequestCounts() {
Loading