blob: 29871b6cf017c677f612a2ab924492e9ae5b00fe [file] [log] [blame]
Joe Onorato5dcbc6c2017-08-29 15:13:58 -07001/**
yro947fbce2017-11-15 22:50:23 -08002 * Copyright (c) 2017, The Android Open Source Project
Joe Onorato5dcbc6c2017-08-29 15:13:58 -07003 *
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
Tej Singha0c89dd2019-01-25 16:39:18 -080019import android.os.IStatsPullerCallback;
Tej Singh59184292019-10-11 11:07:06 -070020import android.os.IPullAtomCallback;
Max Dashouk11e0d402019-05-16 16:58:07 -070021import android.os.ParcelFileDescriptor;
Tej Singha0c89dd2019-01-25 16:39:18 -080022
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070023/**
Bookatz1b0b1142017-09-08 11:58:42 -070024 * Binder interface to communicate with the statistics management service.
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070025 * {@hide}
26 */
Bookatzb487b552017-09-18 11:26:01 -070027interface IStatsManager {
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070028 /**
Bookatz1b0b1142017-09-08 11:58:42 -070029 * Tell the stats daemon that the android system server is up and running.
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070030 */
Bookatzb487b552017-09-18 11:26:01 -070031 oneway void systemRunning();
32
33 /**
34 * Tell the stats daemon that the StatsCompanionService is up and running.
35 * Two-way binder call so that caller knows message received.
36 */
37 void statsCompanionReady();
Bookatz1b0b1142017-09-08 11:58:42 -070038
39 /**
40 * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and
41 * act accordingly.
Bookatzb487b552017-09-18 11:26:01 -070042 * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
Bookatz1b0b1142017-09-08 11:58:42 -070043 */
44 void informAnomalyAlarmFired();
45
Bookatzb487b552017-09-18 11:26:01 -070046 /**
47 * Tells statsd that it is time to poll some stats. Statsd will be responsible for determing
Bookatz1b0b1142017-09-08 11:58:42 -070048 * what stats to poll and initiating the polling.
Bookatzb487b552017-09-18 11:26:01 -070049 * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
Bookatz1b0b1142017-09-08 11:58:42 -070050 */
51 void informPollAlarmFired();
David Chende701692017-10-05 13:16:02 -070052
53 /**
Yangster-mac932ecec2018-02-01 10:23:52 -080054 * Tells statsd that it is time to handle periodic alarms. Statsd will be responsible for
55 * determing what alarm subscriber to trigger.
56 * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
57 */
58 void informAlarmForSubscriberTriggeringFired();
59
60 /**
Chenjie Yue36018b2018-04-16 15:18:30 -070061 * Tells statsd that the device is about to shutdown.
yro947fbce2017-11-15 22:50:23 -080062 */
Yangster-mac892f3d32018-05-02 14:16:48 -070063 void informDeviceShutdown();
yro947fbce2017-11-15 22:50:23 -080064
65 /**
Max Dashouk11e0d402019-05-16 16:58:07 -070066 * Inform statsd about a file descriptor for a pipe through which we will pipe version
67 * and package information for each uid.
68 * Versions and package information are supplied via UidData proto where info for each app
69 * is captured in its own element of a repeated ApplicationInfo message.
David Chende701692017-10-05 13:16:02 -070070 */
Max Dashouk11e0d402019-05-16 16:58:07 -070071 oneway void informAllUidData(in ParcelFileDescriptor fd);
David Chende701692017-10-05 13:16:02 -070072
73 /**
dwchen730403e2018-10-29 11:41:56 -070074 * Inform statsd what the uid, version, version_string, and installer are for one app that was
75 * updated.
David Chende701692017-10-05 13:16:02 -070076 */
dwchen730403e2018-10-29 11:41:56 -070077 oneway void informOnePackage(in String app, in int uid, in long version,
78 in String version_string, in String installer);
David Chende701692017-10-05 13:16:02 -070079
80 /**
81 * Inform stats that an app was removed.
82 */
83 oneway void informOnePackageRemoved(in String app, in int uid);
yro31eb67b2017-10-24 13:33:21 -070084
85 /**
David Chenadaf8b32017-11-03 15:42:08 -070086 * Fetches data for the specified configuration key. Returns a byte array representing proto
David Chen2e8f3802017-11-22 10:56:48 -080087 * wire-encoded of ConfigMetricsReportList.
Bookatz4f716292018-04-10 17:15:12 -070088 *
89 * Requires Manifest.permission.DUMP.
yro31eb67b2017-10-24 13:33:21 -070090 */
Jeff Sharkey6b649252018-04-16 09:50:22 -060091 byte[] getData(in long key, in String packageName);
yro31eb67b2017-10-24 13:33:21 -070092
93 /**
David Chen2e8f3802017-11-22 10:56:48 -080094 * Fetches metadata across statsd. Returns byte array representing wire-encoded proto.
Bookatz4f716292018-04-10 17:15:12 -070095 *
96 * Requires Manifest.permission.DUMP.
David Chen2e8f3802017-11-22 10:56:48 -080097 */
Jeff Sharkey6b649252018-04-16 09:50:22 -060098 byte[] getMetadata(in String packageName);
David Chen2e8f3802017-11-22 10:56:48 -080099
100 /**
David Chenadaf8b32017-11-03 15:42:08 -0700101 * Sets a configuration with the specified config key and subscribes to updates for this
102 * configuration key. Broadcasts will be sent if this configuration needs to be collected.
Bookatz4f716292018-04-10 17:15:12 -0700103 * The configuration must be a wire-encoded StatsdConfig. The receiver for this data is
David Chen661f7912018-01-22 17:46:24 -0800104 * registered in a separate function.
David Chenadaf8b32017-11-03 15:42:08 -0700105 *
Bookatz4f716292018-04-10 17:15:12 -0700106 * Requires Manifest.permission.DUMP.
yro31eb67b2017-10-24 13:33:21 -0700107 */
Jeff Sharkey6b649252018-04-16 09:50:22 -0600108 void addConfiguration(in long configKey, in byte[] config, in String packageName);
David Chen661f7912018-01-22 17:46:24 -0800109
110 /**
111 * Registers the given pending intent for this config key. This intent is invoked when the
112 * memory consumed by the metrics for this configuration approach the pre-defined limits. There
113 * can be at most one listener per config key.
114 *
Bookatz4f716292018-04-10 17:15:12 -0700115 * Requires Manifest.permission.DUMP.
David Chen661f7912018-01-22 17:46:24 -0800116 */
Jeff Sharkey6b649252018-04-16 09:50:22 -0600117 void setDataFetchOperation(long configKey, in IBinder intentSender, in String packageName);
David Chen661f7912018-01-22 17:46:24 -0800118
119 /**
120 * Removes the data fetch operation for the specified configuration.
Bookatz4f716292018-04-10 17:15:12 -0700121 *
122 * Requires Manifest.permission.DUMP.
David Chen661f7912018-01-22 17:46:24 -0800123 */
Jeff Sharkey6b649252018-04-16 09:50:22 -0600124 void removeDataFetchOperation(long configKey, in String packageName);
David Chenadaf8b32017-11-03 15:42:08 -0700125
126 /**
Tej Singh2c9ef2a2019-01-22 11:33:51 -0800127 * Registers the given pending intent for this packagename. This intent is invoked when the
128 * active status of any of the configs sent by this package changes and will contain a list of
129 * config ids that are currently active. It also returns the list of configs that are currently
130 * active. There can be at most one active configs changed listener per package.
131 *
132 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
133 */
134 long[] setActiveConfigsChangedOperation(in IBinder intentSender, in String packageName);
135
136 /**
137 * Removes the active configs changed operation for the specified package name.
138 *
139 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
140 */
141 void removeActiveConfigsChangedOperation(in String packageName);
142
143 /**
David Chenadaf8b32017-11-03 15:42:08 -0700144 * Removes the configuration with the matching config key. No-op if this config key does not
145 * exist.
146 *
Bookatz4f716292018-04-10 17:15:12 -0700147 * Requires Manifest.permission.DUMP.
David Chenadaf8b32017-11-03 15:42:08 -0700148 */
Jeff Sharkey6b649252018-04-16 09:50:22 -0600149 void removeConfiguration(in long configKey, in String packageName);
Bookatzc6977972018-01-16 16:55:05 -0800150
151 /**
152 * Set the IIntentSender (i.e. PendingIntent) to be used when broadcasting subscriber
153 * information to the given subscriberId within the given config.
154 *
155 * Suppose that the calling uid has added a config with key configKey, and that in this config
156 * it is specified that when a particular anomaly is detected, a broadcast should be sent to
157 * a BroadcastSubscriber with id subscriberId. This function links the given intentSender with
158 * that subscriberId (for that config), so that this intentSender is used to send the broadcast
159 * when the anomaly is detected.
160 *
161 * This function can only be called by the owner (uid) of the config. It must be called each
162 * time statsd starts. Later calls overwrite previous calls; only one intentSender is stored.
163 *
164 * intentSender must be convertible into an IntentSender using IntentSender(IBinder)
165 * and cannot be null.
166 *
Bookatz4f716292018-04-10 17:15:12 -0700167 * Requires Manifest.permission.DUMP.
Bookatzc6977972018-01-16 16:55:05 -0800168 */
Jeff Sharkey6b649252018-04-16 09:50:22 -0600169 void setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender,
170 in String packageName);
Bookatzc6977972018-01-16 16:55:05 -0800171
172 /**
173 * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair.
174 * Any broadcasts associated with subscriberId will henceforth not be sent.
175 * No-op if this (configKey, subsriberId) pair was not associated with an IntentSender.
176 *
Bookatz4f716292018-04-10 17:15:12 -0700177 * Requires Manifest.permission.DUMP.
Bookatzc6977972018-01-16 16:55:05 -0800178 */
Jeff Sharkey6b649252018-04-16 09:50:22 -0600179 void unsetBroadcastSubscriber(long configKey, long subscriberId, in String packageName);
yrobe6d7f92018-05-04 13:02:53 -0700180
181 /**
182 * Apps can send an atom via this application breadcrumb with the specified label and state for
183 * this label. This allows building custom metrics and predicates.
184 */
185 void sendAppBreadcrumbAtom(int label, int state);
Tej Singha0c89dd2019-01-25 16:39:18 -0800186
187 /**
188 * Registers a puller callback function that, when invoked, pulls the data
189 * for the specified vendor atom tag.
190 *
191 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS
Tej Singh59184292019-10-11 11:07:06 -0700192 * @deprecated please use registerPullAtomCallback.
Tej Singha0c89dd2019-01-25 16:39:18 -0800193 */
194 oneway void registerPullerCallback(int atomTag, IStatsPullerCallback pullerCallback,
195 String packageName);
196
197 /**
Tej Singh59184292019-10-11 11:07:06 -0700198 * Registers a puller callback function that, when invoked, pulls the data
199 * for the specified atom tag.
200 */
201 oneway void registerPullAtomCallback(int uid, int atomTag, long coolDownNs, long timeoutNs,
202 in int[] additiveFields, IPullAtomCallback pullerCallback);
203
204 /**
Tej Singha0c89dd2019-01-25 16:39:18 -0800205 * Unregisters a puller callback function for the given vendor atom.
206 *
207 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS
208 */
209 oneway void unregisterPullerCallback(int atomTag, String packageName);
Chenjie Yu6b1667c2019-01-18 10:09:33 -0800210
211 /**
212 * The install requires staging.
213 */
214 const int FLAG_REQUIRE_STAGING = 0x01;
215
216 /**
217 * Rollback is enabled with this install.
218 */
219 const int FLAG_ROLLBACK_ENABLED = 0x02;
220
221 /**
222 * Requires low latency monitoring.
223 */
224 const int FLAG_REQUIRE_LOW_LATENCY_MONITOR = 0x04;
225
226 /**
227 * Logs an event for binary push for module updates.
228 */
229 oneway void sendBinaryPushStateChangedAtom(in String trainName, in long trainVersionCode,
230 in int options, in int state, in long[] experimentId);
Jeff Hamiltonfa2f91c2019-03-22 00:25:02 -0400231
232 /**
Tej Singh73f8e9b2019-05-19 16:52:38 -0700233 * Logs an event for watchdog rollbacks.
234 */
235 oneway void sendWatchdogRollbackOccurredAtom(in int rollbackType, in String packageName,
236 in long packageVersionCode);
237
238 /**
Jeff Hamiltonfa2f91c2019-03-22 00:25:02 -0400239 * Returns the most recently registered experiment IDs.
240 */
241 long[] getRegisteredExperimentIds();
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700242}