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 | |
| 17 | #define LOG_TAG "AppOpsService" |
| 18 | |
| 19 | #include <binder/IAppOpsService.h> |
| 20 | |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 21 | #include <binder/Parcel.h> |
Nate Myren | 2b437b2 | 2021-04-08 08:14:15 -0700 | [diff] [blame] | 22 | #include <utils/Log.h> |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 23 | #include <utils/String8.h> |
| 24 | |
Jooyung Han | 149be4a | 2020-01-23 12:45:10 +0900 | [diff] [blame] | 25 | #include <optional> |
| 26 | |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 27 | namespace android { |
| 28 | |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 29 | using android::content::AttributionSourceState; |
| 30 | |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 31 | // ---------------------------------------------------------------------- |
| 32 | |
| 33 | class BpAppOpsService : public BpInterface<IAppOpsService> |
| 34 | { |
| 35 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 36 | explicit BpAppOpsService(const sp<IBinder>& impl) |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 37 | : BpInterface<IAppOpsService>(impl) |
| 38 | { |
| 39 | } |
| 40 | |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 41 | virtual int32_t checkOperationWithState(int32_t code, |
| 42 | const AttributionSourceState &attributionSourceState) { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 43 | Parcel data, reply; |
| 44 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 45 | data.writeInt32(code); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 46 | data.writeParcelable(attributionSourceState); |
| 47 | remote()->transact(CHECK_OPERATION_WITH_STATE_TRANSACTION, data, &reply); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 48 | // fail on exception |
Eino-Ville Talvala | e88a85e | 2013-02-19 12:54:57 -0800 | [diff] [blame] | 49 | if (reply.readExceptionCode() != 0) return MODE_ERRORED; |
| 50 | return reply.readInt32(); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 53 | virtual int32_t noteOperationWithState(int32_t code, |
| 54 | const AttributionSourceState& attributionSourceState, |
| 55 | bool shouldCollectAsyncNotedOp, const String16& message, |
| 56 | bool shouldCollectMessage) { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 57 | Parcel data, reply; |
| 58 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 59 | data.writeInt32(code); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 60 | data.writeParcelable(attributionSourceState); |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 61 | data.writeBool(shouldCollectAsyncNotedOp); |
Philip P. Moltmann | 3879cf6 | 2019-12-20 11:22:37 -0800 | [diff] [blame] | 62 | data.writeString16(message); |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 63 | data.writeBool(shouldCollectMessage); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 64 | remote()->transact(NOTE_OPERATION_WITH_STATE_TRANSACTION, data, &reply); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 65 | // fail on exception |
Eino-Ville Talvala | e88a85e | 2013-02-19 12:54:57 -0800 | [diff] [blame] | 66 | if (reply.readExceptionCode() != 0) return MODE_ERRORED; |
Nate Myren | 2b437b2 | 2021-04-08 08:14:15 -0700 | [diff] [blame] | 67 | // TODO b/184855056: extract to class |
| 68 | reply.readInt32(); |
Nate Myren | a0ae2f9 | 2021-04-01 15:19:26 -0700 | [diff] [blame] | 69 | reply.readByte(); |
Eino-Ville Talvala | e88a85e | 2013-02-19 12:54:57 -0800 | [diff] [blame] | 70 | return reply.readInt32(); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 71 | } |
| 72 | |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 73 | virtual int32_t startOperationWithState(const sp<IBinder>& token, int32_t code, |
| 74 | const AttributionSourceState& attributionSourceState, bool startIfModeDefault, |
| 75 | bool shouldCollectAsyncNotedOp, const String16& message, |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 76 | bool shouldCollectMessage) { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 77 | Parcel data, reply; |
| 78 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 79 | data.writeStrongBinder(token); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 80 | data.writeInt32(code); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 81 | data.writeParcelable(attributionSourceState); |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 82 | data.writeBool(startIfModeDefault); |
| 83 | data.writeBool(shouldCollectAsyncNotedOp); |
Philip P. Moltmann | 3879cf6 | 2019-12-20 11:22:37 -0800 | [diff] [blame] | 84 | data.writeString16(message); |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 85 | data.writeBool(shouldCollectMessage); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 86 | remote()->transact(START_OPERATION_WITH_STATE_TRANSACTION, data, &reply); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 87 | // fail on exception |
Eino-Ville Talvala | e88a85e | 2013-02-19 12:54:57 -0800 | [diff] [blame] | 88 | if (reply.readExceptionCode() != 0) return MODE_ERRORED; |
Nate Myren | 2b437b2 | 2021-04-08 08:14:15 -0700 | [diff] [blame] | 89 | // TODO b/184855056: extract to class |
| 90 | reply.readInt32(); |
Nate Myren | a0ae2f9 | 2021-04-01 15:19:26 -0700 | [diff] [blame] | 91 | reply.readByte(); |
Eino-Ville Talvala | e88a85e | 2013-02-19 12:54:57 -0800 | [diff] [blame] | 92 | return reply.readInt32(); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 93 | } |
| 94 | |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 95 | virtual void finishOperationWithState(const sp<IBinder>& token, int32_t code, |
| 96 | const AttributionSourceState& attributionSourceState) { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 97 | Parcel data, reply; |
| 98 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 99 | data.writeStrongBinder(token); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 100 | data.writeInt32(code); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 101 | data.writeParcelable(attributionSourceState); |
| 102 | remote()->transact(FINISH_OPERATION_WITH_STATE_TRANSACTION, data, &reply); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | virtual void startWatchingMode(int32_t op, const String16& packageName, |
| 106 | const sp<IAppOpsCallback>& callback) { |
| 107 | Parcel data, reply; |
| 108 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 109 | data.writeInt32(op); |
| 110 | data.writeString16(packageName); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 111 | data.writeStrongBinder(IInterface::asBinder(callback)); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 112 | remote()->transact(START_WATCHING_MODE_TRANSACTION, data, &reply); |
| 113 | } |
| 114 | |
| 115 | virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) { |
| 116 | Parcel data, reply; |
| 117 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 118 | data.writeStrongBinder(IInterface::asBinder(callback)); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 119 | remote()->transact(STOP_WATCHING_MODE_TRANSACTION, data, &reply); |
| 120 | } |
Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 121 | |
Svetoslav | b412f6e | 2015-04-29 16:50:41 -0700 | [diff] [blame] | 122 | virtual int32_t permissionToOpCode(const String16& permission) { |
| 123 | Parcel data, reply; |
| 124 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 125 | data.writeString16(permission); |
| 126 | remote()->transact(PERMISSION_TO_OP_CODE_TRANSACTION, data, &reply); |
| 127 | // fail on exception |
| 128 | if (reply.readExceptionCode() != 0) return -1; |
| 129 | return reply.readInt32(); |
| 130 | } |
Jean-Michel Trivi | 94a566d | 2019-02-25 12:16:02 -0800 | [diff] [blame] | 131 | |
| 132 | virtual int32_t checkAudioOperation(int32_t code, int32_t usage, |
| 133 | int32_t uid, const String16& packageName) { |
| 134 | Parcel data, reply; |
| 135 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 136 | data.writeInt32(code); |
| 137 | data.writeInt32(usage); |
| 138 | data.writeInt32(uid); |
| 139 | data.writeString16(packageName); |
| 140 | remote()->transact(CHECK_AUDIO_OPERATION_TRANSACTION, data, &reply); |
| 141 | // fail on exception |
| 142 | if (reply.readExceptionCode() != 0) { |
| 143 | return MODE_ERRORED; |
| 144 | } |
| 145 | return reply.readInt32(); |
| 146 | } |
Philip P. Moltmann | 66a8777 | 2019-06-24 16:30:00 -0700 | [diff] [blame] | 147 | |
Yin-Chia Yeh | 8e95ee8 | 2019-08-13 12:24:25 -0700 | [diff] [blame] | 148 | virtual void setCameraAudioRestriction(int32_t mode) { |
| 149 | Parcel data, reply; |
| 150 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 151 | data.writeInt32(mode); |
| 152 | remote()->transact(SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION, data, &reply); |
| 153 | } |
| 154 | |
Philip P. Moltmann | 66a8777 | 2019-06-24 16:30:00 -0700 | [diff] [blame] | 155 | virtual bool shouldCollectNotes(int32_t opCode) { |
| 156 | Parcel data, reply; |
| 157 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 158 | data.writeInt32(opCode); |
| 159 | remote()->transact(SHOULD_COLLECT_NOTES_TRANSACTION, data, &reply); |
| 160 | // fail on exception |
| 161 | if (reply.readExceptionCode() != 0) { |
| 162 | return false; |
| 163 | } |
| 164 | return reply.readBool(); |
| 165 | } |
Evan Severson | 949cb3d | 2023-04-04 14:46:06 -0700 | [diff] [blame] | 166 | |
| 167 | virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName, |
| 168 | int32_t flags, const sp<IAppOpsCallback>& callback) { |
| 169 | Parcel data, reply; |
| 170 | data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); |
| 171 | data.writeInt32(op); |
| 172 | data.writeString16(packageName); |
| 173 | data.writeInt32(flags); |
| 174 | data.writeStrongBinder(IInterface::asBinder(callback)); |
| 175 | remote()->transact(START_WATCHING_MODE_WITH_FLAGS_TRANSACTION, data, &reply); |
| 176 | } |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 177 | }; |
| 178 | |
Jooyung Han | c91e3cb | 2020-11-25 06:38:17 +0900 | [diff] [blame] | 179 | IMPLEMENT_META_INTERFACE(AppOpsService, "com.android.internal.app.IAppOpsService") |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 180 | |
| 181 | // ---------------------------------------------------------------------- |
| 182 | |
Jiyong Park | b86c866 | 2018-10-29 23:01:57 +0900 | [diff] [blame] | 183 | // NOLINTNEXTLINE(google-default-arguments) |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 184 | status_t BnAppOpsService::onTransact( |
| 185 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 186 | { |
| 187 | //printf("AppOpsService received: "); data.print(); |
| 188 | switch(code) { |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 189 | case CHECK_OPERATION_WITH_STATE_TRANSACTION: { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 190 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 191 | int32_t code = data.readInt32(); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 192 | AttributionSourceState attributionSourceState; |
| 193 | status_t status = data.readParcelable(&attributionSourceState); |
| 194 | if (status != NO_ERROR) { |
| 195 | return status; |
| 196 | } |
| 197 | int32_t res = checkOperationWithState(code, attributionSourceState); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 198 | reply->writeNoException(); |
| 199 | reply->writeInt32(res); |
| 200 | return NO_ERROR; |
| 201 | } break; |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 202 | case NOTE_OPERATION_WITH_STATE_TRANSACTION: { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 203 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 204 | int32_t code = data.readInt32(); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 205 | AttributionSourceState attributionSourceState; |
| 206 | status_t status = data.readParcelable(&attributionSourceState); |
| 207 | if (status != NO_ERROR) { |
| 208 | return status; |
| 209 | } |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 210 | bool shouldCollectAsyncNotedOp = data.readBool(); |
Philip P. Moltmann | 3879cf6 | 2019-12-20 11:22:37 -0800 | [diff] [blame] | 211 | String16 message = data.readString16(); |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 212 | bool shouldCollectMessage = data.readBool(); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 213 | int32_t res = noteOperationWithState(code, attributionSourceState, |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 214 | shouldCollectAsyncNotedOp, message, shouldCollectMessage); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 215 | reply->writeNoException(); |
| 216 | reply->writeInt32(res); |
| 217 | return NO_ERROR; |
| 218 | } break; |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 219 | case START_OPERATION_WITH_STATE_TRANSACTION: { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 220 | CHECK_INTERFACE(IAppOpsService, data, reply); |
Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 221 | sp<IBinder> token = data.readStrongBinder(); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 222 | int32_t code = data.readInt32(); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 223 | AttributionSourceState attributionSourceState; |
| 224 | status_t status = data.readParcelable(&attributionSourceState); |
| 225 | if (status != NO_ERROR) { |
| 226 | return status; |
| 227 | } |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 228 | bool startIfModeDefault = data.readBool(); |
| 229 | bool shouldCollectAsyncNotedOp = data.readBool(); |
Philip P. Moltmann | 3879cf6 | 2019-12-20 11:22:37 -0800 | [diff] [blame] | 230 | String16 message = data.readString16(); |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 231 | bool shouldCollectMessage = data.readBool(); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 232 | int32_t res = startOperationWithState(token, code, attributionSourceState, |
Stanislav Zholnin | fce9ccc | 2020-07-15 02:29:01 +0100 | [diff] [blame] | 233 | startIfModeDefault, shouldCollectAsyncNotedOp, message, shouldCollectMessage); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 234 | reply->writeNoException(); |
| 235 | reply->writeInt32(res); |
| 236 | return NO_ERROR; |
| 237 | } break; |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 238 | case FINISH_OPERATION_WITH_STATE_TRANSACTION: { |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 239 | CHECK_INTERFACE(IAppOpsService, data, reply); |
Dianne Hackborn | 913b63d | 2013-07-17 17:26:15 -0700 | [diff] [blame] | 240 | sp<IBinder> token = data.readStrongBinder(); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 241 | int32_t code = data.readInt32(); |
Karishma Vakil | 14f7ae8 | 2023-08-21 17:40:30 +0000 | [diff] [blame^] | 242 | AttributionSourceState attributionSourceState; |
| 243 | status_t status = data.readParcelable(&attributionSourceState); |
| 244 | if (status != NO_ERROR) { |
| 245 | return status; |
| 246 | } |
| 247 | finishOperationWithState(token, code, attributionSourceState); |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 248 | reply->writeNoException(); |
| 249 | return NO_ERROR; |
| 250 | } break; |
| 251 | case START_WATCHING_MODE_TRANSACTION: { |
| 252 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 253 | int32_t op = data.readInt32(); |
| 254 | String16 packageName = data.readString16(); |
| 255 | sp<IAppOpsCallback> callback = interface_cast<IAppOpsCallback>(data.readStrongBinder()); |
| 256 | startWatchingMode(op, packageName, callback); |
| 257 | reply->writeNoException(); |
| 258 | return NO_ERROR; |
| 259 | } break; |
| 260 | case STOP_WATCHING_MODE_TRANSACTION: { |
| 261 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 262 | sp<IAppOpsCallback> callback = interface_cast<IAppOpsCallback>(data.readStrongBinder()); |
| 263 | stopWatchingMode(callback); |
| 264 | reply->writeNoException(); |
| 265 | return NO_ERROR; |
| 266 | } break; |
Svetoslav | b412f6e | 2015-04-29 16:50:41 -0700 | [diff] [blame] | 267 | case PERMISSION_TO_OP_CODE_TRANSACTION: { |
| 268 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 269 | String16 permission = data.readString16(); |
| 270 | const int32_t opCode = permissionToOpCode(permission); |
| 271 | reply->writeNoException(); |
| 272 | reply->writeInt32(opCode); |
| 273 | return NO_ERROR; |
| 274 | } break; |
Jean-Michel Trivi | 94a566d | 2019-02-25 12:16:02 -0800 | [diff] [blame] | 275 | case CHECK_AUDIO_OPERATION_TRANSACTION: { |
| 276 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 277 | const int32_t code = data.readInt32(); |
| 278 | const int32_t usage = data.readInt32(); |
| 279 | const int32_t uid = data.readInt32(); |
| 280 | const String16 packageName = data.readString16(); |
| 281 | const int32_t res = checkAudioOperation(code, usage, uid, packageName); |
| 282 | reply->writeNoException(); |
| 283 | reply->writeInt32(res); |
| 284 | return NO_ERROR; |
| 285 | } break; |
Yin-Chia Yeh | 8e95ee8 | 2019-08-13 12:24:25 -0700 | [diff] [blame] | 286 | case SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION: { |
| 287 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 288 | const int32_t mode = data.readInt32(); |
| 289 | setCameraAudioRestriction(mode); |
| 290 | reply->writeNoException(); |
| 291 | return NO_ERROR; |
| 292 | } break; |
Philip P. Moltmann | 66a8777 | 2019-06-24 16:30:00 -0700 | [diff] [blame] | 293 | case SHOULD_COLLECT_NOTES_TRANSACTION: { |
| 294 | CHECK_INTERFACE(IAppOpsService, data, reply); |
| 295 | int32_t opCode = data.readInt32(); |
| 296 | bool shouldCollect = shouldCollectNotes(opCode); |
| 297 | reply->writeNoException(); |
| 298 | reply->writeBool(shouldCollect); |
| 299 | return NO_ERROR; |
| 300 | } break; |
Dianne Hackborn | 5da5ca5 | 2013-02-12 15:12:21 -0800 | [diff] [blame] | 301 | default: |
| 302 | return BBinder::onTransact(code, data, reply, flags); |
| 303 | } |
| 304 | } |
| 305 | |
Steven Moreland | 6511af5 | 2019-09-26 16:05:45 -0700 | [diff] [blame] | 306 | } // namespace android |