| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
| Steven Moreland | c7a871e | 2020-11-10 21:56:57 +0000 | [diff] [blame] | 17 | #pragma once |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 18 | |
| Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 19 | #include <android/content/AttributionSourceState.h> |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 20 | #include <binder/IAppOpsCallback.h> |
| 21 | #include <binder/IInterface.h> |
| 22 | |
| Jooyung Han | 149be4a | 2020-01-23 12:45:10 +0900 | [diff] [blame] | 23 | #include <optional> |
| 24 | |
| Steven Moreland | c326a94 | 2019-09-09 16:07:52 -0700 | [diff] [blame] | 25 | #ifdef __ANDROID_VNDK__ |
| 26 | #error "This header is not visible to vendors" |
| 27 | #endif |
| 28 | |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 29 | namespace android { |
| 30 | |
| Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 31 | using android::content::AttributionSourceState; |
| 32 | |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 33 | // ---------------------------------------------------------------------- |
| 34 | |
| 35 | class IAppOpsService : public IInterface |
| 36 | { |
| 37 | public: |
| Colin Cross | 17576de | 2016-09-26 13:07:06 -0700 | [diff] [blame] | 38 | DECLARE_META_INTERFACE(AppOpsService) |
| Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 39 | virtual int32_t checkOperationWithState(int32_t code, |
| 40 | const AttributionSourceState& attributionSourceState) = 0; |
| 41 | virtual int32_t noteOperationWithState(int32_t code, |
| 42 | const AttributionSourceState& attributionSourceState, bool shouldCollectAsyncNotedOp, |
| Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 43 | const String16& message, bool shouldCollectMessage) = 0; |
| Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 44 | virtual int32_t startOperationWithState(const sp<IBinder>& token, int32_t code, |
| 45 | const AttributionSourceState& attributionSourceState, bool startIfModeDefault, |
| 46 | bool shouldCollectAsyncNotedOp, const String16& message, bool shouldCollectMessage) = 0; |
| 47 | virtual void finishOperationWithState(const sp<IBinder>& token, int32_t code, |
| 48 | const AttributionSourceState& attributionSourceState) = 0; |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 49 | virtual void startWatchingMode(int32_t op, const String16& packageName, |
| 50 | const sp<IAppOpsCallback>& callback) = 0; |
| 51 | virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0; |
| Svetoslav | b412f6e | 2015-04-29 16:50:41 -0700 | [diff] [blame] | 52 | virtual int32_t permissionToOpCode(const String16& permission) = 0; |
| Jean-Michel Trivi | 94a566d | 2019-02-25 12:16:02 -0800 | [diff] [blame] | 53 | virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid, |
| 54 | const String16& packageName) = 0; |
| Yin-Chia Yeh | 8e95ee8 | 2019-08-13 12:24:25 -0700 | [diff] [blame] | 55 | virtual void setCameraAudioRestriction(int32_t mode) = 0; |
| Philip P. Moltmann | 66a8777 | 2019-06-24 16:30:00 -0700 | [diff] [blame] | 56 | virtual bool shouldCollectNotes(int32_t opCode) = 0; |
| Evan Severson | 949cb3d | 2023-04-04 14:46:06 -0700 | [diff] [blame] | 57 | virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName, |
| 58 | int32_t flags, const sp<IAppOpsCallback>& callback) = 0; |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 59 | |
| 60 | enum { |
| Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 61 | CHECK_OPERATION_WITH_STATE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+50, |
| 62 | NOTE_OPERATION_WITH_STATE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+52, |
| 63 | START_OPERATION_WITH_STATE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+53, |
| 64 | FINISH_OPERATION_WITH_STATE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+54, |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 65 | START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4, |
| Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 66 | STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5, |
| Philip P. Moltmann | c52e1fc | 2019-11-26 15:18:09 -0800 | [diff] [blame] | 67 | PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6, |
| 68 | CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7, |
| Philip P. Moltmann | 3879cf6 | 2019-12-20 11:22:37 -0800 | [diff] [blame] | 69 | SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8, |
| 70 | SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9, |
| Evan Severson | 949cb3d | 2023-04-04 14:46:06 -0700 | [diff] [blame] | 71 | START_WATCHING_MODE_WITH_FLAGS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+10, |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 72 | }; |
| Eino-Ville Talvala | e88a85e | 2013-02-19 12:54:57 -0800 | [diff] [blame] | 73 | |
| 74 | enum { |
| 75 | MODE_ALLOWED = 0, |
| 76 | MODE_IGNORED = 1, |
| 77 | MODE_ERRORED = 2 |
| 78 | }; |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | // ---------------------------------------------------------------------- |
| 82 | |
| 83 | class BnAppOpsService : public BnInterface<IAppOpsService> |
| 84 | { |
| 85 | public: |
| Jiyong Park | b86c866 | 2018-10-29 23:01:57 +0900 | [diff] [blame] | 86 | // NOLINTNEXTLINE(google-default-arguments) |
| Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 87 | virtual status_t onTransact( uint32_t code, |
| 88 | const Parcel& data, |
| 89 | Parcel* reply, |
| 90 | uint32_t flags = 0); |
| 91 | }; |
| 92 | |
| 93 | // ---------------------------------------------------------------------- |
| 94 | |
| Steven Moreland | 6511af5 | 2019-09-26 16:05:45 -0700 | [diff] [blame] | 95 | } // namespace android |