blob: 5e032f00a3a02439ea07ea90f79fe48862dd3154 [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. Moltmann59076d82019-08-19 15:00:40 -070019import android.annotation.NonNull;
20import android.annotation.Nullable;
Hui Yu88910de2019-12-16 14:35:27 -080021import android.util.SparseArray;
Dianne Hackbornd5254412018-05-11 18:02:58 -070022import android.util.SparseIntArray;
23
Hai Zhangf4ef0392020-02-03 14:49:35 -080024import com.android.internal.app.IAppOpsCallback;
Stanislav Zholnin54762b22020-06-19 13:20:48 +010025import com.android.internal.util.function.HeptFunction;
Svet Ganovd873ae62018-06-25 16:39:23 -070026import com.android.internal.util.function.QuadFunction;
Svet Ganovd873ae62018-06-25 16:39:23 -070027
Dianne Hackbornd5254412018-05-11 18:02:58 -070028/**
29 * App ops service local interface.
30 *
31 * @hide Only for use within the system server.
32 */
33public abstract class AppOpsManagerInternal {
Svet Ganovd873ae62018-06-25 16:39:23 -070034 /** Interface to override app ops checks via composition */
35 public interface CheckOpsDelegate {
36 /**
37 * Allows overriding check operation behavior.
38 *
39 * @param code The op code to check.
40 * @param uid The UID for which to check.
41 * @param packageName The package for which to check.
42 * @param superImpl The super implementation.
Svet Ganov9d528a12018-12-19 17:23:11 -080043 * @param raw Whether to check the raw op i.e. not interpret the mode based on UID state.
Svet Ganovd873ae62018-06-25 16:39:23 -070044 * @return The app op check result.
45 */
Svet Ganov9d528a12018-12-19 17:23:11 -080046 int checkOperation(int code, int uid, String packageName, boolean raw,
47 QuadFunction<Integer, Integer, String, Boolean, Integer> superImpl);
Svet Ganovd873ae62018-06-25 16:39:23 -070048
49 /**
50 * Allows overriding check audio operation behavior.
51 *
52 * @param code The op code to check.
53 * @param usage The audio op usage.
54 * @param uid The UID for which to check.
55 * @param packageName The package for which to check.
56 * @param superImpl The super implementation.
57 * @return The app op check result.
58 */
59 int checkAudioOperation(int code, int usage, int uid, String packageName,
60 QuadFunction<Integer, Integer, Integer, String, Integer> superImpl);
61
62 /**
63 * Allows overriding note operation behavior.
64 *
65 * @param code The op code to note.
66 * @param uid The UID for which to note.
Philip P. Moltmann59076d82019-08-19 15:00:40 -070067 * @param packageName The package for which to note. {@code null} for system package.
68 * @param featureId Id of the feature in the package
Philip P. Moltmannda554e42019-12-20 11:21:02 -080069 * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected
70 * @param message The message in the async noted op
Svet Ganovd873ae62018-06-25 16:39:23 -070071 * @param superImpl The super implementation.
72 * @return The app op note result.
73 */
Philip P. Moltmann59076d82019-08-19 15:00:40 -070074 int noteOperation(int code, int uid, @Nullable String packageName,
Philip P. Moltmannda554e42019-12-20 11:21:02 -080075 @Nullable String featureId, boolean shouldCollectAsyncNotedOp,
Stanislav Zholnin54762b22020-06-19 13:20:48 +010076 @Nullable String message, boolean shouldCollectMessage,
77 @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean,
78 Integer> superImpl);
Svet Ganovd873ae62018-06-25 16:39:23 -070079 }
80
Dianne Hackbornd5254412018-05-11 18:02:58 -070081 /**
82 * Set the currently configured device and profile owners. Specifies the package uid (value)
83 * that has been configured for each user (key) that has one. These will be allowed privileged
84 * access to app ops for their user.
85 */
86 public abstract void setDeviceAndProfileOwners(SparseIntArray owners);
Hui Yu88910de2019-12-16 14:35:27 -080087
88 /**
89 * Update if the list of AppWidget becomes visible/invisible.
90 * @param uidPackageNames uid to packageName map.
91 * @param visible true for visible, false for invisible.
92 */
93 public abstract void updateAppWidgetVisibility(SparseArray<String> uidPackageNames,
94 boolean visible);
Hai Zhangf4ef0392020-02-03 14:49:35 -080095
96 /**
Hai Zhang8846aaa2020-02-13 15:19:54 -080097 * Like {@link AppOpsManager#setUidMode}, but allows ignoring our own callback and not updating
98 * the REVOKED_COMPAT flag.
Hai Zhangf4ef0392020-02-03 14:49:35 -080099 */
Hai Zhang8846aaa2020-02-13 15:19:54 -0800100 public abstract void setUidModeFromPermissionPolicy(int code, int uid, int mode,
101 @Nullable IAppOpsCallback callback);
Hai Zhangf4ef0392020-02-03 14:49:35 -0800102
103 /**
Hai Zhang8846aaa2020-02-13 15:19:54 -0800104 * Like {@link AppOpsManager#setMode}, but allows ignoring our own callback and not updating the
105 * REVOKED_COMPAT flag.
Hai Zhangf4ef0392020-02-03 14:49:35 -0800106 */
Hai Zhang8846aaa2020-02-13 15:19:54 -0800107 public abstract void setModeFromPermissionPolicy(int code, int uid, @NonNull String packageName,
108 int mode, @Nullable IAppOpsCallback callback);
Dianne Hackbornd5254412018-05-11 18:02:58 -0700109}