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