blob: 7fe21b23738c8d1d7fc4b50658ba61619c8021a4 [file] [log] [blame]
Dianne Hackbornd5254412018-05-11 18:02:58 -07001/*
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
17package android.app;
18
Philip P. Moltmann17f65af2018-10-18 15:32:29 -070019import android.annotation.NonNull;
Dianne Hackbornd5254412018-05-11 18:02:58 -070020import android.util.SparseIntArray;
21
Svet Ganovd873ae62018-06-25 16:39:23 -070022import com.android.internal.util.function.QuadFunction;
23import com.android.internal.util.function.TriFunction;
24
Dianne Hackbornd5254412018-05-11 18:02:58 -070025/**
26 * App ops service local interface.
27 *
28 * @hide Only for use within the system server.
29 */
30public abstract class AppOpsManagerInternal {
Svet Ganovd873ae62018-06-25 16:39:23 -070031 /** Interface to override app ops checks via composition */
32 public interface CheckOpsDelegate {
33 /**
34 * Allows overriding check operation behavior.
35 *
36 * @param code The op code to check.
37 * @param uid The UID for which to check.
38 * @param packageName The package for which to check.
39 * @param superImpl The super implementation.
40 * @return The app op check result.
41 */
42 int checkOperation(int code, int uid, String packageName,
43 TriFunction<Integer, Integer, String, 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 */
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 */
67 int noteOperation(int code, int uid, String packageName,
68 TriFunction<Integer, Integer, String, Integer> superImpl);
69 }
70
Dianne Hackbornd5254412018-05-11 18:02:58 -070071 /**
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 */
76 public abstract void setDeviceAndProfileOwners(SparseIntArray owners);
Philip P. Moltmann17f65af2018-10-18 15:32:29 -070077
78 /**
79 * Sets the app-ops mode for a certain app-op and uid.
80 *
81 * <p>Similar as {@link AppOpsManager#setMode} but does not require the package manager to be
82 * working. Hence this can be used very early during boot.
83 *
84 * <p>Only for internal callers. Does <u>not</u> verify that package name belongs to uid.
85 *
86 * @param code The op code to set.
87 * @param uid The UID for which to set.
88 * @param packageName The package for which to set.
89 * @param mode The new mode to set.
90 * @param isPrivileged If the package is privileged
91 */
92 public abstract void setMode(int code, int uid, @NonNull String packageName, int mode,
93 boolean isPrivileged);
Dianne Hackbornd5254412018-05-11 18:02:58 -070094}