Sets up Final Phase Emit for Calling App Track
When we know the calling app, this sets up the final phase emit, where we do not know the providers. The session ID is properly transferred and different. We call this the 'track one' emit for the final phase. Bug: 271135048 Test: Build and won't submit without E2E test. Change-Id: If8cf0831f49eec7171c549fab1db471825fe6282
This commit is contained in:
@@ -30,6 +30,8 @@ import android.os.RemoteException;
|
||||
import android.service.credentials.CallingAppInfo;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.credentials.metrics.ProviderSessionMetric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -93,9 +95,12 @@ public final class ClearRequestSession extends RequestSession<ClearCredentialSta
|
||||
public void onFinalResponseReceived(
|
||||
ComponentName componentName,
|
||||
Void response) {
|
||||
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(
|
||||
mProviders.get(componentName.flattenToString()).mProviderSessionMetric
|
||||
.getCandidatePhasePerProviderMetric());
|
||||
if (mProviders.get(componentName.flattenToString()) != null) {
|
||||
ProviderSessionMetric providerSessionMetric =
|
||||
mProviders.get(componentName.flattenToString()).mProviderSessionMetric;
|
||||
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(providerSessionMetric
|
||||
.getCandidatePhasePerProviderMetric());
|
||||
}
|
||||
respondToClientWithResponseAndFinish(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.service.credentials.CallingAppInfo;
|
||||
import android.service.credentials.PermissionUtils;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.credentials.metrics.ProviderSessionMetric;
|
||||
import com.android.server.credentials.metrics.ProviderStatusForMetrics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -131,9 +132,12 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
|
||||
@Nullable CreateCredentialResponse response) {
|
||||
Slog.i(TAG, "Final credential received from: " + componentName.flattenToString());
|
||||
mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
|
||||
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(mProviders.get(
|
||||
componentName.flattenToString()).mProviderSessionMetric
|
||||
.getCandidatePhasePerProviderMetric());
|
||||
if (mProviders.get(componentName.flattenToString()) != null) {
|
||||
ProviderSessionMetric providerSessionMetric =
|
||||
mProviders.get(componentName.flattenToString()).mProviderSessionMetric;
|
||||
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(providerSessionMetric
|
||||
.getCandidatePhasePerProviderMetric());
|
||||
}
|
||||
if (response != null) {
|
||||
mRequestSessionMetric.collectChosenProviderStatus(
|
||||
ProviderStatusForMetrics.FINAL_SUCCESS.getMetricCode());
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.os.RemoteException;
|
||||
import android.service.credentials.CallingAppInfo;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.credentials.metrics.ProviderSessionMetric;
|
||||
import com.android.server.credentials.metrics.ProviderStatusForMetrics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -118,9 +119,12 @@ public class GetRequestSession extends RequestSession<GetCredentialRequest,
|
||||
@Nullable GetCredentialResponse response) {
|
||||
Slog.i(TAG, "onFinalResponseReceived from: " + componentName.flattenToString());
|
||||
mRequestSessionMetric.collectUiResponseData(/*uiReturned=*/ true, System.nanoTime());
|
||||
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(
|
||||
mProviders.get(componentName.flattenToString())
|
||||
.mProviderSessionMetric.getCandidatePhasePerProviderMetric());
|
||||
if (mProviders.get(componentName.flattenToString()) != null) {
|
||||
ProviderSessionMetric providerSessionMetric =
|
||||
mProviders.get(componentName.flattenToString()).mProviderSessionMetric;
|
||||
mRequestSessionMetric.collectChosenMetricViaCandidateTransfer(providerSessionMetric
|
||||
.getCandidatePhasePerProviderMetric());
|
||||
}
|
||||
if (response != null) {
|
||||
mRequestSessionMetric.collectChosenProviderStatus(
|
||||
ProviderStatusForMetrics.FINAL_SUCCESS.getMetricCode());
|
||||
|
||||
@@ -141,7 +141,7 @@ public class MetricUtilities {
|
||||
index++;
|
||||
}
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_FINAL_PHASE_REPORTED,
|
||||
/* session_id */ finalPhaseMetric.getSessionIdTrackTwo(),
|
||||
/* session_id */ finalPhaseMetric.getSessionIdProvider(),
|
||||
/* sequence_num */ emitSequenceId,
|
||||
/* ui_returned_final_start */ finalPhaseMetric.isUiReturned(),
|
||||
/* chosen_provider_uid */ finalPhaseMetric.getChosenUid(),
|
||||
@@ -225,7 +225,7 @@ public class MetricUtilities {
|
||||
CandidatePhaseMetric metric = session.mProviderSessionMetric
|
||||
.getCandidatePhasePerProviderMetric();
|
||||
if (sessionId == -1) {
|
||||
sessionId = metric.getSessionIdTrackTwo();
|
||||
sessionId = metric.getSessionIdProvider();
|
||||
}
|
||||
if (!queryReturned) {
|
||||
queryReturned = metric.isQueryReturned();
|
||||
@@ -329,7 +329,7 @@ public class MetricUtilities {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_INIT_PHASE_REPORTED,
|
||||
/* api_name */ initialPhaseMetric.getApiName(),
|
||||
/* caller_uid */ initialPhaseMetric.getCallerUid(),
|
||||
/* session_id */ initialPhaseMetric.getSessionId(),
|
||||
/* session_id */ initialPhaseMetric.getSessionIdCaller(),
|
||||
/* sequence_num */ sequenceNum,
|
||||
/* initial_timestamp_reference_nanoseconds */
|
||||
initialPhaseMetric.getCredentialServiceStartedTimeNanoseconds(),
|
||||
@@ -360,7 +360,7 @@ public class MetricUtilities {
|
||||
try {
|
||||
if (!LOG_FLAG) {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_TOTAL_REPORTED,
|
||||
/*session_id*/ candidateAggregateMetric.getSessionId(),
|
||||
/*session_id*/ candidateAggregateMetric.getSessionIdProvider(),
|
||||
/*sequence_num*/ sequenceNum,
|
||||
/*query_returned*/ candidateAggregateMetric.isQueryReturned(),
|
||||
/*num_providers*/ candidateAggregateMetric.getNumProviders(),
|
||||
@@ -405,4 +405,70 @@ public class MetricUtilities {
|
||||
Slog.w(TAG, "Unexpected error during metric logging: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A logging utility used primarily for the final phase of the current metric setup for track 1.
|
||||
*
|
||||
* @param finalPhaseMetric the coalesced data of the chosen provider
|
||||
* @param browsingPhaseMetrics the coalesced data of the browsing phase
|
||||
* @param apiStatus the final status of this particular api call
|
||||
* @param emitSequenceId an emitted sequence id for the current session
|
||||
*/
|
||||
public static void logApiCalledNoUidFinal(ChosenProviderFinalPhaseMetric finalPhaseMetric,
|
||||
List<CandidateBrowsingPhaseMetric> browsingPhaseMetrics, int apiStatus,
|
||||
int emitSequenceId) {
|
||||
try {
|
||||
if (!LOG_FLAG) {
|
||||
return;
|
||||
}
|
||||
int browsedSize = browsingPhaseMetrics.size();
|
||||
int[] browsedClickedEntries = new int[browsedSize];
|
||||
int[] browsedProviderUid = new int[browsedSize];
|
||||
int index = 0;
|
||||
for (CandidateBrowsingPhaseMetric metric : browsingPhaseMetrics) {
|
||||
browsedClickedEntries[index] = metric.getEntryEnum();
|
||||
browsedProviderUid[index] = metric.getProviderUid();
|
||||
index++;
|
||||
}
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_FINALNOUID_REPORTED,
|
||||
/* session_id */ finalPhaseMetric.getSessionIdCaller(),
|
||||
/* sequence_num */ emitSequenceId,
|
||||
/* ui_returned_final_start */ finalPhaseMetric.isUiReturned(),
|
||||
/* chosen_provider_query_start_timestamp_microseconds */
|
||||
finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
|
||||
.getQueryStartTimeNanoseconds()),
|
||||
/* chosen_provider_query_end_timestamp_microseconds */
|
||||
finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
|
||||
.getQueryEndTimeNanoseconds()),
|
||||
/* chosen_provider_ui_invoked_timestamp_microseconds */
|
||||
finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
|
||||
.getUiCallStartTimeNanoseconds()),
|
||||
/* chosen_provider_ui_finished_timestamp_microseconds */
|
||||
finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
|
||||
.getUiCallEndTimeNanoseconds()),
|
||||
/* chosen_provider_finished_timestamp_microseconds */
|
||||
finalPhaseMetric.getTimestampFromReferenceStartMicroseconds(finalPhaseMetric
|
||||
.getFinalFinishTimeNanoseconds()),
|
||||
/* chosen_provider_status */ finalPhaseMetric.getChosenProviderStatus(),
|
||||
/* chosen_provider_has_exception */ finalPhaseMetric.isHasException(),
|
||||
/* 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_classtype */
|
||||
finalPhaseMetric.getFrameworkException(),
|
||||
/* clicked_entries */ browsedClickedEntries,
|
||||
/* provider_of_clicked_entry */ browsedProviderUid,
|
||||
/* api_status */ apiStatus,
|
||||
/* primary_indicated */ false
|
||||
);
|
||||
} catch (Exception e) {
|
||||
Slog.w(TAG, "Unexpected error during metric logging: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -138,8 +138,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
|
||||
mRequestSessionMetric = new RequestSessionMetric(mUniqueSessionInteger,
|
||||
MetricUtilities.getHighlyUniqueInteger());
|
||||
mRequestSessionMetric.collectInitialPhaseMetricInfo(timestampStarted,
|
||||
mCallingUid, ApiName.getMetricCodeFromRequestInfo(mRequestType),
|
||||
mUniqueSessionInteger);
|
||||
mCallingUid, ApiName.getMetricCodeFromRequestInfo(mRequestType));
|
||||
setCancellationListener();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,16 @@ package com.android.server.credentials.metrics;
|
||||
* Contains information about what was collected from the authentication entry output.
|
||||
*/
|
||||
public class BrowsedAuthenticationMetric {
|
||||
private final int mSessionIdTrackTwo;
|
||||
// The session id of this provider known flow related metric
|
||||
private final int mSessionIdProvider;
|
||||
// TODO(b/271135048) - Match the atom and provide a clean per provider session metric
|
||||
// encapsulation.
|
||||
|
||||
public BrowsedAuthenticationMetric(int sessionIdTrackTwo) {
|
||||
mSessionIdTrackTwo = sessionIdTrackTwo;
|
||||
public BrowsedAuthenticationMetric(int sessionIdProvider) {
|
||||
mSessionIdProvider = sessionIdProvider;
|
||||
}
|
||||
|
||||
public int getSessionIdTrackTwo() {
|
||||
return mSessionIdTrackTwo;
|
||||
public int getSessionIdProvider() {
|
||||
return mSessionIdProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.util.Map;
|
||||
public class CandidateAggregateMetric {
|
||||
|
||||
private static final String TAG = "CandidateProviderMetric";
|
||||
// The session id of this provider, default set to -1
|
||||
private final int mSessionId;
|
||||
// The session id of this provider metric
|
||||
private final int mSessionIdProvider;
|
||||
// Indicates if this provider returned from the query phase, default false
|
||||
private boolean mQueryReturned = false;
|
||||
// Indicates the total number of providers this aggregate captures information for, default 0
|
||||
@@ -37,11 +37,11 @@ public class CandidateAggregateMetric {
|
||||
private int mNumAuthEntriesTapped = 0;
|
||||
|
||||
public CandidateAggregateMetric(int sessionIdTrackOne) {
|
||||
mSessionId = sessionIdTrackOne;
|
||||
mSessionIdProvider = sessionIdTrackOne;
|
||||
}
|
||||
|
||||
public int getSessionId() {
|
||||
return mSessionId;
|
||||
public int getSessionIdProvider() {
|
||||
return mSessionIdProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,8 +32,8 @@ import java.util.Map;
|
||||
public class CandidatePhaseMetric {
|
||||
|
||||
private static final String TAG = "CandidateProviderMetric";
|
||||
// The session id of this provider, default set to -1
|
||||
private final int mSessionIdTrackTwo;
|
||||
// The session id of this provider metric
|
||||
private final int mSessionIdProvider;
|
||||
// Indicates if this provider returned from the query phase, default false
|
||||
private boolean mQueryReturned = false;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class CandidatePhaseMetric {
|
||||
private ResponseCollective mResponseCollective = new ResponseCollective(Map.of(), Map.of());
|
||||
|
||||
public CandidatePhaseMetric(int sessionIdTrackTwo) {
|
||||
mSessionIdTrackTwo = sessionIdTrackTwo;
|
||||
mSessionIdProvider = sessionIdTrackTwo;
|
||||
}
|
||||
|
||||
/* ---------- Latencies ---------- */
|
||||
@@ -143,8 +143,8 @@ public class CandidatePhaseMetric {
|
||||
|
||||
/* -------------- Session Id ---------------- */
|
||||
|
||||
public int getSessionIdTrackTwo() {
|
||||
return mSessionIdTrackTwo;
|
||||
public int getSessionIdProvider() {
|
||||
return mSessionIdProvider;
|
||||
}
|
||||
|
||||
/* -------------- Query Returned Status ---------------- */
|
||||
|
||||
@@ -34,10 +34,10 @@ public class ChosenProviderFinalPhaseMetric {
|
||||
private static final String TAG = "ChosenFinalPhaseMetric";
|
||||
// The session id associated with this API call, used to unite split emits, for the flow
|
||||
// where we know the calling app
|
||||
private final int mSessionIdTrackOne;
|
||||
private final int mSessionIdCaller;
|
||||
// The session id associated with this API call, used to unite split emits, for the flow
|
||||
// where we know the provider apps
|
||||
private final int mSessionIdTrackTwo;
|
||||
private final int mSessionIdProvider;
|
||||
// Reveals if the UI was returned, false by default
|
||||
private boolean mUiReturned = false;
|
||||
private int mChosenUid = -1;
|
||||
@@ -78,9 +78,9 @@ public class ChosenProviderFinalPhaseMetric {
|
||||
private ResponseCollective mResponseCollective = new ResponseCollective(Map.of(), Map.of());
|
||||
|
||||
|
||||
public ChosenProviderFinalPhaseMetric(int sessionIdTrackOne, int sessionIdTrackTwo) {
|
||||
mSessionIdTrackOne = sessionIdTrackOne;
|
||||
mSessionIdTrackTwo = sessionIdTrackTwo;
|
||||
public ChosenProviderFinalPhaseMetric(int sessionIdCaller, int sessionIdProvider) {
|
||||
mSessionIdCaller = sessionIdCaller;
|
||||
mSessionIdProvider = sessionIdProvider;
|
||||
}
|
||||
|
||||
/* ------------------- UID ------------------- */
|
||||
@@ -243,8 +243,8 @@ public class ChosenProviderFinalPhaseMetric {
|
||||
|
||||
/* ----------- Session ID -------------- */
|
||||
|
||||
public int getSessionIdTrackTwo() {
|
||||
return mSessionIdTrackTwo;
|
||||
public int getSessionIdProvider() {
|
||||
return mSessionIdProvider;
|
||||
}
|
||||
|
||||
/* ----------- UI Returned Successfully -------------- */
|
||||
@@ -286,4 +286,10 @@ public class ChosenProviderFinalPhaseMetric {
|
||||
public String getFrameworkException() {
|
||||
return mFrameworkException;
|
||||
}
|
||||
|
||||
/* -------------- Session ID for Track One (Known Calling App) ---------------- */
|
||||
|
||||
public int getSessionIdCaller() {
|
||||
return mSessionIdCaller;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public class InitialPhaseMetric {
|
||||
private int mApiName = ApiName.UNKNOWN.getMetricCode();
|
||||
// The caller uid of the calling application, default to -1
|
||||
private int mCallerUid = -1;
|
||||
// The session id to unite multiple atom emits, default to -1
|
||||
private final int mSessionId;
|
||||
// The session id to unite multiple atom emits
|
||||
private final int mSessionIdCaller;
|
||||
|
||||
// Raw timestamps in nanoseconds, *the only* one logged as such (i.e. 64 bits) since it is a
|
||||
// reference point.
|
||||
@@ -51,7 +51,7 @@ public class InitialPhaseMetric {
|
||||
|
||||
|
||||
public InitialPhaseMetric(int sessionIdTrackOne) {
|
||||
mSessionId = sessionIdTrackOne;
|
||||
mSessionIdCaller = sessionIdTrackOne;
|
||||
}
|
||||
|
||||
/* ---------- Latencies ---------- */
|
||||
@@ -106,8 +106,8 @@ public class InitialPhaseMetric {
|
||||
|
||||
/* ------ SessionId ------ */
|
||||
|
||||
public int getSessionId() {
|
||||
return mSessionId;
|
||||
public int getSessionIdCaller() {
|
||||
return mSessionIdCaller;
|
||||
}
|
||||
|
||||
/* ------ Count Request Class Types ------ */
|
||||
|
||||
@@ -21,6 +21,7 @@ import static com.android.server.credentials.MetricUtilities.DELTA_RESPONSES_CUT
|
||||
import static com.android.server.credentials.MetricUtilities.generateMetricKey;
|
||||
import static com.android.server.credentials.MetricUtilities.logApiCalledCandidatePhase;
|
||||
import static com.android.server.credentials.MetricUtilities.logApiCalledFinalPhase;
|
||||
import static com.android.server.credentials.MetricUtilities.logApiCalledNoUidFinal;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.credentials.GetCredentialRequest;
|
||||
@@ -103,7 +104,7 @@ public class RequestSessionMetric {
|
||||
* known flow
|
||||
*/
|
||||
public void collectInitialPhaseMetricInfo(long timestampStarted,
|
||||
int mCallingUid, int metricCode, int callingAppFlowUniqueInt) {
|
||||
int mCallingUid, int metricCode) {
|
||||
try {
|
||||
mInitialPhaseMetric.setCredentialServiceStartedTimeNanoseconds(timestampStarted);
|
||||
mInitialPhaseMetric.setCallerUid(mCallingUid);
|
||||
@@ -371,6 +372,9 @@ public class RequestSessionMetric {
|
||||
logApiCalledFinalPhase(mChosenProviderFinalPhaseMetric, mCandidateBrowsingPhaseMetric,
|
||||
apiStatus,
|
||||
++mSequenceCounter);
|
||||
logApiCalledNoUidFinal(mChosenProviderFinalPhaseMetric, mCandidateBrowsingPhaseMetric,
|
||||
apiStatus,
|
||||
++mSequenceCounter);
|
||||
} catch (Exception e) {
|
||||
Slog.i(TAG, "Unexpected error during final metric emit: " + e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user