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

Commit fd673f32 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Implements StatsManager temporary stubs."

parents b3dc0105 76ce2d6d
Loading
Loading
Loading
Loading
+39 −5
Original line number Diff line number Diff line
@@ -60,10 +60,20 @@ 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.

        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;
            }
        }
    }

    /**
     * Clients can send a configuration and simultaneously registers the name of a broadcast
@@ -99,8 +109,20 @@ public class StatsManager {
    @RequiresPermission(Manifest.permission.DUMP)
    public boolean removeConfiguration(String configKey) {
        // To prevent breakages of old dependencies.
        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;
            }
        }
    }

    /**
     * Remove a configuration from logging.
@@ -132,8 +154,20 @@ 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.
        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;
            }
        }
    }

    /**
     * Clients can request data with a binder call. This getter is destructive and also clears