• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package android.os;
18 
19 import android.os.IPendingIntentRef;
20 import android.os.IPullAtomCallback;
21 import android.os.ParcelFileDescriptor;
22 
23 /**
24   * Binder interface to communicate with the statistics management service.
25   * {@hide}
26   */
27 interface IStatsd {
28     /**
29      * Tell the stats daemon that the android system server is up and running.
30      */
systemRunning()31     oneway void systemRunning();
32 
33     /**
34      * Tell the stats daemon that the android system has finished booting.
35      */
bootCompleted()36     oneway void bootCompleted();
37 
38     /**
39      * Tell the stats daemon that the StatsCompanionService is up and running.
40      * Two-way binder call so that caller knows message received.
41      */
statsCompanionReady()42     void statsCompanionReady();
43 
44     /**
45      * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and
46      * act accordingly.
47      * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
48      */
informAnomalyAlarmFired()49     void informAnomalyAlarmFired();
50 
51     /**
52      * Tells statsd that it is time to poll some stats. Statsd will be responsible for determing
53      * what stats to poll and initiating the polling.
54      * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
55      */
informPollAlarmFired()56     void informPollAlarmFired();
57 
58     /**
59      * Tells statsd that it is time to handle periodic alarms. Statsd will be responsible for
60      * determing what alarm subscriber to trigger.
61      * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
62      */
informAlarmForSubscriberTriggeringFired()63     void informAlarmForSubscriberTriggeringFired();
64 
65     /**
66      * Tells statsd that the device is about to shutdown.
67      */
informDeviceShutdown()68     void informDeviceShutdown();
69 
70     /**
71      * Inform statsd about a file descriptor for a pipe through which we will pipe version
72      * and package information for each uid.
73      * Versions and package information are supplied via UidData proto where info for each app
74      * is captured in its own element of a repeated ApplicationInfo message.
75      */
informAllUidData(in ParcelFileDescriptor fd)76     oneway void informAllUidData(in ParcelFileDescriptor fd);
77 
78     /**
79      * Inform statsd what the uid, version, version_string, and installer are for one app that was
80      * updated.
81      */
informOnePackage(in String app, in int uid, in long version, in String version_string, in String installer)82     oneway void informOnePackage(in String app, in int uid, in long version,
83         in String version_string, in String installer);
84 
85     /**
86      * Inform stats that an app was removed.
87      */
informOnePackageRemoved(in String app, in int uid)88     oneway void informOnePackageRemoved(in String app, in int uid);
89 
90     /**
91      * Fetches data for the specified configuration key. Returns a byte array representing proto
92      * wire-encoded of ConfigMetricsReportList.
93      *
94      * Requires Manifest.permission.DUMP.
95      */
getData(in long key, int callingUid)96     byte[] getData(in long key, int callingUid);
97 
98     /**
99      * Fetches metadata across statsd. Returns byte array representing wire-encoded proto.
100      *
101      * Requires Manifest.permission.DUMP.
102      */
getMetadata()103     byte[] getMetadata();
104 
105     /**
106      * Sets a configuration with the specified config id and subscribes to updates for this
107      * configuration key. Broadcasts will be sent if this configuration needs to be collected.
108      * The configuration must be a wire-encoded StatsdConfig. The receiver for this data is
109      * registered in a separate function.
110      *
111      * Requires Manifest.permission.DUMP.
112      */
addConfiguration(in long configId, in byte[] config, in int callingUid)113     void addConfiguration(in long configId, in byte[] config, in int callingUid);
114 
115     /**
116      * Registers the given pending intent for this config key. This intent is invoked when the
117      * memory consumed by the metrics for this configuration approach the pre-defined limits. There
118      * can be at most one listener per config key.
119      *
120      * Requires Manifest.permission.DUMP.
121      */
setDataFetchOperation(long configId, in IPendingIntentRef pendingIntentRef, int callingUid)122     void setDataFetchOperation(long configId, in IPendingIntentRef pendingIntentRef,
123                                int callingUid);
124 
125     /**
126      * Removes the data fetch operation for the specified configuration.
127      *
128      * Requires Manifest.permission.DUMP.
129      */
removeDataFetchOperation(long configId, int callingUid)130     void removeDataFetchOperation(long configId, int callingUid);
131 
132     /**
133      * Registers the given pending intent for this packagename. This intent is invoked when the
134      * active status of any of the configs sent by this package changes and will contain a list of
135      * config ids that are currently active. It also returns the list of configs that are currently
136      * active. There can be at most one active configs changed listener per package.
137      *
138      * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
139      */
setActiveConfigsChangedOperation(in IPendingIntentRef pendingIntentRef, int callingUid)140     long[] setActiveConfigsChangedOperation(in IPendingIntentRef pendingIntentRef, int callingUid);
141 
142     /**
143      * Removes the active configs changed operation for the specified package name.
144      *
145      * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
146      */
removeActiveConfigsChangedOperation(int callingUid)147     void removeActiveConfigsChangedOperation(int callingUid);
148 
149     /**
150      * Removes the configuration with the matching config id. No-op if this config id does not
151      * exist.
152      *
153      * Requires Manifest.permission.DUMP.
154      */
removeConfiguration(in long configId, in int callingUid)155     void removeConfiguration(in long configId, in int callingUid);
156 
157     /**
158      * Set the PendingIntentRef to be used when broadcasting subscriber
159      * information to the given subscriberId within the given config.
160      *
161      * Suppose that the calling uid has added a config with key configId, and that in this config
162      * it is specified that when a particular anomaly is detected, a broadcast should be sent to
163      * a BroadcastSubscriber with id subscriberId. This function links the given pendingIntent with
164      * that subscriberId (for that config), so that this pendingIntent is used to send the broadcast
165      * when the anomaly is detected.
166      *
167      * This function can only be called by the owner (uid) of the config. It must be called each
168      * time statsd starts. Later calls overwrite previous calls; only one pendingIntent is stored.
169      *
170      * Requires Manifest.permission.DUMP.
171      */
setBroadcastSubscriber(long configId, long subscriberId, in IPendingIntentRef pir, int callingUid)172     void setBroadcastSubscriber(long configId, long subscriberId, in IPendingIntentRef pir,
173                                 int callingUid);
174 
175     /**
176      * Undoes setBroadcastSubscriber() for the (configId, subscriberId) pair.
177      * Any broadcasts associated with subscriberId will henceforth not be sent.
178      * No-op if this (configKey, subscriberId) pair was not associated with an PendingIntentRef.
179      *
180      * Requires Manifest.permission.DUMP.
181      */
unsetBroadcastSubscriber(long configId, long subscriberId, int callingUid)182     void unsetBroadcastSubscriber(long configId, long subscriberId, int callingUid);
183 
184     /**
185      * Tell the stats daemon that all the pullers registered during boot have been sent.
186      */
allPullersFromBootRegistered()187     oneway void allPullersFromBootRegistered();
188 
189     /**
190      * Registers a puller callback function that, when invoked, pulls the data
191      * for the specified atom tag.
192      */
registerPullAtomCallback(int uid, int atomTag, long coolDownMillis, long timeoutMillis,in int[] additiveFields, IPullAtomCallback pullerCallback)193     oneway void registerPullAtomCallback(int uid, int atomTag, long coolDownMillis,
194                                          long timeoutMillis,in int[] additiveFields,
195                                          IPullAtomCallback pullerCallback);
196 
197     /**
198      * Registers a puller callback function that, when invoked, pulls the data
199      * for the specified atom tag.
200      *
201      * Enforces the REGISTER_STATS_PULL_ATOM permission.
202      */
registerNativePullAtomCallback(int atomTag, long coolDownMillis, long timeoutMillis, in int[] additiveFields, IPullAtomCallback pullerCallback)203     oneway void registerNativePullAtomCallback(int atomTag, long coolDownMillis, long timeoutMillis,
204                            in int[] additiveFields, IPullAtomCallback pullerCallback);
205 
206     /**
207      * Unregisters any pullAtomCallback for the given uid/atom.
208      */
unregisterPullAtomCallback(int uid, int atomTag)209     oneway void unregisterPullAtomCallback(int uid, int atomTag);
210 
211     /**
212      * Unregisters any pullAtomCallback for the given atom + caller.
213      *
214      * Enforces the REGISTER_STATS_PULL_ATOM permission.
215      */
unregisterNativePullAtomCallback(int atomTag)216     oneway void unregisterNativePullAtomCallback(int atomTag);
217 
218     /**
219      * The install requires staging.
220      */
221     const int FLAG_REQUIRE_STAGING = 0x01;
222 
223     /**
224      * Rollback is enabled with this install.
225      */
226     const int FLAG_ROLLBACK_ENABLED = 0x02;
227 
228     /**
229      * Requires low latency monitoring.
230      */
231     const int FLAG_REQUIRE_LOW_LATENCY_MONITOR = 0x04;
232 
233     /**
234      * Returns the most recently registered experiment IDs.
235      */
getRegisteredExperimentIds()236     long[] getRegisteredExperimentIds();
237 }
238