blob: 22f056b2350dcd1a0e35435d7d9fefb3a9c5495b [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 Han149be4a2020-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. Moltmann90eb7ec2020-03-05 15:06:19 -080039 const std::optional<String16>& attributionTag, bool shouldCollectAsyncNotedOp,
Stanislav Zholninfce9ccc2020-07-15 02:29:01 +010040 const String16& message, bool shouldCollectMessage) = 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. Moltmann90eb7ec2020-03-05 15:06:19 -080042 const String16& packageName, const std::optional<String16>& attributionTag,
Stanislav Zholninfce9ccc2020-07-15 02:29:01 +010043 bool startIfModeDefault, bool shouldCollectAsyncNotedOp, const String16& message,
44 bool shouldCollectMessage) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070045 virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
Philip P. Moltmann90eb7ec2020-03-05 15:06:19 -080046 const String16& packageName, const std::optional<String16>& attributionTag) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080047 virtual void startWatchingMode(int32_t op, const String16& packageName,
48 const sp<IAppOpsCallback>& callback) = 0;
49 virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
Svetoslavb412f6e2015-04-29 16:50:41 -070050 virtual int32_t permissionToOpCode(const String16& permission) = 0;
Jean-Michel Trivi94a566d2019-02-25 12:16:02 -080051 virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid,
52 const String16& packageName) = 0;
Yin-Chia Yeh8e95ee82019-08-13 12:24:25 -070053 virtual void setCameraAudioRestriction(int32_t mode) = 0;
Philip P. Moltmann66a87772019-06-24 16:30:00 -070054 virtual bool shouldCollectNotes(int32_t opCode) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080055
56 enum {
57 CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
58 NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1,
59 START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2,
60 FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3,
61 START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
Dianne Hackborn913b63d2013-07-17 17:26:15 -070062 STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
Philip P. Moltmannc52e1fc2019-11-26 15:18:09 -080063 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
64 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
Philip P. Moltmann3879cf62019-12-20 11:22:37 -080065 SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
66 SET_CAMERA_AUDIO_RESTRICTION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9,
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080067 };
Eino-Ville Talvalae88a85e2013-02-19 12:54:57 -080068
69 enum {
70 MODE_ALLOWED = 0,
71 MODE_IGNORED = 1,
72 MODE_ERRORED = 2
73 };
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080074};
75
76// ----------------------------------------------------------------------
77
78class BnAppOpsService : public BnInterface<IAppOpsService>
79{
80public:
Jiyong Parkb86c8662018-10-29 23:01:57 +090081 // NOLINTNEXTLINE(google-default-arguments)
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080082 virtual status_t onTransact( uint32_t code,
83 const Parcel& data,
84 Parcel* reply,
85 uint32_t flags = 0);
86};
87
88// ----------------------------------------------------------------------
89
Steven Moreland6511af52019-09-26 16:05:45 -070090} // namespace android