IStatsManager.aidl revision 661f791a2580515eee5882ab9498aef94a0d33a5
15dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato/** 2947fbce521d9e8377df03e3c1c31884ed5577f32yro * Copyright (c) 2017, The Android Open Source Project 35dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * 45dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * Licensed under the Apache License, Version 2.0 (the "License"); 55dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * you may not use this file except in compliance with the License. 65dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * You may obtain a copy of the License at 75dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * 85dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * http://www.apache.org/licenses/LICENSE-2.0 95dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * 105dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * Unless required by applicable law or agreed to in writing, software 115dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * distributed under the License is distributed on an "AS IS" BASIS, 125dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * See the License for the specific language governing permissions and 145dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * limitations under the License. 155dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato */ 165dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato 175dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onoratopackage android.os; 185dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato 195dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato/** 201b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz * Binder interface to communicate with the statistics management service. 215dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato * {@hide} 225dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato */ 23b487b5533eba8635232009c7f32a54a0380a532dBookatzinterface IStatsManager { 245dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato /** 251b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz * Tell the stats daemon that the android system server is up and running. 265dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato */ 27b487b5533eba8635232009c7f32a54a0380a532dBookatz oneway void systemRunning(); 28b487b5533eba8635232009c7f32a54a0380a532dBookatz 29b487b5533eba8635232009c7f32a54a0380a532dBookatz /** 30b487b5533eba8635232009c7f32a54a0380a532dBookatz * Tell the stats daemon that the StatsCompanionService is up and running. 31b487b5533eba8635232009c7f32a54a0380a532dBookatz * Two-way binder call so that caller knows message received. 32b487b5533eba8635232009c7f32a54a0380a532dBookatz */ 33b487b5533eba8635232009c7f32a54a0380a532dBookatz void statsCompanionReady(); 341b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz 351b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz /** 361b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and 371b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz * act accordingly. 38b487b5533eba8635232009c7f32a54a0380a532dBookatz * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. 391b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz */ 401b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz void informAnomalyAlarmFired(); 411b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz 42b487b5533eba8635232009c7f32a54a0380a532dBookatz /** 43b487b5533eba8635232009c7f32a54a0380a532dBookatz * Tells statsd that it is time to poll some stats. Statsd will be responsible for determing 441b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz * what stats to poll and initiating the polling. 45b487b5533eba8635232009c7f32a54a0380a532dBookatz * Two-way binder call so that caller's method (and corresponding wakelocks) will linger. 461b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz */ 471b0b114abca0a7c7642b0b7de343e1e2f982ebf0Bookatz void informPollAlarmFired(); 48de70169109c57787a23c732ec4b361ade2e9850eDavid Chen 49de70169109c57787a23c732ec4b361ade2e9850eDavid Chen /** 50947fbce521d9e8377df03e3c1c31884ed5577f32yro * Tells statsd to store data to disk. 51947fbce521d9e8377df03e3c1c31884ed5577f32yro */ 52947fbce521d9e8377df03e3c1c31884ed5577f32yro void writeDataToDisk(); 53947fbce521d9e8377df03e3c1c31884ed5577f32yro 54947fbce521d9e8377df03e3c1c31884ed5577f32yro /** 55de70169109c57787a23c732ec4b361ade2e9850eDavid Chen * Inform statsd what the version and package are for each uid. Note that each array should 56de70169109c57787a23c732ec4b361ade2e9850eDavid Chen * have the same number of elements, and version[i] and package[i] correspond to uid[i]. 57de70169109c57787a23c732ec4b361ade2e9850eDavid Chen */ 583accca05ddcad9d0b1b313eae49f273e39121d3cDianne Hackborn oneway void informAllUidData(in int[] uid, in long[] version, in String[] app); 59de70169109c57787a23c732ec4b361ade2e9850eDavid Chen 60de70169109c57787a23c732ec4b361ade2e9850eDavid Chen /** 61de70169109c57787a23c732ec4b361ade2e9850eDavid Chen * Inform statsd what the uid and version are for one app that was updated. 62de70169109c57787a23c732ec4b361ade2e9850eDavid Chen */ 633accca05ddcad9d0b1b313eae49f273e39121d3cDianne Hackborn oneway void informOnePackage(in String app, in int uid, in long version); 64de70169109c57787a23c732ec4b361ade2e9850eDavid Chen 65de70169109c57787a23c732ec4b361ade2e9850eDavid Chen /** 66de70169109c57787a23c732ec4b361ade2e9850eDavid Chen * Inform stats that an app was removed. 67de70169109c57787a23c732ec4b361ade2e9850eDavid Chen */ 68de70169109c57787a23c732ec4b361ade2e9850eDavid Chen oneway void informOnePackageRemoved(in String app, in int uid); 6931eb67b3498d326659b2b164ff367a01a793d641yro 7031eb67b3498d326659b2b164ff367a01a793d641yro /** 71adaf8b344e312853530e276ceff05783133ecf17David Chen * Fetches data for the specified configuration key. Returns a byte array representing proto 722e8f3807379f5d5d151ad2cb434d8a7aca910238David Chen * wire-encoded of ConfigMetricsReportList. 7331eb67b3498d326659b2b164ff367a01a793d641yro */ 7494e197cceb2ba7df13ff8de04f60bfeec64015d9Yangster-mac byte[] getData(in long key); 7531eb67b3498d326659b2b164ff367a01a793d641yro 7631eb67b3498d326659b2b164ff367a01a793d641yro /** 772e8f3807379f5d5d151ad2cb434d8a7aca910238David Chen * Fetches metadata across statsd. Returns byte array representing wire-encoded proto. 782e8f3807379f5d5d151ad2cb434d8a7aca910238David Chen */ 792e8f3807379f5d5d151ad2cb434d8a7aca910238David Chen byte[] getMetadata(); 802e8f3807379f5d5d151ad2cb434d8a7aca910238David Chen 812e8f3807379f5d5d151ad2cb434d8a7aca910238David Chen /** 82adaf8b344e312853530e276ceff05783133ecf17David Chen * Sets a configuration with the specified config key and subscribes to updates for this 83adaf8b344e312853530e276ceff05783133ecf17David Chen * configuration key. Broadcasts will be sent if this configuration needs to be collected. 84661f791a2580515eee5882ab9498aef94a0d33a5David Chen * The configuration must be a wire-encoded StatsDConfig. The receiver for this data is 85661f791a2580515eee5882ab9498aef94a0d33a5David Chen * registered in a separate function. 86adaf8b344e312853530e276ceff05783133ecf17David Chen * 87adaf8b344e312853530e276ceff05783133ecf17David Chen * Returns if this configuration was correctly registered. 8831eb67b3498d326659b2b164ff367a01a793d641yro */ 89661f791a2580515eee5882ab9498aef94a0d33a5David Chen boolean addConfiguration(in long configKey, in byte[] config); 90661f791a2580515eee5882ab9498aef94a0d33a5David Chen 91661f791a2580515eee5882ab9498aef94a0d33a5David Chen /** 92661f791a2580515eee5882ab9498aef94a0d33a5David Chen * Registers the given pending intent for this config key. This intent is invoked when the 93661f791a2580515eee5882ab9498aef94a0d33a5David Chen * memory consumed by the metrics for this configuration approach the pre-defined limits. There 94661f791a2580515eee5882ab9498aef94a0d33a5David Chen * can be at most one listener per config key. 95661f791a2580515eee5882ab9498aef94a0d33a5David Chen * 96661f791a2580515eee5882ab9498aef94a0d33a5David Chen * Returns if this listener was correctly registered. 97661f791a2580515eee5882ab9498aef94a0d33a5David Chen */ 98661f791a2580515eee5882ab9498aef94a0d33a5David Chen boolean setDataFetchOperation(long configKey, in IBinder intentSender); 99661f791a2580515eee5882ab9498aef94a0d33a5David Chen 100661f791a2580515eee5882ab9498aef94a0d33a5David Chen /** 101661f791a2580515eee5882ab9498aef94a0d33a5David Chen * Removes the data fetch operation for the specified configuration. 102661f791a2580515eee5882ab9498aef94a0d33a5David Chen */ 103661f791a2580515eee5882ab9498aef94a0d33a5David Chen boolean removeDataFetchOperation(long configKey); 104adaf8b344e312853530e276ceff05783133ecf17David Chen 105adaf8b344e312853530e276ceff05783133ecf17David Chen /** 106adaf8b344e312853530e276ceff05783133ecf17David Chen * Removes the configuration with the matching config key. No-op if this config key does not 107adaf8b344e312853530e276ceff05783133ecf17David Chen * exist. 108adaf8b344e312853530e276ceff05783133ecf17David Chen * 109adaf8b344e312853530e276ceff05783133ecf17David Chen * Returns if this configuration key was removed. 110adaf8b344e312853530e276ceff05783133ecf17David Chen */ 11194e197cceb2ba7df13ff8de04f60bfeec64015d9Yangster-mac boolean removeConfiguration(in long configKey); 112c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz 113c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz /** 114c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * Set the IIntentSender (i.e. PendingIntent) to be used when broadcasting subscriber 115c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * information to the given subscriberId within the given config. 116c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * 117c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * Suppose that the calling uid has added a config with key configKey, and that in this config 118c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * it is specified that when a particular anomaly is detected, a broadcast should be sent to 119c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * a BroadcastSubscriber with id subscriberId. This function links the given intentSender with 120c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * that subscriberId (for that config), so that this intentSender is used to send the broadcast 121c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * when the anomaly is detected. 122c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * 123c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * This function can only be called by the owner (uid) of the config. It must be called each 124c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * time statsd starts. Later calls overwrite previous calls; only one intentSender is stored. 125c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * 126c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * intentSender must be convertible into an IntentSender using IntentSender(IBinder) 127c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * and cannot be null. 128c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * 129c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * Returns true if successful. 130c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz */ 131c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz boolean setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender); 132c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz 133c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz /** 134c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair. 135c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * Any broadcasts associated with subscriberId will henceforth not be sent. 136c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * No-op if this (configKey, subsriberId) pair was not associated with an IntentSender. 137c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * 138c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz * Returns true if successful. 139c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz */ 140c697797d43b6932fc7cca1c8d7d850c3fb4d1452Bookatz boolean unsetBroadcastSubscriber(long configKey, long subscriberId); 1415dcbc6c015fd56db9381cb7aff58506e8ebcc150Joe Onorato} 142