blob: b0719d4ebc0966ca4e4dff0b02c4c2d01ff0c3b5 [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
19#include <binder/IAppOpsCallback.h>
20#include <binder/IInterface.h>
21
Jooyung Han2d5878e2020-01-23 12:45:10 +090022#include <optional>
23
Steven Morelandc326a942019-09-09 16:07:52 -070024#ifdef __ANDROID_VNDK__
25#error "This header is not visible to vendors"
26#endif
27
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080028namespace android {
29
30// ----------------------------------------------------------------------
31
32class IAppOpsService : public IInterface
33{
34public:
Colin Cross17576de2016-09-26 13:07:06 -070035 DECLARE_META_INTERFACE(AppOpsService)
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080036
37 virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0;
Philip P. Moltmannaeaaf1c2019-11-05 12:34:36 -080038 virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName,
Philip P. Moltmann3f6efd82020-03-05 15:06:19 -080039 const std::optional<String16>& attributionTag, bool shouldCollectAsyncNotedOp,
Philip P. Moltmann3879cf62019-12-20 11:22:37 -080040 const String16& message) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070041 virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
Philip P. Moltmann3f6efd82020-03-05 15:06:19 -080042 const String16& packageName, const std::optional<String16>& attributionTag,
Philip P. Moltmann3879cf62019-12-20 11:22:37 -080043 bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070044 virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
Philip P. Moltmann3f6efd82020-03-05 15:06:19 -080045 const String16& packageName, const std::optional<String16>& attributionTag) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080046 virtual void startWatchingMode(int32_t op, const String16& packageName,
47 const sp<IAppOpsCallback>& callback) = 0;
48 virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
Svetoslavb412f6e2015-04-29 16:50:41 -070049 virtual int32_t permissionToOpCode(const String16& permission) = 0;
Jean-Michel Trivi94a566d2019-02-25 12:16:02 -080050 virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid,
51 const String16& packageName) = 0;
Yin-Chia Yeh8e95ee82019-08-13 12:24:25 -070052 virtual void setCameraAudioRestriction(int32_t mode) = 0;
Philip P. Moltmann66a87772019-06-24 16:30:00 -070053 virtual bool shouldCollectNotes(int32_t opCode) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080054
55 enum {
56 CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
57 NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1,
58 START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2,
59 FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3,
60 START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
Dianne Hackborn913b63d2013-07-17 17:26:15 -070061 STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
Philip P. Moltmannc52e1fc2019-11-26 15:18:09 -080062 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
63 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
Philip P. Moltmann3879cf62019-12-20 11:22:37 -080064 SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
65 SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9,
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080066 };
Eino-Ville Talvalae88a85e2013-02-19 12:54:57 -080067
68 enum {
69 MODE_ALLOWED = 0,
70 MODE_IGNORED = 1,
71 MODE_ERRORED = 2
72 };
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080073};
74
75// ----------------------------------------------------------------------
76
77class BnAppOpsService : public BnInterface<IAppOpsService>
78{
79public:
Jiyong Parkb86c8662018-10-29 23:01:57 +090080 // NOLINTNEXTLINE(google-default-arguments)
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080081 virtual status_t onTransact( uint32_t code,
82 const Parcel& data,
83 Parcel* reply,
84 uint32_t flags = 0);
85};
86
87// ----------------------------------------------------------------------
88
Steven Moreland6511af52019-09-26 16:05:45 -070089} // namespace android