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.StatsDimensionsValue;
20 import android.os.StatsLogEventWrapper;
21 
22 /**
23   * Binder interface to communicate with the Java-based statistics service helper.
24   * {@hide}
25   */
26 interface IStatsCompanionService {
27     /**
28      * Tell statscompanion that stastd is up and running.
29      */
statsdReady()30     oneway void statsdReady();
31 
32     /**
33     * Register an alarm for anomaly detection to fire at the given timestamp (ms since epoch).
34     * If anomaly alarm had already been registered, it will be replaced with the new timestamp.
35     * Uses AlarmManager.set API, so  if the timestamp is in the past, alarm fires immediately, and
36     * alarm is inexact.
37     */
setAnomalyAlarm(long timestampMs)38     oneway void setAnomalyAlarm(long timestampMs);
39 
40     /** Cancel any anomaly detection alarm. */
cancelAnomalyAlarm()41     oneway void cancelAnomalyAlarm();
42 
43     /**
44       * Register a repeating alarm for pulling to fire at the given timestamp and every
45       * intervalMs thereafter (in ms since epoch).
46       * If polling alarm had already been registered, it will be replaced by new one.
47       * Uses AlarmManager.setRepeating API, so if the timestamp is in past, alarm fires immediately,
48       * and alarm is inexact.
49       */
setPullingAlarm(long nextPullTimeMs)50     oneway void setPullingAlarm(long nextPullTimeMs);
51 
52     /** Cancel any repeating pulling alarm. */
cancelPullingAlarm()53     oneway void cancelPullingAlarm();
54 
55     /**
56       * Register an alarm when we want to trigger subscribers at the given
57       * timestamp (in ms since epoch).
58       * If an alarm had already been registered, it will be replaced by new one.
59       */
setAlarmForSubscriberTriggering(long timestampMs)60     oneway void setAlarmForSubscriberTriggering(long timestampMs);
61 
62     /** Cancel any alarm for the purpose of subscriber triggering. */
cancelAlarmForSubscriberTriggering()63     oneway void cancelAlarmForSubscriberTriggering();
64 
65     /** Pull the specified data. Results will be sent to statsd when complete. */
pullData(int pullCode)66     StatsLogEventWrapper[] pullData(int pullCode);
67 
68     /** Send a broadcast to the specified PendingIntent's as IBinder that it should getData now. */
sendDataBroadcast(in IBinder intentSender, long lastReportTimeNs)69     oneway void sendDataBroadcast(in IBinder intentSender, long lastReportTimeNs);
70 
71     /**
72      * Requests StatsCompanionService to send a broadcast using the given intentSender
73      * (which should cast to an IIntentSender), along with the other information specified.
74      */
sendSubscriberBroadcast(in IBinder intentSender, long configUid, long configId, long subscriptionId, long subscriptionRuleId, in String[] cookies, in StatsDimensionsValue dimensionsValue)75     oneway void sendSubscriberBroadcast(in IBinder intentSender, long configUid, long configId,
76                                         long subscriptionId, long subscriptionRuleId,
77                                         in String[] cookies,
78                                         in StatsDimensionsValue dimensionsValue);
79 
80     /** Tells StatsCompaionService to grab the uid map snapshot and send it to statsd. */
triggerUidSnapshot()81     oneway void triggerUidSnapshot();
82 }
83