IStatsManager.aidl revision 661f791a2580515eee5882ab9498aef94a0d33a5
1/**
2 * Copyright (c) 2017, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.os;
18
19/**
20  * Binder interface to communicate with the statistics management service.
21  * {@hide}
22  */
23interface IStatsManager {
24    /**
25     * Tell the stats daemon that the android system server is up and running.
26     */
27    oneway void systemRunning();
28
29    /**
30     * Tell the stats daemon that the StatsCompanionService is up and running.
31     * Two-way binder call so that caller knows message received.
32     */
33    void statsCompanionReady();
34
35    /**
36     * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and
37     * act accordingly.
38     * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
39     */
40    void informAnomalyAlarmFired();
41
42    /**
43     * Tells statsd that it is time to poll some stats. Statsd will be responsible for determing
44     * what stats to poll and initiating the polling.
45     * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
46     */
47    void informPollAlarmFired();
48
49    /**
50     * Tells statsd to store data to disk.
51     */
52    void writeDataToDisk();
53
54    /**
55     * Inform statsd what the version and package are for each uid. Note that each array should
56     * have the same number of elements, and version[i] and package[i] correspond to uid[i].
57     */
58    oneway void informAllUidData(in int[] uid, in long[] version, in String[] app);
59
60    /**
61     * Inform statsd what the uid and version are for one app that was updated.
62     */
63    oneway void informOnePackage(in String app, in int uid, in long version);
64
65    /**
66     * Inform stats that an app was removed.
67     */
68    oneway void informOnePackageRemoved(in String app, in int uid);
69
70    /**
71     * Fetches data for the specified configuration key. Returns a byte array representing proto
72     * wire-encoded of ConfigMetricsReportList.
73     */
74    byte[] getData(in long key);
75
76    /**
77     * Fetches metadata across statsd. Returns byte array representing wire-encoded proto.
78     */
79    byte[] getMetadata();
80
81    /**
82     * Sets a configuration with the specified config key and subscribes to updates for this
83     * configuration key. Broadcasts will be sent if this configuration needs to be collected.
84     * The configuration must be a wire-encoded StatsDConfig. The receiver for this data is
85     * registered in a separate function.
86     *
87     * Returns if this configuration was correctly registered.
88     */
89    boolean addConfiguration(in long configKey, in byte[] config);
90
91    /**
92     * Registers the given pending intent for this config key. This intent is invoked when the
93     * memory consumed by the metrics for this configuration approach the pre-defined limits. There
94     * can be at most one listener per config key.
95     *
96     * Returns if this listener was correctly registered.
97     */
98    boolean setDataFetchOperation(long configKey, in IBinder intentSender);
99
100    /**
101     * Removes the data fetch operation for the specified configuration.
102     */
103    boolean removeDataFetchOperation(long configKey);
104
105    /**
106     * Removes the configuration with the matching config key. No-op if this config key does not
107     * exist.
108     *
109     * Returns if this configuration key was removed.
110     */
111    boolean removeConfiguration(in long configKey);
112
113    /**
114     * Set the IIntentSender (i.e. PendingIntent) to be used when broadcasting subscriber
115     * information to the given subscriberId within the given config.
116     *
117     * Suppose that the calling uid has added a config with key configKey, and that in this config
118     * it is specified that when a particular anomaly is detected, a broadcast should be sent to
119     * a BroadcastSubscriber with id subscriberId. This function links the given intentSender with
120     * that subscriberId (for that config), so that this intentSender is used to send the broadcast
121     * when the anomaly is detected.
122     *
123     * This function can only be called by the owner (uid) of the config. It must be called each
124     * time statsd starts. Later calls overwrite previous calls; only one intentSender is stored.
125     *
126     * intentSender must be convertible into an IntentSender using IntentSender(IBinder)
127     * and cannot be null.
128     *
129     * Returns true if successful.
130     */
131    boolean setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender);
132
133    /**
134     * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair.
135     * Any broadcasts associated with subscriberId will henceforth not be sent.
136     * No-op if this (configKey, subsriberId) pair was not associated with an IntentSender.
137     *
138     * Returns true if successful.
139     */
140    boolean unsetBroadcastSubscriber(long configKey, long subscriberId);
141}
142