Home | History | Annotate | Download | only in os
      1 /**
      2  * Copyright (c) 2017, 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.os.IStatsPullerCallback;
     20 import android.os.ParcelFileDescriptor;
     21 
     22 /**
     23   * Binder interface to communicate with the statistics management service.
     24   * {@hide}
     25   */
     26 interface IStatsManager {
     27     /**
     28      * Tell the stats daemon that the android system server is up and running.
     29      */
     30     oneway void systemRunning();
     31 
     32     /**
     33      * Tell the stats daemon that the StatsCompanionService is up and running.
     34      * Two-way binder call so that caller knows message received.
     35      */
     36     void statsCompanionReady();
     37 
     38     /**
     39      * Tells statsd that an anomaly may have occurred, so statsd can check whether this is so and
     40      * act accordingly.
     41      * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
     42      */
     43     void informAnomalyAlarmFired();
     44 
     45     /**
     46      * Tells statsd that it is time to poll some stats. Statsd will be responsible for determing
     47      * what stats to poll and initiating the polling.
     48      * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
     49      */
     50     void informPollAlarmFired();
     51 
     52     /**
     53      * Tells statsd that it is time to handle periodic alarms. Statsd will be responsible for
     54      * determing what alarm subscriber to trigger.
     55      * Two-way binder call so that caller's method (and corresponding wakelocks) will linger.
     56      */
     57     void informAlarmForSubscriberTriggeringFired();
     58 
     59     /**
     60      * Tells statsd that the device is about to shutdown.
     61      */
     62     void informDeviceShutdown();
     63 
     64     /**
     65      * Inform statsd about a file descriptor for a pipe through which we will pipe version
     66      * and package information for each uid.
     67      * Versions and package information are supplied via UidData proto where info for each app
     68      * is captured in its own element of a repeated ApplicationInfo message.
     69      */
     70     oneway void informAllUidData(in ParcelFileDescriptor fd);
     71 
     72     /**
     73      * Inform statsd what the uid, version, version_string, and installer are for one app that was
     74      * updated.
     75      */
     76     oneway void informOnePackage(in String app, in int uid, in long version,
     77         in String version_string, in String installer);
     78 
     79     /**
     80      * Inform stats that an app was removed.
     81      */
     82     oneway void informOnePackageRemoved(in String app, in int uid);
     83 
     84     /**
     85      * Fetches data for the specified configuration key. Returns a byte array representing proto
     86      * wire-encoded of ConfigMetricsReportList.
     87      *
     88      * Requires Manifest.permission.DUMP.
     89      */
     90     byte[] getData(in long key, in String packageName);
     91 
     92     /**
     93      * Fetches metadata across statsd. Returns byte array representing wire-encoded proto.
     94      *
     95      * Requires Manifest.permission.DUMP.
     96      */
     97     byte[] getMetadata(in String packageName);
     98 
     99     /**
    100      * Sets a configuration with the specified config key and subscribes to updates for this
    101      * configuration key. Broadcasts will be sent if this configuration needs to be collected.
    102      * The configuration must be a wire-encoded StatsdConfig. The receiver for this data is
    103      * registered in a separate function.
    104      *
    105      * Requires Manifest.permission.DUMP.
    106      */
    107     void addConfiguration(in long configKey, in byte[] config, in String packageName);
    108 
    109     /**
    110      * Registers the given pending intent for this config key. This intent is invoked when the
    111      * memory consumed by the metrics for this configuration approach the pre-defined limits. There
    112      * can be at most one listener per config key.
    113      *
    114      * Requires Manifest.permission.DUMP.
    115      */
    116     void setDataFetchOperation(long configKey, in IBinder intentSender, in String packageName);
    117 
    118     /**
    119      * Removes the data fetch operation for the specified configuration.
    120      *
    121      * Requires Manifest.permission.DUMP.
    122      */
    123     void removeDataFetchOperation(long configKey, in String packageName);
    124 
    125     /**
    126      * Registers the given pending intent for this packagename. This intent is invoked when the
    127      * active status of any of the configs sent by this package changes and will contain a list of
    128      * config ids that are currently active. It also returns the list of configs that are currently
    129      * active. There can be at most one active configs changed listener per package.
    130      *
    131      * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
    132      */
    133     long[] setActiveConfigsChangedOperation(in IBinder intentSender, in String packageName);
    134 
    135     /**
    136      * Removes the active configs changed operation for the specified package name.
    137      *
    138      * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS.
    139      */
    140     void removeActiveConfigsChangedOperation(in String packageName);
    141 
    142     /**
    143      * Removes the configuration with the matching config key. No-op if this config key does not
    144      * exist.
    145      *
    146      * Requires Manifest.permission.DUMP.
    147      */
    148     void removeConfiguration(in long configKey, in String packageName);
    149 
    150     /**
    151      * Set the IIntentSender (i.e. PendingIntent) to be used when broadcasting subscriber
    152      * information to the given subscriberId within the given config.
    153      *
    154      * Suppose that the calling uid has added a config with key configKey, and that in this config
    155      * it is specified that when a particular anomaly is detected, a broadcast should be sent to
    156      * a BroadcastSubscriber with id subscriberId. This function links the given intentSender with
    157      * that subscriberId (for that config), so that this intentSender is used to send the broadcast
    158      * when the anomaly is detected.
    159      *
    160      * This function can only be called by the owner (uid) of the config. It must be called each
    161      * time statsd starts. Later calls overwrite previous calls; only one intentSender is stored.
    162      *
    163      * intentSender must be convertible into an IntentSender using IntentSender(IBinder)
    164      * and cannot be null.
    165      *
    166      * Requires Manifest.permission.DUMP.
    167      */
    168     void setBroadcastSubscriber(long configKey, long subscriberId, in IBinder intentSender,
    169                                 in String packageName);
    170 
    171     /**
    172      * Undoes setBroadcastSubscriber() for the (configKey, subscriberId) pair.
    173      * Any broadcasts associated with subscriberId will henceforth not be sent.
    174      * No-op if this (configKey, subsriberId) pair was not associated with an IntentSender.
    175      *
    176      * Requires Manifest.permission.DUMP.
    177      */
    178     void unsetBroadcastSubscriber(long configKey, long subscriberId, in String packageName);
    179 
    180     /**
    181      * Apps can send an atom via this application breadcrumb with the specified label and state for
    182      * this label. This allows building custom metrics and predicates.
    183      */
    184     void sendAppBreadcrumbAtom(int label, int state);
    185 
    186     /**
    187      * Registers a puller callback function that, when invoked, pulls the data
    188      * for the specified vendor atom tag.
    189      *
    190      * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS
    191      */
    192     oneway void registerPullerCallback(int atomTag, IStatsPullerCallback pullerCallback,
    193                                        String packageName);
    194 
    195    /**
    196     * Unregisters a puller callback function for the given vendor atom.
    197     *
    198     * Requires Manifest.permission.DUMP and Manifest.permission.PACKAGE_USAGE_STATS
    199     */
    200    oneway void unregisterPullerCallback(int atomTag, String packageName);
    201 
    202     /**
    203      * The install requires staging.
    204      */
    205     const int FLAG_REQUIRE_STAGING = 0x01;
    206 
    207     /**
    208      * Rollback is enabled with this install.
    209      */
    210     const int FLAG_ROLLBACK_ENABLED = 0x02;
    211 
    212     /**
    213      * Requires low latency monitoring.
    214      */
    215     const int FLAG_REQUIRE_LOW_LATENCY_MONITOR = 0x04;
    216 
    217     /**
    218      * Logs an event for binary push for module updates.
    219      */
    220      oneway void sendBinaryPushStateChangedAtom(in String trainName, in long trainVersionCode,
    221          in int options, in int state, in long[] experimentId);
    222 
    223     /**
    224      * Logs an event for watchdog rollbacks.
    225      */
    226      oneway void sendWatchdogRollbackOccurredAtom(in int rollbackType, in String packageName,
    227          in long packageVersionCode);
    228 
    229     /**
    230      * Returns the most recently registered experiment IDs.
    231      */
    232     long[] getRegisteredExperimentIds();
    233 }
    234