diff options
| author | David Chen <dwchen@google.com> | 2017-11-17 17:44:33 -0800 |
|---|---|---|
| committer | David Chen <dwchen@google.com> | 2017-11-17 17:46:58 -0800 |
| commit | c562bfb68f84b86633da61c03ebcd7ac4629ba2a (patch) | |
| tree | f93029923d65ad6003bfaf5e72136ead2c8a44da /core/java/android/util/StatsManager.java | |
| parent | 24c992479799c8330f6b837d504bac7970310947 (diff) | |
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
Diffstat (limited to 'core/java/android/util/StatsManager.java')
| -rw-r--r-- | core/java/android/util/StatsManager.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/java/android/util/StatsManager.java b/core/java/android/util/StatsManager.java index 55b33a617a60..2bcd863cd409 100644 --- a/core/java/android/util/StatsManager.java +++ b/core/java/android/util/StatsManager.java @@ -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) { |
