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

Commit c562bfb6 authored by David Chen's avatar David Chen
Browse files

Converts exceptions to log messages in StatsManager.

We log if the statsd is not available instead of throwing an
exception. This helps prevent a crash when calling this API since
statsd is not a system service and can potentially be down.

Test: Not applicable.

Change-Id: I776efede4a01c751924fa9a8abd0eec0c4c1306b
parent 24c99247
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -58,11 +58,12 @@ public final class StatsManager {
            try {
                IStatsManager service = getIStatsManagerLocked();
                if (service == null) {
                    throw new RuntimeException("StatsD service connection lost");
                    Slog.d(TAG, "Failed to find statsd when adding configuration");
                    return false;
                }
                return service.addConfiguration(configKey, config, pkg, cls);
            } catch (RemoteException e) {
                Slog.d(TAG, "Failed to connect to statsd when getting data");
                Slog.d(TAG, "Failed to connect to statsd when adding configuration");
                return false;
            }
        }
@@ -80,11 +81,12 @@ public final class StatsManager {
            try {
                IStatsManager service = getIStatsManagerLocked();
                if (service == null) {
                    throw new RuntimeException("StatsD service connection lost");
                    Slog.d(TAG, "Failed to find statsd when removing configuration");
                    return false;
                }
                return service.removeConfiguration(configKey);
            } catch (RemoteException e) {
                Slog.d(TAG, "Failed to connect to statsd when getting data");
                Slog.d(TAG, "Failed to connect to statsd when removing configuration");
                return false;
            }
        }
@@ -102,7 +104,8 @@ public final class StatsManager {
            try {
                IStatsManager service = getIStatsManagerLocked();
                if (service == null) {
                    throw new RuntimeException("StatsD service connection lost");
                    Slog.d(TAG, "Failed to find statsd when getting data");
                    return null;
                }
                return service.getData(configKey);
            } catch (RemoteException e) {