Loading services/credentials/java/com/android/server/credentials/CreateRequestSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -168,7 +168,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); // TODO add exception bit if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) { Log.i(TAG, "Request has already been completed. This is strange."); return; Loading services/credentials/java/com/android/server/credentials/CredentialManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -592,9 +592,13 @@ public final class CredentialManagerService } private void finalizeAndEmitInitialPhaseMetric(RequestSession session) { try { var initMetric = session.mInitialPhaseMetric; initMetric.setCredentialServiceBeginQueryTimeNanoseconds(System.nanoTime()); MetricUtilities.logApiCalled(initMetric); } catch (Exception e) { Log.w(TAG, "Unexpected error during metric logging: " + e); } } @Override Loading services/credentials/java/com/android/server/credentials/MetricUtilities.java +30 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,34 @@ public class MetricUtilities { return (int) ((t2 - t1) / 1000); } /** * A logging utility used primarily for the candidate phase of the current metric setup. * * @param providers a map with known providers * @param emitSequenceId an emitted sequence id for the current session */ protected static void logApiCalled(Map<String, ProviderSession> providers, int emitSequenceId) { try { var providerSessions = providers.values(); int providerSize = providerSessions.size(); int[] candidateUidList = new int[providerSize]; int[] candidateQueryRoundTripTimeList = new int[providerSize]; int[] candidateStatusList = new int[providerSize]; int index = 0; for (var session : providerSessions) { CandidatePhaseMetric metric = session.mCandidatePhasePerProviderMetric; candidateUidList[index] = metric.getCandidateUid(); candidateQueryRoundTripTimeList[index] = metric.getQueryLatencyMicroseconds(); candidateStatusList[index] = metric.getProviderQueryStatus(); index++; } // TODO Handle the emit here } catch (Exception e) { Log.w(TAG, "Unexpected error during metric logging: " + e); } } /** * 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 Loading @@ -90,6 +118,7 @@ public class MetricUtilities { * @param providers a map with known providers * @param callingUid the calling UID of the client app * @param chosenProviderFinalPhaseMetric the metric data type of the final chosen provider * TODO remove soon */ protected static void logApiCalled(ApiName apiName, ApiStatus apiStatus, Map<String, ProviderSession> providers, int callingUid, Loading Loading @@ -133,6 +162,7 @@ public class MetricUtilities { * contain default values for all other optional parameters. * * TODO(b/271135048) - given space requirements, this may be a good candidate for another atom * TODO immediately remove and carry over TODO to new log for this setup * * @param apiName the api name to log * @param apiStatus the status to log Loading services/credentials/java/com/android/server/credentials/ProviderClearSession.java +6 −11 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ public final class ProviderClearSession extends ProviderSession<ClearCredential private ClearCredentialStateException mProviderException; /** Creates a new provider session to be used by the request session. */ @Nullable public static ProviderClearSession createNewSession( @Nullable public static ProviderClearSession createNewSession( Context context, @UserIdInt int userId, CredentialProviderInfo providerInfo, Loading Loading @@ -90,6 +91,7 @@ public final class ProviderClearSession extends ProviderSession<ClearCredential if (exception instanceof ClearCredentialStateException) { mProviderException = (ClearCredentialStateException) exception; } captureCandidateFailure(); updateStatusAndInvokeCallback(toStatus(errorCode)); } Loading Loading @@ -120,14 +122,7 @@ public final class ProviderClearSession extends ProviderSession<ClearCredential @Override protected void invokeSession() { if (mRemoteCredentialService != null) { /* InitialPhaseMetric initMetric = ((RequestSession)mCallbacks).initMetric; TODO immediately once the other change patched through mCandidateProviderMetric.setSessionId(initMetric .mInitialPhaseMetric.getSessionId()); mCandidateProviderMetric.setStartTime(initMetric.getStartTime()) */ mCandidatePhasePerProviderMetric.setStartQueryTimeNanoseconds(System.nanoTime()); startCandidateMetrics(); mRemoteCredentialService.onClearCredentialState(mProviderRequest, this); } } Loading services/credentials/java/com/android/server/credentials/ProviderCreateSession.java +31 −12 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ import android.util.Log; import android.util.Pair; import android.util.Slog; import com.android.server.credentials.metrics.EntryEnum; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading @@ -65,7 +67,8 @@ public final class ProviderCreateSession extends ProviderSession< private final ProviderResponseDataHandler mProviderResponseDataHandler; /** Creates a new provider session to be used by the request session. */ @Nullable public static ProviderCreateSession createNewSession( @Nullable public static ProviderCreateSession createNewSession( Context context, @UserIdInt int userId, CredentialProviderInfo providerInfo, Loading Loading @@ -155,6 +158,7 @@ public final class ProviderCreateSession extends ProviderSession< // Store query phase exception for aggregation with final response mProviderException = (CreateCredentialException) exception; } captureCandidateFailure(); updateStatusAndInvokeCallback(toStatus(errorCode)); } Loading @@ -175,14 +179,32 @@ public final class ProviderCreateSession extends ProviderSession< mProviderResponseDataHandler.addResponseContent(response.getCreateEntries(), response.getRemoteCreateEntry()); if (mProviderResponseDataHandler.isEmptyResponse(response)) { gatheCandidateEntryMetrics(response); updateStatusAndInvokeCallback(Status.EMPTY_RESPONSE); } else { gatheCandidateEntryMetrics(response); updateStatusAndInvokeCallback(Status.SAVE_ENTRIES_RECEIVED); } } private void gatheCandidateEntryMetrics(BeginCreateCredentialResponse response) { try { var createEntries = response.getCreateEntries(); int numCreateEntries = createEntries == null ? 0 : createEntries.size(); // TODO confirm how to get types from slice if (numCreateEntries > 0) { createEntries.forEach(c -> mCandidatePhasePerProviderMetric.addEntry(EntryEnum.CREDENTIAL_ENTRY)); } mCandidatePhasePerProviderMetric.setNumEntriesTotal(numCreateEntries); } catch (Exception e) { Log.w(TAG, "Unexpected error during metric logging: " + e); } } @Override @Nullable protected CreateCredentialProviderData prepareUiData() @Nullable protected CreateCredentialProviderData prepareUiData() throws IllegalArgumentException { Log.i(TAG, "In prepareUiData"); if (!ProviderSession.isUiInvokingStatus(getStatus())) { Loading Loading @@ -226,14 +248,7 @@ public final class ProviderCreateSession extends ProviderSession< @Override protected void invokeSession() { if (mRemoteCredentialService != null) { /* InitialPhaseMetric initMetric = ((RequestSession)mCallbacks).initMetric; TODO immediately once the other change patched through mCandidateProviderMetric.setSessionId(initMetric .mInitialPhaseMetric.getSessionId()); mCandidateProviderMetric.setStartTime(initMetric.getStartTime()) */ mCandidatePhasePerProviderMetric.setStartQueryTimeNanoseconds(System.nanoTime()); startCandidateMetrics(); mRemoteCredentialService.onCreateCredential(mProviderRequest, this); } } Loading Loading @@ -305,12 +320,14 @@ public final class ProviderCreateSession extends ProviderSession< } private class ProviderResponseDataHandler { @Nullable private final ComponentName mExpectedRemoteEntryProviderService; @Nullable private final ComponentName mExpectedRemoteEntryProviderService; @NonNull private final Map<String, Pair<CreateEntry, Entry>> mUiCreateEntries = new HashMap<>(); @Nullable private Pair<String, Pair<RemoteEntry, Entry>> mUiRemoteEntry = null; @Nullable private Pair<String, Pair<RemoteEntry, Entry>> mUiRemoteEntry = null; ProviderResponseDataHandler(@Nullable ComponentName expectedRemoteEntryProviderService) { mExpectedRemoteEntryProviderService = expectedRemoteEntryProviderService; Loading @@ -323,6 +340,7 @@ public final class ProviderCreateSession extends ProviderSession< setRemoteEntry(remoteEntry); } } public void addCreateEntry(CreateEntry createEntry) { String id = generateUniqueId(); Entry entry = new Entry(SAVE_ENTRY_KEY, Loading Loading @@ -373,6 +391,7 @@ public final class ProviderCreateSession extends ProviderSession< private boolean isEmptyResponse() { return mUiCreateEntries.isEmpty() && mUiRemoteEntry == null; } @Nullable public RemoteEntry getRemoteEntry(String entryKey) { return mUiRemoteEntry == null || mUiRemoteEntry Loading Loading
services/credentials/java/com/android/server/credentials/CreateRequestSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -168,7 +168,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR private void respondToClientWithErrorAndFinish(String errorType, String errorMsg) { Log.i(TAG, "respondToClientWithErrorAndFinish"); // TODO add exception bit if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) { Log.i(TAG, "Request has already been completed. This is strange."); return; Loading
services/credentials/java/com/android/server/credentials/CredentialManagerService.java +7 −3 Original line number Diff line number Diff line Loading @@ -592,9 +592,13 @@ public final class CredentialManagerService } private void finalizeAndEmitInitialPhaseMetric(RequestSession session) { try { var initMetric = session.mInitialPhaseMetric; initMetric.setCredentialServiceBeginQueryTimeNanoseconds(System.nanoTime()); MetricUtilities.logApiCalled(initMetric); } catch (Exception e) { Log.w(TAG, "Unexpected error during metric logging: " + e); } } @Override Loading
services/credentials/java/com/android/server/credentials/MetricUtilities.java +30 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,34 @@ public class MetricUtilities { return (int) ((t2 - t1) / 1000); } /** * A logging utility used primarily for the candidate phase of the current metric setup. * * @param providers a map with known providers * @param emitSequenceId an emitted sequence id for the current session */ protected static void logApiCalled(Map<String, ProviderSession> providers, int emitSequenceId) { try { var providerSessions = providers.values(); int providerSize = providerSessions.size(); int[] candidateUidList = new int[providerSize]; int[] candidateQueryRoundTripTimeList = new int[providerSize]; int[] candidateStatusList = new int[providerSize]; int index = 0; for (var session : providerSessions) { CandidatePhaseMetric metric = session.mCandidatePhasePerProviderMetric; candidateUidList[index] = metric.getCandidateUid(); candidateQueryRoundTripTimeList[index] = metric.getQueryLatencyMicroseconds(); candidateStatusList[index] = metric.getProviderQueryStatus(); index++; } // TODO Handle the emit here } catch (Exception e) { Log.w(TAG, "Unexpected error during metric logging: " + e); } } /** * 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 Loading @@ -90,6 +118,7 @@ public class MetricUtilities { * @param providers a map with known providers * @param callingUid the calling UID of the client app * @param chosenProviderFinalPhaseMetric the metric data type of the final chosen provider * TODO remove soon */ protected static void logApiCalled(ApiName apiName, ApiStatus apiStatus, Map<String, ProviderSession> providers, int callingUid, Loading Loading @@ -133,6 +162,7 @@ public class MetricUtilities { * contain default values for all other optional parameters. * * TODO(b/271135048) - given space requirements, this may be a good candidate for another atom * TODO immediately remove and carry over TODO to new log for this setup * * @param apiName the api name to log * @param apiStatus the status to log Loading
services/credentials/java/com/android/server/credentials/ProviderClearSession.java +6 −11 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ public final class ProviderClearSession extends ProviderSession<ClearCredential private ClearCredentialStateException mProviderException; /** Creates a new provider session to be used by the request session. */ @Nullable public static ProviderClearSession createNewSession( @Nullable public static ProviderClearSession createNewSession( Context context, @UserIdInt int userId, CredentialProviderInfo providerInfo, Loading Loading @@ -90,6 +91,7 @@ public final class ProviderClearSession extends ProviderSession<ClearCredential if (exception instanceof ClearCredentialStateException) { mProviderException = (ClearCredentialStateException) exception; } captureCandidateFailure(); updateStatusAndInvokeCallback(toStatus(errorCode)); } Loading Loading @@ -120,14 +122,7 @@ public final class ProviderClearSession extends ProviderSession<ClearCredential @Override protected void invokeSession() { if (mRemoteCredentialService != null) { /* InitialPhaseMetric initMetric = ((RequestSession)mCallbacks).initMetric; TODO immediately once the other change patched through mCandidateProviderMetric.setSessionId(initMetric .mInitialPhaseMetric.getSessionId()); mCandidateProviderMetric.setStartTime(initMetric.getStartTime()) */ mCandidatePhasePerProviderMetric.setStartQueryTimeNanoseconds(System.nanoTime()); startCandidateMetrics(); mRemoteCredentialService.onClearCredentialState(mProviderRequest, this); } } Loading
services/credentials/java/com/android/server/credentials/ProviderCreateSession.java +31 −12 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ import android.util.Log; import android.util.Pair; import android.util.Slog; import com.android.server.credentials.metrics.EntryEnum; import java.util.ArrayList; import java.util.HashMap; import java.util.List; Loading @@ -65,7 +67,8 @@ public final class ProviderCreateSession extends ProviderSession< private final ProviderResponseDataHandler mProviderResponseDataHandler; /** Creates a new provider session to be used by the request session. */ @Nullable public static ProviderCreateSession createNewSession( @Nullable public static ProviderCreateSession createNewSession( Context context, @UserIdInt int userId, CredentialProviderInfo providerInfo, Loading Loading @@ -155,6 +158,7 @@ public final class ProviderCreateSession extends ProviderSession< // Store query phase exception for aggregation with final response mProviderException = (CreateCredentialException) exception; } captureCandidateFailure(); updateStatusAndInvokeCallback(toStatus(errorCode)); } Loading @@ -175,14 +179,32 @@ public final class ProviderCreateSession extends ProviderSession< mProviderResponseDataHandler.addResponseContent(response.getCreateEntries(), response.getRemoteCreateEntry()); if (mProviderResponseDataHandler.isEmptyResponse(response)) { gatheCandidateEntryMetrics(response); updateStatusAndInvokeCallback(Status.EMPTY_RESPONSE); } else { gatheCandidateEntryMetrics(response); updateStatusAndInvokeCallback(Status.SAVE_ENTRIES_RECEIVED); } } private void gatheCandidateEntryMetrics(BeginCreateCredentialResponse response) { try { var createEntries = response.getCreateEntries(); int numCreateEntries = createEntries == null ? 0 : createEntries.size(); // TODO confirm how to get types from slice if (numCreateEntries > 0) { createEntries.forEach(c -> mCandidatePhasePerProviderMetric.addEntry(EntryEnum.CREDENTIAL_ENTRY)); } mCandidatePhasePerProviderMetric.setNumEntriesTotal(numCreateEntries); } catch (Exception e) { Log.w(TAG, "Unexpected error during metric logging: " + e); } } @Override @Nullable protected CreateCredentialProviderData prepareUiData() @Nullable protected CreateCredentialProviderData prepareUiData() throws IllegalArgumentException { Log.i(TAG, "In prepareUiData"); if (!ProviderSession.isUiInvokingStatus(getStatus())) { Loading Loading @@ -226,14 +248,7 @@ public final class ProviderCreateSession extends ProviderSession< @Override protected void invokeSession() { if (mRemoteCredentialService != null) { /* InitialPhaseMetric initMetric = ((RequestSession)mCallbacks).initMetric; TODO immediately once the other change patched through mCandidateProviderMetric.setSessionId(initMetric .mInitialPhaseMetric.getSessionId()); mCandidateProviderMetric.setStartTime(initMetric.getStartTime()) */ mCandidatePhasePerProviderMetric.setStartQueryTimeNanoseconds(System.nanoTime()); startCandidateMetrics(); mRemoteCredentialService.onCreateCredential(mProviderRequest, this); } } Loading Loading @@ -305,12 +320,14 @@ public final class ProviderCreateSession extends ProviderSession< } private class ProviderResponseDataHandler { @Nullable private final ComponentName mExpectedRemoteEntryProviderService; @Nullable private final ComponentName mExpectedRemoteEntryProviderService; @NonNull private final Map<String, Pair<CreateEntry, Entry>> mUiCreateEntries = new HashMap<>(); @Nullable private Pair<String, Pair<RemoteEntry, Entry>> mUiRemoteEntry = null; @Nullable private Pair<String, Pair<RemoteEntry, Entry>> mUiRemoteEntry = null; ProviderResponseDataHandler(@Nullable ComponentName expectedRemoteEntryProviderService) { mExpectedRemoteEntryProviderService = expectedRemoteEntryProviderService; Loading @@ -323,6 +340,7 @@ public final class ProviderCreateSession extends ProviderSession< setRemoteEntry(remoteEntry); } } public void addCreateEntry(CreateEntry createEntry) { String id = generateUniqueId(); Entry entry = new Entry(SAVE_ENTRY_KEY, Loading Loading @@ -373,6 +391,7 @@ public final class ProviderCreateSession extends ProviderSession< private boolean isEmptyResponse() { return mUiCreateEntries.isEmpty() && mUiRemoteEntry == null; } @Nullable public RemoteEntry getRemoteEntry(String entryKey) { return mUiRemoteEntry == null || mUiRemoteEntry Loading