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

Commit f3b471ad authored by Arpan Kaphle's avatar Arpan Kaphle
Browse files

Adds to Aggregate Candidate Metric query and count

Also, designs setup for authentication entry collection, and creates a
new abstraction object for said collection. Given that authentication
entries can occur in loops, this starts to think about how we might
aggregate authentication entries.

On top of this, this re-designs the session id in the collection system
so that it is immutable once created.

Bug: 271135048
Test: Build + Won't submit w/o E2E test

Change-Id: Ib32036430f5cf0249a651a2867758de08f19e63b
parent d5b87490
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -697,8 +697,6 @@ public final class CredentialManagerService
                initMetric.setCredentialServiceBeginQueryTimeNanoseconds(System.nanoTime());
                MetricUtilities.logApiCalledInitialPhase(initMetric,
                        session.mRequestSessionMetric.returnIncrementSequence());
                session.mRequestSessionMetric.getCandidateAggregateMetric().setSessionId(
                        initMetric.getSessionId());
            } catch (Exception e) {
                Slog.i(TAG, "Unexpected error during metric logging: ", e);
            }
+5 −6
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ public class MetricUtilities {
                index++;
            }
            FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE_REPORTED,
                    /* session_id */ finalPhaseMetric.getSessionId(),
                    /* session_id */ finalPhaseMetric.getSessionIdTrackTwo(),
                    /* sequence_num */ emitSequenceId,
                    /* ui_returned_final_start */ finalPhaseMetric.isUiReturned(),
                    /* chosen_provider_uid */ finalPhaseMetric.getChosenUid(),
@@ -181,8 +181,7 @@ public class MetricUtilities {
                    finalPhaseMetric.getResponseCollective().getUniqueResponseCounts(),
                    /* framework_exception_unique_classtype */
                    finalPhaseMetric.getFrameworkException(),
                    /* primary_indicated */
                    false
                    /* primary_indicated */ false
            );
        } catch (Exception e) {
            Slog.w(TAG, "Unexpected error during final provider uid emit: " + e);
@@ -226,7 +225,7 @@ public class MetricUtilities {
                CandidatePhaseMetric metric = session.mProviderSessionMetric
                        .getCandidatePhasePerProviderMetric();
                if (sessionId == -1) {
                    sessionId = metric.getSessionId();
                    sessionId = metric.getSessionIdTrackTwo();
                }
                if (!queryReturned) {
                    queryReturned = metric.isQueryReturned();
@@ -363,8 +362,8 @@ public class MetricUtilities {
                FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_TOTAL_REPORTED,
                        /*session_id*/ candidateAggregateMetric.getSessionId(),
                        /*sequence_num*/ sequenceNum,
                        /*query_returned*/ true,
                        /*num_query_providers*/ DEFAULT_INT_32,
                        /*query_returned*/ candidateAggregateMetric.isQueryReturned(),
                        /*num_providers*/ candidateAggregateMetric.getNumProviders(),
                        /*min_query_start_timestamp_microseconds*/
                        DEFAULT_INT_32,
                        /*max_query_end_timestamp_microseconds*/
+2 −2
Original line number Diff line number Diff line
@@ -193,11 +193,11 @@ public final class ProviderCreateSession extends ProviderSession<
        mProviderResponseDataHandler.addResponseContent(response.getCreateEntries(),
                response.getRemoteCreateEntry());
        if (mProviderResponseDataHandler.isEmptyResponse(response)) {
            mProviderSessionMetric.collectCandidateEntryMetrics(response);
            mProviderSessionMetric.collectCandidateEntryMetrics(response, /*isAuthEntry*/false);
            updateStatusAndInvokeCallback(Status.EMPTY_RESPONSE,
                    /*source=*/ CredentialsSource.REMOTE_PROVIDER);
        } else {
            mProviderSessionMetric.collectCandidateEntryMetrics(response);
            mProviderSessionMetric.collectCandidateEntryMetrics(response, /*isAuthEntry*/false);
            updateStatusAndInvokeCallback(Status.SAVE_ENTRIES_RECEIVED,
                    /*source=*/ CredentialsSource.REMOTE_PROVIDER);
        }
+3 −2
Original line number Diff line number Diff line
@@ -432,6 +432,7 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
        BeginGetCredentialResponse response = PendingIntentResultHandler
                .extractResponseContent(providerPendingIntentResponse
                        .getResultData());
        mProviderSessionMetric.collectCandidateEntryMetrics(response, /*isAuthEntry*/true);
        if (response != null && !mProviderResponseDataHandler.isEmptyResponse(response)) {
            addToInitialRemoteResponse(response, /*isInitialResponse=*/ false);
            // Additional content received is in the form of new response content.
@@ -469,12 +470,12 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
        addToInitialRemoteResponse(response, /*isInitialResponse=*/true);
        // Log the data.
        if (mProviderResponseDataHandler.isEmptyResponse(response)) {
            mProviderSessionMetric.collectCandidateEntryMetrics(response);
            mProviderSessionMetric.collectCandidateEntryMetrics(response, /*isAuthEntry*/false);
            updateStatusAndInvokeCallback(Status.EMPTY_RESPONSE,
                    /*source=*/ CredentialsSource.REMOTE_PROVIDER);
            return;
        }
        mProviderSessionMetric.collectCandidateEntryMetrics(response);
        mProviderSessionMetric.collectCandidateEntryMetrics(response, /*isAuthEntry*/false);
        updateStatusAndInvokeCallback(Status.CREDENTIALS_RECEIVED,
                /*source=*/ CredentialsSource.REMOTE_PROVIDER);
    }
+12 −2
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public abstract class ProviderSession<T, R>
    @NonNull
    protected Boolean mProviderResponseSet = false;
    @NonNull
    protected final ProviderSessionMetric mProviderSessionMetric = new ProviderSessionMetric();
    protected final ProviderSessionMetric mProviderSessionMetric;
    @NonNull
    private int mProviderSessionUid;

@@ -113,6 +113,13 @@ public abstract class ProviderSession<T, R>
        return status == Status.COMPLETE || status == Status.EMPTY_RESPONSE;
    }

    /**
     * Gives access to the objects metric collectors.
     */
    public ProviderSessionMetric getProviderSessionMetric() {
        return this.mProviderSessionMetric;
    }

    /**
     * Interface to be implemented by any class that wishes to get a callback when a particular
     * provider session's status changes. Typically, implemented by the {@link RequestSession}
@@ -147,6 +154,8 @@ public abstract class ProviderSession<T, R>
        mComponentName = componentName;
        mRemoteCredentialService = remoteCredentialService;
        mProviderSessionUid = MetricUtilities.getPackageUid(mContext, mComponentName);
        mProviderSessionMetric = new ProviderSessionMetric(
                ((RequestSession) mCallbacks).mRequestSessionMetric.getSessionIdTrackTwo());
    }

    /** Provider status at various states of the provider session. */
@@ -206,7 +215,8 @@ public abstract class ProviderSession<T, R>
            CredentialsSource source) {
        setStatus(status);
        mProviderSessionMetric.collectCandidateMetricUpdate(isTerminatingStatus(status),
                isCompletionStatus(status), mProviderSessionUid);
                isCompletionStatus(status), mProviderSessionUid,
                source == CredentialsSource.AUTH_ENTRY);
        mCallbacks.onProviderStatusChanged(status, mComponentName, source);
    }
    /** Common method that transfers metrics from the init phase to candidates */
Loading