Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 1 | /** |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 2 | * Copyright (c) 2017, The Android Open Source Project |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 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 | |
Tej Singh | a0c89dd | 2019-01-25 16:39:18 -0800 | [diff] [blame] | 19 | import android.os.IStatsPullerCallback; |
Tej Singh | 5918429 | 2019-10-11 11:07:06 -0700 | [diff] [blame] | 20 | import android.os.IPullAtomCallback; |
Max Dashouk | 11e0d40 | 2019-05-16 16:58:07 -0700 | [diff] [blame] | 21 | import android.os.ParcelFileDescriptor; |
Tej Singh | a0c89dd | 2019-01-25 16:39:18 -0800 | [diff] [blame] | 22 | |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 23 | /** |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 24 | * Binder interface to communicate with the statistics management service. |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 25 | * {@hide} |
| 26 | */ |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 27 | interface IStatsManager { |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 28 | /** |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 29 | * Tell the stats daemon that the android system server is up and running. |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 30 | */ |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 31 | 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(); |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and |
| 41 | * act accordingly. |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 42 | * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 43 | */ |
| 44 | void informAnomalyAlarmFired(); |
| 45 | |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Tells statsd that it is time to poll some stats. Statsd will be responsible for determing |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 48 | * what stats to poll and initiating the polling. |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 49 | * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 50 | */ |
| 51 | void informPollAlarmFired(); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 52 | |
| 53 | /** |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 54 | * 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 Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 61 | * Tells statsd that the device is about to shutdown. |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 62 | */ |
Yangster-mac | 892f3d3 | 2018-05-02 14:16:48 -0700 | [diff] [blame] | 63 | void informDeviceShutdown(); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 64 | |
| 65 | /** |
Max Dashouk | 11e0d40 | 2019-05-16 16:58:07 -0700 | [diff] [blame] | 66 | * 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 Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 70 | */ |
Max Dashouk | 11e0d40 | 2019-05-16 16:58:07 -0700 | [diff] [blame] | 71 | oneway void informAllUidData(in ParcelFileDescriptor fd); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
dwchen | 730403e | 2018-10-29 11:41:56 -0700 | [diff] [blame] | 74 | * Inform statsd what the uid, version, version_string, and installer are for one app that was |
| 75 | * updated. |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 76 | */ |
dwchen | 730403e | 2018-10-29 11:41:56 -0700 | [diff] [blame] | 77 | oneway void informOnePackage(in String app, in int uid, in long version, |
| 78 | in String version_string, in String installer); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
| 81 | * Inform stats that an app was removed. |
| 82 | */ |
| 83 | oneway void informOnePackageRemoved(in String app, in int uid); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 86 | * Fetches data for the specified configuration key. Returns a byte array representing proto |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 87 | * wire-encoded of ConfigMetricsReportList. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 88 | * |
| 89 | * Requires Manifest.permission.DUMP. |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 90 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 91 | byte[] getData(in long key, in String packageName); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 94 | * Fetches metadata across statsd. Returns byte array representing wire-encoded proto. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 95 | * |
| 96 | * Requires Manifest.permission.DUMP. |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 97 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 98 | byte[] getMetadata(in String packageName); |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 99 | |
| 100 | /** |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 101 | * 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. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 103 | * The configuration must be a wire-encoded StatsdConfig. The receiver for this data is |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 104 | * registered in a separate function. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 105 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 106 | * Requires Manifest.permission.DUMP. |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 107 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 108 | void addConfiguration(in long configKey, in byte[] config, in String packageName); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 109 | |
| 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 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 115 | * Requires Manifest.permission.DUMP. |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 116 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 117 | void setDataFetchOperation(long configKey, in IBinder intentSender, in String packageName); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * Removes the data fetch operation for the specified configuration. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 121 | * |
| 122 | * Requires Manifest.permission.DUMP. |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 123 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 124 | void removeDataFetchOperation(long configKey, in String packageName); |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
Tej Singh | 2c9ef2a | 2019-01-22 11:33:51 -0800 | [diff] [blame] | 127 | * 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 Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 144 | * Removes the configuration with the matching config key. No-op if this config key does not |
| 145 | * exist. |
| 146 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 147 | * Requires Manifest.permission.DUMP. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 148 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 149 | void removeConfiguration(in long configKey, in String packageName); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 150 | |
| 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 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 167 | * Requires Manifest.permission.DUMP. |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 168 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 169 | void setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender, |
| 170 | in String packageName); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 171 | |
| 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 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 177 | * Requires Manifest.permission.DUMP. |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 178 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 179 | void unsetBroadcastSubscriber(long configKey, long subscriberId, in String packageName); |
yro | be6d7f9 | 2018-05-04 13:02:53 -0700 | [diff] [blame] | 180 | |
| 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 Singh | a0c89dd | 2019-01-25 16:39:18 -0800 | [diff] [blame] | 186 | |
| 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 Singh | 5918429 | 2019-10-11 11:07:06 -0700 | [diff] [blame] | 192 | * @deprecated please use registerPullAtomCallback. |
Tej Singh | a0c89dd | 2019-01-25 16:39:18 -0800 | [diff] [blame] | 193 | */ |
| 194 | oneway void registerPullerCallback(int atomTag, IStatsPullerCallback pullerCallback, |
| 195 | String packageName); |
| 196 | |
| 197 | /** |
Tej Singh | 5918429 | 2019-10-11 11:07:06 -0700 | [diff] [blame] | 198 | * 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 Singh | a0c89dd | 2019-01-25 16:39:18 -0800 | [diff] [blame] | 205 | * 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 Yu | 6b1667c | 2019-01-18 10:09:33 -0800 | [diff] [blame] | 210 | |
| 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 Hamilton | fa2f91c | 2019-03-22 00:25:02 -0400 | [diff] [blame] | 231 | |
| 232 | /** |
Tej Singh | 73f8e9b | 2019-05-19 16:52:38 -0700 | [diff] [blame] | 233 | * Logs an event for watchdog rollbacks. |
| 234 | */ |
| 235 | oneway void sendWatchdogRollbackOccurredAtom(in int rollbackType, in String packageName, |
| 236 | in long packageVersionCode); |
| 237 | |
| 238 | /** |
Jeff Hamilton | fa2f91c | 2019-03-22 00:25:02 -0400 | [diff] [blame] | 239 | * Returns the most recently registered experiment IDs. |
| 240 | */ |
| 241 | long[] getRegisteredExperimentIds(); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 242 | } |