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

Commit 40e2d365 authored by Arpan Kaphle's avatar Arpan Kaphle Committed by Automerger Merge Worker
Browse files

Merge "Further V2 Modifications, Prep for V3" into udc-dev am: 2be846db am: 7fac89e7

parents 97dfb49b 7fac89e7
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -43,8 +43,8 @@ public class MetricUtilities {

    private static final String TAG = "MetricUtilities";

    private static final int DEFAULT_INT_32 = -1;
    private static final int[] DEFAULT_REPEATED_INT_32 = new int[0];
    public static final int DEFAULT_INT_32 = -1;
    public static final int[] DEFAULT_REPEATED_INT_32 = new int[0];

    // Metrics constants TODO(b/269290341) migrate to enums eventually to improve
    protected static final int METRICS_PROVIDER_STATUS_FINAL_FAILURE =
@@ -79,6 +79,21 @@ public class MetricUtilities {
        return sessUid;
    }

    /**
     * Given any two timestamps in nanoseconds, this gets the difference and converts to
     * milliseconds. Assumes the difference is not larger than the maximum int size.
     *
     * @param t2 the final timestamp
     * @param t1 the initial timestamp
     * @return the timestamp difference converted to microseconds
     */
    protected static int getMetricTimestampDifferenceMicroseconds(long t2, long t1) {
        if (t2 - t1 > Integer.MAX_VALUE) {
            throw new ArithmeticException("Input timestamps are too far apart and unsupported");
        }
        return (int) ((t2 - t1) / 1000);
    }

    /**
     * The most common logging helper, handles the overall status of the API request with the
     * provider status and latencies. Other versions of this method may be more useful depending
@@ -102,7 +117,7 @@ public class MetricUtilities {
        for (var session : providerSessions) {
            CandidateProviderMetric metric = session.mCandidateProviderMetric;
            candidateUidList[index] = metric.getCandidateUid();
            candidateQueryRoundTripTimeList[index] = metric.getQueryLatencyMs();
            candidateQueryRoundTripTimeList[index] = metric.getQueryLatencyMicroseconds();
            candidateStatusList[index] = metric.getProviderQueryStatus();
            index++;
        }
@@ -116,9 +131,11 @@ public class MetricUtilities {
                /* repeated_candidate_provider_status */ candidateStatusList,
                /* chosen_provider_uid */ chosenProviderMetric.getChosenUid(),
                /* chosen_provider_round_trip_time_overall_microseconds */
                chosenProviderMetric.getEntireProviderLatencyMs(),
                /* chosen_provider_final_phase_microseconds */
                chosenProviderMetric.getFinalPhaseLatencyMs(),
                chosenProviderMetric.getEntireProviderLatencyMicroseconds(),
                /* chosen_provider_final_phase_microseconds (backwards compat only) */
                getMetricTimestampDifferenceMicroseconds(chosenProviderMetric
                                .getFinalFinishTimeNanoseconds(),
                        chosenProviderMetric.getUiCallEndTimeNanoseconds()),
                /* chosen_provider_status */ chosenProviderMetric.getChosenProviderStatus());
    }

+1 −1
Original line number Diff line number Diff line
@@ -119,8 +119,8 @@ public final class ProviderClearSession extends ProviderSession<ClearCredential
    @Override
    protected void invokeSession() {
        if (mRemoteCredentialService != null) {
            mCandidateProviderMetric.setStartQueryTimeNanoseconds(System.nanoTime());
            mRemoteCredentialService.onClearCredentialState(mProviderRequest, this);
            mCandidateProviderMetric.setStartTimeNanoseconds(System.nanoTime());
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -226,8 +226,8 @@ public final class ProviderCreateSession extends ProviderSession<
    @Override
    protected void invokeSession() {
        if (mRemoteCredentialService != null) {
            mCandidateProviderMetric.setStartQueryTimeNanoseconds(System.nanoTime());
            mRemoteCredentialService.onCreateCredential(mProviderRequest, this);
            mCandidateProviderMetric.setStartTimeNanoseconds(System.nanoTime());
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -268,8 +268,8 @@ public final class ProviderGetSession extends ProviderSession<BeginGetCredential
    @Override
    protected void invokeSession() {
        if (mRemoteCredentialService != null) {
            mCandidateProviderMetric.setStartQueryTimeNanoseconds(System.nanoTime());
            mRemoteCredentialService.onBeginGetCredential(mProviderRequest, this);
            mCandidateProviderMetric.setStartTimeNanoseconds(System.nanoTime());
        }
    }

+6 −4
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan
    //TODO improve design to allow grouped metrics per request
    protected final String mHybridService;

    @NonNull protected RequestSessionStatus mRequestSessionStatus =
    @NonNull
    protected RequestSessionStatus mRequestSessionStatus =
            RequestSessionStatus.IN_PROGRESS;

    /** The status in which a given request session is. */
@@ -213,6 +214,7 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan

    /**
     * Called by RequestSession's upon chosen metric determination.
     *
     * @param componentName the componentName to associate with a provider
     */
    protected void setChosenMetric(ComponentName componentName) {
@@ -220,8 +222,8 @@ abstract class RequestSession<T, U> implements CredentialManagerUi.CredentialMan
                .mCandidateProviderMetric;
        mChosenProviderMetric.setChosenUid(metric.getCandidateUid());
        mChosenProviderMetric.setFinalFinishTimeNanoseconds(System.nanoTime());
        mChosenProviderMetric.setQueryFinishTimeNanoseconds(
                metric.getQueryFinishTimeNanoseconds());
        mChosenProviderMetric.setStartTimeNanoseconds(metric.getStartTimeNanoseconds());
        mChosenProviderMetric.setQueryPhaseLatencyMicroseconds(
                metric.getQueryLatencyMicroseconds());
        mChosenProviderMetric.setQueryStartTimeNanoseconds(metric.getStartQueryTimeNanoseconds());
    }
}
Loading