Dianne Hackborn | d525441 | 2018-05-11 18:02:58 -0700 | [diff] [blame] | 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 | |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
Hui Yu | 88910de | 2019-12-16 14:35:27 -0800 | [diff] [blame] | 21 | import android.util.SparseArray; |
Dianne Hackborn | d525441 | 2018-05-11 18:02:58 -0700 | [diff] [blame] | 22 | import android.util.SparseIntArray; |
| 23 | |
Hai Zhang | f4ef039 | 2020-02-03 14:49:35 -0800 | [diff] [blame] | 24 | import com.android.internal.app.IAppOpsCallback; |
Stanislav Zholnin | 54762b2 | 2020-06-19 13:20:48 +0100 | [diff] [blame] | 25 | import com.android.internal.util.function.HeptFunction; |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 26 | import com.android.internal.util.function.QuadFunction; |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 27 | |
Dianne Hackborn | d525441 | 2018-05-11 18:02:58 -0700 | [diff] [blame] | 28 | /** |
| 29 | * App ops service local interface. |
| 30 | * |
| 31 | * @hide Only for use within the system server. |
| 32 | */ |
| 33 | public abstract class AppOpsManagerInternal { |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 34 | /** 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 Ganov | 9d528a1 | 2018-12-19 17:23:11 -0800 | [diff] [blame] | 43 | * @param raw Whether to check the raw op i.e. not interpret the mode based on UID state. |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 44 | * @return The app op check result. |
| 45 | */ |
Svet Ganov | 9d528a1 | 2018-12-19 17:23:11 -0800 | [diff] [blame] | 46 | int checkOperation(int code, int uid, String packageName, boolean raw, |
| 47 | QuadFunction<Integer, Integer, String, Boolean, Integer> superImpl); |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 48 | |
| 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. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 67 | * @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. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 69 | * @param shouldCollectAsyncNotedOp If an {@link AsyncNotedAppOp} should be collected |
| 70 | * @param message The message in the async noted op |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 71 | * @param superImpl The super implementation. |
| 72 | * @return The app op note result. |
| 73 | */ |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 74 | int noteOperation(int code, int uid, @Nullable String packageName, |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 75 | @Nullable String featureId, boolean shouldCollectAsyncNotedOp, |
Stanislav Zholnin | 54762b2 | 2020-06-19 13:20:48 +0100 | [diff] [blame] | 76 | @Nullable String message, boolean shouldCollectMessage, |
| 77 | @NonNull HeptFunction<Integer, Integer, String, String, Boolean, String, Boolean, |
| 78 | Integer> superImpl); |
Svet Ganov | d873ae6 | 2018-06-25 16:39:23 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Dianne Hackborn | d525441 | 2018-05-11 18:02:58 -0700 | [diff] [blame] | 81 | /** |
| 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 Yu | 88910de | 2019-12-16 14:35:27 -0800 | [diff] [blame] | 87 | |
| 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 Zhang | f4ef039 | 2020-02-03 14:49:35 -0800 | [diff] [blame] | 95 | |
| 96 | /** |
Hai Zhang | 8846aaa | 2020-02-13 15:19:54 -0800 | [diff] [blame] | 97 | * Like {@link AppOpsManager#setUidMode}, but allows ignoring our own callback and not updating |
| 98 | * the REVOKED_COMPAT flag. |
Hai Zhang | f4ef039 | 2020-02-03 14:49:35 -0800 | [diff] [blame] | 99 | */ |
Hai Zhang | 8846aaa | 2020-02-13 15:19:54 -0800 | [diff] [blame] | 100 | public abstract void setUidModeFromPermissionPolicy(int code, int uid, int mode, |
| 101 | @Nullable IAppOpsCallback callback); |
Hai Zhang | f4ef039 | 2020-02-03 14:49:35 -0800 | [diff] [blame] | 102 | |
| 103 | /** |
Hai Zhang | 8846aaa | 2020-02-13 15:19:54 -0800 | [diff] [blame] | 104 | * Like {@link AppOpsManager#setMode}, but allows ignoring our own callback and not updating the |
| 105 | * REVOKED_COMPAT flag. |
Hai Zhang | f4ef039 | 2020-02-03 14:49:35 -0800 | [diff] [blame] | 106 | */ |
Hai Zhang | 8846aaa | 2020-02-13 15:19:54 -0800 | [diff] [blame] | 107 | public abstract void setModeFromPermissionPolicy(int code, int uid, @NonNull String packageName, |
| 108 | int mode, @Nullable IAppOpsCallback callback); |
Dianne Hackborn | d525441 | 2018-05-11 18:02:58 -0700 | [diff] [blame] | 109 | } |