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 android.app;
18 
19 import android.util.SparseIntArray;
20 
21 import com.android.internal.util.function.QuadFunction;
22 import com.android.internal.util.function.TriFunction;
23 
24 /**
25  * App ops service local interface.
26  *
27  * @hide Only for use within the system server.
28  */
29 public abstract class AppOpsManagerInternal {
30     /** Interface to override app ops checks via composition */
31     public interface CheckOpsDelegate {
32         /**
33          * Allows overriding check operation behavior.
34          *
35          * @param code The op code to check.
36          * @param uid The UID for which to check.
37          * @param packageName The package for which to check.
38          * @param superImpl The super implementation.
39          * @param raw Whether to check the raw op i.e. not interpret the mode based on UID state.
40          * @return The app op check result.
41          */
checkOperation(int code, int uid, String packageName, boolean raw, QuadFunction<Integer, Integer, String, Boolean, Integer> superImpl)42         int checkOperation(int code, int uid, String packageName, boolean raw,
43                 QuadFunction<Integer, Integer, String, Boolean, Integer> superImpl);
44 
45         /**
46          * Allows overriding check audio operation behavior.
47          *
48          * @param code The op code to check.
49          * @param usage The audio op usage.
50          * @param uid The UID for which to check.
51          * @param packageName The package for which to check.
52          * @param superImpl The super implementation.
53          * @return The app op check result.
54          */
checkAudioOperation(int code, int usage, int uid, String packageName, QuadFunction<Integer, Integer, Integer, String, Integer> superImpl)55         int checkAudioOperation(int code, int usage, int uid, String packageName,
56                 QuadFunction<Integer, Integer, Integer, String, Integer> superImpl);
57 
58         /**
59          * Allows overriding note operation behavior.
60          *
61          * @param code The op code to note.
62          * @param uid The UID for which to note.
63          * @param packageName The package for which to note.
64          * @param superImpl The super implementation.
65          * @return The app op note result.
66          */
noteOperation(int code, int uid, String packageName, TriFunction<Integer, Integer, String, Integer> superImpl)67         int noteOperation(int code, int uid, String packageName,
68                 TriFunction<Integer, Integer, String, Integer> superImpl);
69     }
70 
71     /**
72      * Set the currently configured device and profile owners.  Specifies the package uid (value)
73      * that has been configured for each user (key) that has one.  These will be allowed privileged
74      * access to app ops for their user.
75      */
setDeviceAndProfileOwners(SparseIntArray owners)76     public abstract void setDeviceAndProfileOwners(SparseIntArray owners);
77 
78     /**
79      * Set all {@link #setMode (package) modes} for this uid to the default value.
80      *
81      * @param code The app-op
82      * @param uid The uid
83      */
setAllPkgModesToDefault(int code, int uid)84     public abstract void setAllPkgModesToDefault(int code, int uid);
85 }
86