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 | /** |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 50 | * Tells statsd to store data to disk. |
| 51 | */ |
| 52 | void writeDataToDisk(); |
| 53 | |
| 54 | /** |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 55 | * Inform statsd what the version and package are for each uid. Note that each array should |
| 56 | * have the same number of elements, and version[i] and package[i] correspond to uid[i]. |
| 57 | */ |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 58 | oneway void informAllUidData(in int[] uid, in long[] version, in String[] app); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * Inform statsd what the uid and version are for one app that was updated. |
| 62 | */ |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 63 | oneway void informOnePackage(in String app, in int uid, in long version); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
| 66 | * Inform stats that an app was removed. |
| 67 | */ |
| 68 | oneway void informOnePackageRemoved(in String app, in int uid); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 71 | * 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] | 72 | * wire-encoded of ConfigMetricsReportList. |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 73 | */ |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 74 | byte[] getData(in long key); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 77 | * Fetches metadata across statsd. Returns byte array representing wire-encoded proto. |
| 78 | */ |
| 79 | byte[] getMetadata(); |
| 80 | |
| 81 | /** |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 82 | * Sets a configuration with the specified config key and subscribes to updates for this |
| 83 | * configuration key. Broadcasts will be sent if this configuration needs to be collected. |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 84 | * The configuration must be a wire-encoded StatsDConfig. The receiver for this data is |
| 85 | * registered in a separate function. |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 86 | * |
| 87 | * Returns if this configuration was correctly registered. |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 88 | */ |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 89 | boolean addConfiguration(in long configKey, in byte[] config); |
| 90 | |
| 91 | /** |
| 92 | * Registers the given pending intent for this config key. This intent is invoked when the |
| 93 | * memory consumed by the metrics for this configuration approach the pre-defined limits. There |
| 94 | * can be at most one listener per config key. |
| 95 | * |
| 96 | * Returns if this listener was correctly registered. |
| 97 | */ |
| 98 | boolean setDataFetchOperation(long configKey, in IBinder intentSender); |
| 99 | |
| 100 | /** |
| 101 | * Removes the data fetch operation for the specified configuration. |
| 102 | */ |
| 103 | boolean removeDataFetchOperation(long configKey); |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
| 106 | * Removes the configuration with the matching config key. No-op if this config key does not |
| 107 | * exist. |
| 108 | * |
| 109 | * Returns if this configuration key was removed. |
| 110 | */ |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 111 | boolean removeConfiguration(in long configKey); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Set the IIntentSender (i.e. PendingIntent) to be used when broadcasting subscriber |
| 115 | * information to the given subscriberId within the given config. |
| 116 | * |
| 117 | * Suppose that the calling uid has added a config with key configKey, and that in this config |
| 118 | * it is specified that when a particular anomaly is detected, a broadcast should be sent to |
| 119 | * a BroadcastSubscriber with id subscriberId. This function links the given intentSender with |
| 120 | * that subscriberId (for that config), so that this intentSender is used to send the broadcast |
| 121 | * when the anomaly is detected. |
| 122 | * |
| 123 | * This function can only be called by the owner (uid) of the config. It must be called each |
| 124 | * time statsd starts. Later calls overwrite previous calls; only one intentSender is stored. |
| 125 | * |
| 126 | * intentSender must be convertible into an IntentSender using IntentSender(IBinder) |
| 127 | * and cannot be null. |
| 128 | * |
| 129 | * Returns true if successful. |
| 130 | */ |
| 131 | boolean setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender); |
| 132 | |
| 133 | /** |
| 134 | * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair. |
| 135 | * Any broadcasts associated with subscriberId will henceforth not be sent. |
| 136 | * No-op if this (configKey, subsriberId) pair was not associated with an IntentSender. |
| 137 | * |
| 138 | * Returns true if successful. |
| 139 | */ |
| 140 | boolean unsetBroadcastSubscriber(long configKey, long subscriberId); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 141 | } |