From 3d0d25996f430675ba6eb93acf593596ae6e43bd Mon Sep 17 00:00:00 2001 From: Arpan Kaphle Date: Sat, 22 Apr 2023 01:15:33 +0000 Subject: [PATCH] Adding in New Status Emit for isEnabled This utilizes our new atom to avoid the heavy defaulted version we used prior. This means far less space is needed to emit simple status for APIs such as isEnabled. Future status updates will be added. Bug: 271135048 Test: Build and won't submit until E2E Tested Change-Id: I32ddc8c35fb41a0cf258675507050e4de9bb88c9 --- .../credentials/CredentialManagerService.java | 5 ++-- .../server/credentials/MetricUtilities.java | 26 +++++-------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java index 7f95e058406e6..dd180d0ae4e49 100644 --- a/services/credentials/java/com/android/server/credentials/CredentialManagerService.java +++ b/services/credentials/java/com/android/server/credentials/CredentialManagerService.java @@ -748,7 +748,7 @@ public final class CredentialManagerService if (serviceComponentName.equals(componentName)) { if (!s.getServicePackageName().equals(callingPackage)) { // The component name and the package name do not match. - MetricUtilities.logApiCalledSimpleV1( + MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.FAILURE, callingUid); Slog.w( @@ -757,10 +757,9 @@ public final class CredentialManagerService + "not match package name."); return false; } - MetricUtilities.logApiCalledSimpleV1( + MetricUtilities.logApiCalledSimpleV2( ApiName.IS_ENABLED_CREDENTIAL_PROVIDER_SERVICE, ApiStatus.SUCCESS, callingUid); - // TODO(b/271135048) - Update asap to use the new logging types return true; } } diff --git a/services/credentials/java/com/android/server/credentials/MetricUtilities.java b/services/credentials/java/com/android/server/credentials/MetricUtilities.java index 47502c24fbd79..e4c6b3a10dd84 100644 --- a/services/credentials/java/com/android/server/credentials/MetricUtilities.java +++ b/services/credentials/java/com/android/server/credentials/MetricUtilities.java @@ -266,7 +266,9 @@ public class MetricUtilities { /* request_unique_classtypes */ initialPhaseMetric.getUniqueRequestStrings(), /* per_classtype_counts */ - initialPhaseMetric.getUniqueRequestCounts() + initialPhaseMetric.getUniqueRequestCounts(), + /* api_name */ + initialPhaseMetric.getApiName() ); } catch (Exception e) { Slog.w(TAG, "Unexpected error during candidate provider uid metric emit: " + e); @@ -274,36 +276,22 @@ public class MetricUtilities { } /** - * This is useful just to record an API calls' final event, and for no other purpose. It will - * 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 + * This is useful just to record an API calls' final event, and for no other purpose. * * @param apiName the api name to log * @param apiStatus the status to log * @param callingUid the calling uid */ - public static void logApiCalledSimpleV1(ApiName apiName, ApiStatus apiStatus, + public static void logApiCalledSimpleV2(ApiName apiName, ApiStatus apiStatus, int callingUid) { try { if (!LOG_FLAG) { return; } - FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED, + FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_APIV2_CALLED, /* api_name */apiName.getMetricCode(), /* caller_uid */ callingUid, - /* api_status */ apiStatus.getMetricCode(), - /* repeated_candidate_provider_uid */ DEFAULT_REPEATED_INT_32, - /* repeated_candidate_provider_round_trip_time_query_microseconds */ - DEFAULT_REPEATED_INT_32, - /* repeated_candidate_provider_status */ DEFAULT_REPEATED_INT_32, - /* chosen_provider_uid */ DEFAULT_INT_32, - /* chosen_provider_round_trip_time_overall_microseconds */ - DEFAULT_INT_32, - /* chosen_provider_final_phase_microseconds */ - DEFAULT_INT_32, - /* chosen_provider_status */ DEFAULT_INT_32); + /* api_status */ apiStatus.getMetricCode()); } catch (Exception e) { Slog.w(TAG, "Unexpected error during metric logging: " + e); }