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

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

Gracefully failing Exceptions during logging

Logging should be optimized such that errors during the logging do not
affect the flow of the codebase. This is a step in that direction by
ensuring the core point of logging will not crash the application.

Bug: 272127428
Test: Build tested
Change-Id: Ice5c246e8520c9db71a49fe6d30a42fb841a701e
parent cb10ef04
Loading
Loading
Loading
Loading
+48 −40
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class MetricUtilities {
    protected static void logApiCalled(ApiName apiName, ApiStatus apiStatus,
            Map<String, ProviderSession> providers, int callingUid,
            ChosenProviderMetric chosenProviderMetric) {
        try {
            var providerSessions = providers.values();
            int providerSize = providerSessions.size();
            int[] candidateUidList = new int[providerSize];
@@ -117,6 +118,9 @@ public class MetricUtilities {
                    /* chosen_provider_final_phase_microseconds (backwards compat only) */
                    DEFAULT_INT_32,
                    /* chosen_provider_status */ chosenProviderMetric.getChosenProviderStatus());
        } catch (Exception e) {
            Log.w(TAG, "Unexpected error during metric logging: " + e);
        }
    }

    /**
@@ -131,6 +135,7 @@ public class MetricUtilities {
     */
    protected static void logApiCalled(ApiName apiName, ApiStatus apiStatus,
            int callingUid) {
        try {
            FrameworkStatsLog.write(FrameworkStatsLog.CREDENTIAL_MANAGER_API_CALLED,
                    /* api_name */apiName.getMetricCode(),
                    /* caller_uid */ callingUid,
@@ -145,6 +150,9 @@ public class MetricUtilities {
                    /* chosen_provider_final_phase_microseconds */
                    DEFAULT_INT_32,
                    /* chosen_provider_status */ DEFAULT_INT_32);
        } catch (Exception e) {
            Log.w(TAG, "Unexpected error during metric logging: " + e);
        }
    }

}