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