From 76ce2d6d04e4a22a5d2065cf92eeff4f3fefd4bd Mon Sep 17 00:00:00 2001 From: David Chen Date: Wed, 31 Jan 2018 16:38:13 -0800 Subject: Implements StatsManager temporary stubs. Need to use the old API for a bit, so the temporary API will convert the arguments for ConfigKey from String to Long and then call the correct API from statsd. This can be deleted in the future. Test: Test that marlin-eng can build. Change-Id: Iebaf2debc08c749ecaae631201e7d039b916f0ce --- core/java/android/util/StatsManager.java | 44 ++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'core/java/android/util/StatsManager.java') diff --git a/core/java/android/util/StatsManager.java b/core/java/android/util/StatsManager.java index 687aa8375e01..51fb18a95c4c 100644 --- a/core/java/android/util/StatsManager.java +++ b/core/java/android/util/StatsManager.java @@ -60,9 +60,19 @@ public class StatsManager { */ @RequiresPermission(Manifest.permission.DUMP) public boolean addConfiguration(String configKey, byte[] config, String pkg, String cls) { - // To prevent breakages of dependencies on old API. - - return false; + synchronized (this) { + try { + IStatsManager service = getIStatsManagerLocked(); + if (service == null) { + Slog.d(TAG, "Failed to find statsd when adding configuration"); + return false; + } + return service.addConfiguration(Long.parseLong(configKey), config, pkg, cls); + } catch (RemoteException e) { + Slog.d(TAG, "Failed to connect to statsd when adding configuration"); + return false; + } + } } /** @@ -99,7 +109,19 @@ public class StatsManager { @RequiresPermission(Manifest.permission.DUMP) public boolean removeConfiguration(String configKey) { // To prevent breakages of old dependencies. - return false; + synchronized (this) { + try { + IStatsManager service = getIStatsManagerLocked(); + if (service == null) { + Slog.d(TAG, "Failed to find statsd when removing configuration"); + return false; + } + return service.removeConfiguration(Long.parseLong(configKey)); + } catch (RemoteException e) { + Slog.d(TAG, "Failed to connect to statsd when removing configuration"); + return false; + } + } } /** @@ -132,7 +154,19 @@ public class StatsManager { public byte[] getData(String configKey) { // TODO: remove this and all other methods with String-based config keys. // To prevent build breakages of dependencies. - return null; + synchronized (this) { + try { + IStatsManager service = getIStatsManagerLocked(); + if (service == null) { + Slog.d(TAG, "Failed to find statsd when getting data"); + return null; + } + return service.getData(Long.parseLong(configKey)); + } catch (RemoteException e) { + Slog.d(TAG, "Failed to connecto statsd when getting data"); + return null; + } + } } /** -- cgit v1.2.3