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 | |
| 19 | /** |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 20 | * Binder interface to communicate with the statistics management service. |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 21 | * {@hide} |
| 22 | */ |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 23 | interface IStatsManager { |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 24 | /** |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 25 | * 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] | 26 | */ |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 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(); |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and |
| 37 | * act accordingly. |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 38 | * 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] | 39 | */ |
| 40 | void informAnomalyAlarmFired(); |
| 41 | |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 42 | /** |
| 43 | * 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] | 44 | * what stats to poll and initiating the polling. |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 45 | * 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] | 46 | */ |
| 47 | void informPollAlarmFired(); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 50 | * Tells statsd that it is time to handle periodic alarms. Statsd will be responsible for |
| 51 | * determing what alarm subscriber to trigger. |
| 52 | * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. |
| 53 | */ |
| 54 | void informAlarmForSubscriberTriggeringFired(); |
| 55 | |
| 56 | /** |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 57 | * Tells statsd that the device is about to shutdown. |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 58 | */ |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 59 | void informDeviceShutdown(boolean isShutdown); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 60 | |
| 61 | /** |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 62 | * Inform statsd what the version and package are for each uid. Note that each array should |
| 63 | * have the same number of elements, and version[i] and package[i] correspond to uid[i]. |
| 64 | */ |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 65 | oneway void informAllUidData(in int[] uid, in long[] version, in String[] app); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Inform statsd what the uid and version are for one app that was updated. |
| 69 | */ |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 70 | oneway void informOnePackage(in String app, in int uid, in long version); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * Inform stats that an app was removed. |
| 74 | */ |
| 75 | oneway void informOnePackageRemoved(in String app, in int uid); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 78 | * 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] | 79 | * wire-encoded of ConfigMetricsReportList. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 80 | * |
| 81 | * Requires Manifest.permission.DUMP. |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 82 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 83 | byte[] getData(in long key, in String packageName); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 86 | * Fetches metadata across statsd. Returns byte array representing wire-encoded proto. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 87 | * |
| 88 | * Requires Manifest.permission.DUMP. |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 89 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 90 | byte[] getMetadata(in String packageName); |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 91 | |
| 92 | /** |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 93 | * Sets a configuration with the specified config key and subscribes to updates for this |
| 94 | * configuration key. Broadcasts will be sent if this configuration needs to be collected. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 95 | * 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] | 96 | * registered in a separate function. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 97 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 98 | * Requires Manifest.permission.DUMP. |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 99 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 100 | void addConfiguration(in long configKey, in byte[] config, in String packageName); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Registers the given pending intent for this config key. This intent is invoked when the |
| 104 | * memory consumed by the metrics for this configuration approach the pre-defined limits. There |
| 105 | * can be at most one listener per config key. |
| 106 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 107 | * Requires Manifest.permission.DUMP. |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 108 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 109 | void setDataFetchOperation(long configKey, in IBinder intentSender, in String packageName); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * Removes the data fetch operation for the specified configuration. |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 113 | * |
| 114 | * Requires Manifest.permission.DUMP. |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 115 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 116 | void removeDataFetchOperation(long configKey, in String packageName); |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Removes the configuration with the matching config key. No-op if this config key does not |
| 120 | * exist. |
| 121 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 122 | * Requires Manifest.permission.DUMP. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 123 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 124 | void removeConfiguration(in long configKey, in String packageName); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Set the IIntentSender (i.e. PendingIntent) to be used when broadcasting subscriber |
| 128 | * information to the given subscriberId within the given config. |
| 129 | * |
| 130 | * Suppose that the calling uid has added a config with key configKey, and that in this config |
| 131 | * it is specified that when a particular anomaly is detected, a broadcast should be sent to |
| 132 | * a BroadcastSubscriber with id subscriberId. This function links the given intentSender with |
| 133 | * that subscriberId (for that config), so that this intentSender is used to send the broadcast |
| 134 | * when the anomaly is detected. |
| 135 | * |
| 136 | * This function can only be called by the owner (uid) of the config. It must be called each |
| 137 | * time statsd starts. Later calls overwrite previous calls; only one intentSender is stored. |
| 138 | * |
| 139 | * intentSender must be convertible into an IntentSender using IntentSender(IBinder) |
| 140 | * and cannot be null. |
| 141 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 142 | * Requires Manifest.permission.DUMP. |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 143 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 144 | void setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender, |
| 145 | in String packageName); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair. |
| 149 | * Any broadcasts associated with subscriberId will henceforth not be sent. |
| 150 | * No-op if this (configKey, subsriberId) pair was not associated with an IntentSender. |
| 151 | * |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 152 | * Requires Manifest.permission.DUMP. |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 153 | */ |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 154 | void unsetBroadcastSubscriber(long configKey, long subscriberId, in String packageName); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 155 | } |