blob: a5fdc54f2876643d21d469eafc4338e2ca2a003f [file] [log] [blame]
Dianne Hackborn5da5ca52013-02-12 15:12:21 -08001/*
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 Morelandc7a871e2020-11-10 21:56:57 +000017#pragma once
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080018
Karishma Vakil14f7ae82023-08-21 17:40:30 +000019#include <android/content/AttributionSourceState.h>
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080020#include <binder/IAppOpsCallback.h>
21#include <binder/IInterface.h>
22
Jooyung Han149be4a2020-01-23 12:45:10 +090023#include <optional>
24
Steven Morelandc326a942019-09-09 16:07:52 -070025#ifdef __ANDROID_VNDK__
26#error "This header is not visible to vendors"
27#endif
28
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080029namespace android {
30
Karishma Vakil14f7ae82023-08-21 17:40:30 +000031using android::content::AttributionSourceState;
32
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080033// ----------------------------------------------------------------------
34
35class IAppOpsService : public IInterface
36{
37public:
Colin Cross17576de2016-09-26 13:07:06 -070038 DECLARE_META_INTERFACE(AppOpsService)
Karishma Vakil14f7ae82023-08-21 17:40:30 +000039 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 Zholninfce9ccc2020-07-15 02:29:01 +010043 const String16& message, bool shouldCollectMessage) = 0;
Karishma Vakil14f7ae82023-08-21 17:40:30 +000044 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 Hackborn5da5ca52013-02-12 15:12:21 -080049 virtual void startWatchingMode(int32_t op, const String16& packageName,
50 const sp<IAppOpsCallback>& callback) = 0;
51 virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
Svetoslavb412f6e2015-04-29 16:50:41 -070052 virtual int32_t permissionToOpCode(const String16& permission) = 0;
Jean-Michel Trivi94a566d2019-02-25 12:16:02 -080053 virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid,
54 const String16& packageName) = 0;
Yin-Chia Yeh8e95ee82019-08-13 12:24:25 -070055 virtual void setCameraAudioRestriction(int32_t mode) = 0;
Philip P. Moltmann66a87772019-06-24 16:30:00 -070056 virtual bool shouldCollectNotes(int32_t opCode) = 0;
Evan Severson949cb3d2023-04-04 14:46:06 -070057 virtual void startWatchingModeWithFlags(int32_t op, const String16& packageName,
58 int32_t flags, const sp<IAppOpsCallback>& callback) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080059
60 enum {
Karishma Vakil14f7ae82023-08-21 17:40:30 +000061 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 Hackborn5da5ca52013-02-12 15:12:21 -080065 START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
Dianne Hackborn913b63d2013-07-17 17:26:15 -070066 STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
Philip P. Moltmannc52e1fc2019-11-26 15:18:09 -080067 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
68 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
Philip P. Moltmann3879cf62019-12-20 11:22:37 -080069 SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
70 SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9,
Evan Severson949cb3d2023-04-04 14:46:06 -070071 START_WATCHING_MODE_WITH_FLAGS_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+10,
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080072 };
Eino-Ville Talvalae88a85e2013-02-19 12:54:57 -080073
74 enum {
75 MODE_ALLOWED = 0,
76 MODE_IGNORED = 1,
77 MODE_ERRORED = 2
78 };
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080079};
80
81// ----------------------------------------------------------------------
82
83class BnAppOpsService : public BnInterface<IAppOpsService>
84{
85public:
Jiyong Parkb86c8662018-10-29 23:01:57 +090086 // NOLINTNEXTLINE(google-default-arguments)
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080087 virtual status_t onTransact( uint32_t code,
88 const Parcel& data,
89 Parcel* reply,
90 uint32_t flags = 0);
91};
92
93// ----------------------------------------------------------------------
94
Steven Moreland6511af52019-09-26 16:05:45 -070095} // namespace android