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 /**
20   * Binder interface to communicate with the Java-based statistics service helper.
21   * {@hide}
22   */
23 interface IStatsCompanionService {
24     /**
25      * Tell statscompanion that stastd is up and running.
26      */
statsdReady()27     oneway void statsdReady();
28 
29     /**
30     * Register an alarm for anomaly detection to fire at the given timestamp (ms since epoch).
31     * If anomaly alarm had already been registered, it will be replaced with the new timestamp.
32     * Uses AlarmManager.set API, so  if the timestamp is in the past, alarm fires immediately, and
33     * alarm is inexact.
34     */
setAnomalyAlarm(long timestampMs)35     oneway void setAnomalyAlarm(long timestampMs);
36 
37     /** Cancel any anomaly detection alarm. */
cancelAnomalyAlarm()38     oneway void cancelAnomalyAlarm();
39 
40     /**
41       * Register a repeating alarm for pulling to fire at the given timestamp and every
42       * intervalMs thereafter (in ms since epoch).
43       * If polling alarm had already been registered, it will be replaced by new one.
44       * Uses AlarmManager.setRepeating API, so if the timestamp is in past, alarm fires immediately,
45       * and alarm is inexact.
46       */
setPullingAlarm(long nextPullTimeMs)47     oneway void setPullingAlarm(long nextPullTimeMs);
48 
49     /** Cancel any repeating pulling alarm. */
cancelPullingAlarm()50     oneway void cancelPullingAlarm();
51 
52     /**
53       * Register an alarm when we want to trigger subscribers at the given
54       * timestamp (in ms since epoch).
55       * If an alarm had already been registered, it will be replaced by new one.
56       */
setAlarmForSubscriberTriggering(long timestampMs)57     oneway void setAlarmForSubscriberTriggering(long timestampMs);
58 
59     /** Cancel any alarm for the purpose of subscriber triggering. */
cancelAlarmForSubscriberTriggering()60     oneway void cancelAlarmForSubscriberTriggering();
61 
62     /**
63      * Ask StatsCompanionService if the given permission is allowed for a particular process
64      * and user ID. statsd is incapable of doing this check itself because checkCallingPermission
65      * is not currently supported by libbinder_ndk.
66      */
checkPermission(String permission, int pid, int uid)67     boolean checkPermission(String permission, int pid, int uid);
68 }
69