1 /** 2 * Copyright (c) 2019, The Android Open Source Project 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 import android.app.PendingIntent; 20 import android.os.IPullAtomCallback; 21 import android.os.IStatsQueryCallback; 22 23 /** 24 * Binder interface to communicate with the Java-based statistics service helper. 25 * Contains parcelable objects available only in Java. 26 * {@hide} 27 */ 28 interface IStatsManagerService { 29 30 /** 31 * Registers the given pending intent for this config key. This intent is invoked when the 32 * memory consumed by the metrics for this configuration approach the pre-defined limits. There 33 * can be at most one listener per config key. 34 * 35 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 36 */ setDataFetchOperation(long configId, in PendingIntent pendingIntent, in String packageName)37 void setDataFetchOperation(long configId, in PendingIntent pendingIntent, 38 in String packageName); 39 40 /** 41 * Removes the data fetch operation for the specified configuration. 42 * 43 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 44 */ removeDataFetchOperation(long configId, in String packageName)45 void removeDataFetchOperation(long configId, in String packageName); 46 47 /** 48 * Registers the given pending intent for this packagename. This intent is invoked when the 49 * active status of any of the configs sent by this package changes and will contain a list of 50 * config ids that are currently active. It also returns the list of configs that are currently 51 * active. There can be at most one active configs changed listener per package. 52 * 53 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 54 */ setActiveConfigsChangedOperation(in PendingIntent pendingIntent, in String packageName)55 long[] setActiveConfigsChangedOperation(in PendingIntent pendingIntent, in String packageName); 56 57 /** 58 * Removes the active configs changed operation for the specified package name. 59 * 60 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 61 */ removeActiveConfigsChangedOperation(in String packageName)62 void removeActiveConfigsChangedOperation(in String packageName); 63 64 /** 65 * Set the PendingIntent to be used when broadcasting subscriber 66 * information to the given subscriberId within the given config. 67 * 68 * Suppose that the calling uid has added a config with key configKey, and that in this config 69 * it is specified that when a particular anomaly is detected, a broadcast should be sent to 70 * a BroadcastSubscriber with id subscriberId. This function links the given pendingIntent with 71 * that subscriberId (for that config), so that this pendingIntent is used to send the broadcast 72 * when the anomaly is detected. 73 * 74 * This function can only be called by the owner (uid) of the config. It must be called each 75 * time statsd starts. Later calls overwrite previous calls; only one PendingIntent is stored. 76 * 77 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 78 */ setBroadcastSubscriber(long configKey, long subscriberId, in PendingIntent pendingIntent, in String packageName)79 void setBroadcastSubscriber(long configKey, long subscriberId, in PendingIntent pendingIntent, 80 in String packageName); 81 82 /** 83 * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair. 84 * Any broadcasts associated with subscriberId will henceforth not be sent. 85 * No-op if this (configKey, subscriberId) pair was not associated with an PendingIntent. 86 * 87 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 88 */ unsetBroadcastSubscriber(long configKey, long subscriberId, in String packageName)89 void unsetBroadcastSubscriber(long configKey, long subscriberId, in String packageName); 90 91 /** 92 * Returns the most recently registered experiment IDs. 93 * 94 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 95 */ getRegisteredExperimentIds()96 long[] getRegisteredExperimentIds(); 97 98 /** 99 * Fetches metadata across statsd. Returns byte array representing wire-encoded proto. 100 * 101 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 102 */ getMetadata(in String packageName)103 byte[] getMetadata(in String packageName); 104 105 /** 106 * Fetches data for the specified configuration key. Returns a byte array representing proto 107 * wire-encoded of ConfigMetricsReportList. 108 * 109 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 110 */ getData(in long key, in String packageName)111 byte[] getData(in long key, in String packageName); 112 113 /** 114 * Sets a configuration with the specified config id and subscribes to updates for this 115 * configuration id. Broadcasts will be sent if this configuration needs to be collected. 116 * The configuration must be a wire-encoded StatsdConfig. The receiver for this data is 117 * registered in a separate function. 118 * 119 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 120 */ addConfiguration(in long configId, in byte[] config, in String packageName)121 void addConfiguration(in long configId, in byte[] config, in String packageName); 122 123 /** 124 * Removes the configuration with the matching config id. No-op if this config id does not 125 * exist. 126 * 127 * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS. 128 */ removeConfiguration(in long configId, in String packageName)129 void removeConfiguration(in long configId, in String packageName); 130 131 /** Tell StatsManagerService to register a puller for the given atom tag with statsd. */ registerPullAtomCallback(int atomTag, long coolDownMillis, long timeoutMillis, in int[] additiveFields, IPullAtomCallback pullerCallback)132 oneway void registerPullAtomCallback(int atomTag, long coolDownMillis, long timeoutMillis, 133 in int[] additiveFields, IPullAtomCallback pullerCallback); 134 135 /** Tell StatsManagerService to unregister the puller for the given atom tag from statsd. */ unregisterPullAtomCallback(int atomTag)136 oneway void unregisterPullAtomCallback(int atomTag); 137 138 /** Section for restricted-logging methods. */ 139 140 /** Queries data from underlying statsd sql store. */ querySql(in String sqlQuery, in int minSqlClientVersion, in @nullable byte[] policyConfig, in IStatsQueryCallback queryCallback, in long configKey, in String configPackage)141 oneway void querySql(in String sqlQuery, in int minSqlClientVersion, 142 in @nullable byte[] policyConfig, in IStatsQueryCallback queryCallback, 143 in long configKey, in String configPackage); 144 145 /** 146 * Registers the operation that is called whenever there is a change in the restricted metrics 147 * for a specified config that are present for this client. This operation allows statsd to 148 * inform the client about the current restricted metrics available to be queried for 149 * the specified config. 150 * 151 * Requires Manifest.permission.READ_RESTRICTED_STATS. 152 */ setRestrictedMetricsChangedOperation(in PendingIntent pendingIntent, in long configKey, in String configPackage)153 long[] setRestrictedMetricsChangedOperation(in PendingIntent pendingIntent, in long configKey, 154 in String configPackage); 155 156 /** 157 * Removes the restricted metrics changed operation for the specified config key/package. 158 * 159 * Requires Manifest.permission.READ_RESTRICTED_STATS. 160 */ removeRestrictedMetricsChangedOperation(in long configKey, in String configPackage)161 void removeRestrictedMetricsChangedOperation(in long configKey, in String configPackage); 162 } 163