Home | History | Annotate | Download | only in appops
      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      */
     32     interface Callback {
     33         void onActiveStateChanged(int code, int uid, String packageName, boolean active);
     34     }
     35 
     36     /**
     37      * Adds a callback that will get notified when an AppOp of the type the controller tracks
     38      * changes
     39      *
     40      * @param opsCodes App Ops the callback was interested in checking
     41      * @param cb Callback to report changes
     42      *
     43      * @see #removeCallback(int[], Callback)
     44      */
     45     void addCallback(int[] opsCodes, Callback cb);
     46 
     47     /**
     48      * Removes a callback from those notifified when an AppOp of the type the controller tracks
     49      * changes
     50      *
     51      * @param opsCodes App Ops the callback is interested in checking
     52      * @param cb Callback to stop reporting changes
     53      *
     54      * @see #addCallback(int[], Callback)
     55      */
     56     void removeCallback(int[] opsCodes, Callback cb);
     57 
     58     /**
     59      * Returns a copy of the list containing all the active AppOps that the controller tracks.
     60      *
     61      * @return List of active AppOps information
     62      */
     63     List<AppOpItem> getActiveAppOps();
     64 
     65     /**
     66      * Returns a copy of the list containing all the active AppOps that the controller tracks, for
     67      * a given user id.
     68      *
     69      * @param userId User id to track
     70      *
     71      * @return List of active AppOps information for that user id
     72      */
     73     List<AppOpItem> getActiveAppOpsForUser(int userId);
     74 }
     75