• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 com.android.systemui.appops;
18 
19 import java.util.List;
20 
21 /**
22  * Controller to keep track of applications that have requested access to given App Ops.
23  *
24  * It can be subscribed to with callbacks. Additionally, it passes on the information to
25  * NotificationPresenter to be displayed to the user.
26  */
27 public interface AppOpsController {
28 
29     /**
30      * Callback to notify when the state of active AppOps tracked by the controller has changed.
31      * AppOps that are noted will not be notified every time, just when the tracked state changes
32      * between currently in use and not.
33      */
34     interface Callback {
onActiveStateChanged(int code, int uid, String packageName, boolean active)35         void onActiveStateChanged(int code, int uid, String packageName, boolean active);
36     }
37 
38     /**
39      * Adds a callback that will get notified when an AppOp of the type the controller tracks
40      * changes
41      *
42      * @param opsCodes App Ops the callback was interested in checking
43      * @param cb Callback to report changes
44      *
45      * @see #removeCallback(int[], Callback)
46      */
addCallback(int[] opsCodes, Callback cb)47     void addCallback(int[] opsCodes, Callback cb);
48 
49     /**
50      * Removes a callback from those notifified when an AppOp of the type the controller tracks
51      * changes
52      *
53      * @param opsCodes App Ops the callback is interested in checking
54      * @param cb Callback to stop reporting changes
55      *
56      * @see #addCallback(int[], Callback)
57      */
removeCallback(int[] opsCodes, Callback cb)58     void removeCallback(int[] opsCodes, Callback cb);
59 
60     /**
61      * Returns a copy of the list containing all the active AppOps that the controller tracks.
62      *
63      * @return List of active AppOps information, without paused elements.
64      */
getActiveAppOps()65     List<AppOpItem> getActiveAppOps();
66 
67     /**
68      * Returns a copy of the list containing all the active AppOps that the controller tracks.
69      *
70      * @param showPaused {@code true} to also obtain paused items. {@code false} otherwise.
71      * @return List of active AppOps information
72      */
getActiveAppOps(boolean showPaused)73     List<AppOpItem> getActiveAppOps(boolean showPaused);
74 
75     /**
76      * Returns a copy of the list containing all the active AppOps that the controller tracks, for
77      * a given user id.
78      *
79      * @param userId User id to track
80      * @param showPaused {@code true} to also obtain paused items. {@code false} otherwise.
81      *
82      * @return List of active AppOps information for that user id
83      */
getActiveAppOpsForUser(int userId, boolean showPaused)84     List<AppOpItem> getActiveAppOpsForUser(int userId, boolean showPaused);
85 
86     /**
87      * @return whether this controller is considering the microphone as muted.
88      */
isMicMuted()89     boolean isMicMuted();
90 }
91