blob: 9d0237001500bdc0b394d0717d468f6cebc88aac [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
17//
18#ifndef ANDROID_IAPP_OPS_SERVICE_H
19#define ANDROID_IAPP_OPS_SERVICE_H
20
Jiyong Park47f876b2018-04-17 13:56:46 +090021#ifndef __ANDROID_VNDK__
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080022#include <binder/IAppOpsCallback.h>
Philip P. Moltmann66a87772019-06-24 16:30:00 -070023#endif
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080024#include <binder/IInterface.h>
25
26namespace android {
27
28// ----------------------------------------------------------------------
29
30class IAppOpsService : public IInterface
31{
32public:
Colin Cross17576de2016-09-26 13:07:06 -070033 DECLARE_META_INTERFACE(AppOpsService)
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080034
Philip P. Moltmann66a87772019-06-24 16:30:00 -070035#ifndef __ANDROID_VNDK__
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080036 virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0;
37 virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070038 virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
Svet Ganov616554c2018-02-26 13:27:26 -080039 const String16& packageName, bool startIfModeDefault) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070040 virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
41 const String16& packageName) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080042 virtual void startWatchingMode(int32_t op, const String16& packageName,
43 const sp<IAppOpsCallback>& callback) = 0;
44 virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070045 virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0;
Svetoslavb412f6e2015-04-29 16:50:41 -070046 virtual int32_t permissionToOpCode(const String16& permission) = 0;
Jean-Michel Trivi94a566d2019-02-25 12:16:02 -080047 virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid,
48 const String16& packageName) = 0;
Philip P. Moltmann66a87772019-06-24 16:30:00 -070049#endif // __ANDROID_VNDK__
50 virtual void noteAsyncOp(const String16& callingPackageName, int32_t uid,
51 const String16& packageName, int32_t opCode, const String16& message) = 0;
52 virtual bool shouldCollectNotes(int32_t opCode) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080053
54 enum {
Philip P. Moltmann66a87772019-06-24 16:30:00 -070055#ifndef __ANDROID_VNDK__
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080056 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,
62 GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
Svetoslavb412f6e2015-04-29 16:50:41 -070063 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
Jean-Michel Trivi94a566d2019-02-25 12:16:02 -080064 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
Philip P. Moltmann66a87772019-06-24 16:30:00 -070065#endif // __ANDROID_VNDK__
66 NOTE_ASYNC_OP_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+9,
67 SHOULD_COLLECT_NOTES_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+10,
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080068 };
Eino-Ville Talvalae88a85e2013-02-19 12:54:57 -080069
70 enum {
71 MODE_ALLOWED = 0,
72 MODE_IGNORED = 1,
73 MODE_ERRORED = 2
74 };
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080075};
76
77// ----------------------------------------------------------------------
78
79class BnAppOpsService : public BnInterface<IAppOpsService>
80{
81public:
Jiyong Parkb86c8662018-10-29 23:01:57 +090082 // NOLINTNEXTLINE(google-default-arguments)
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080083 virtual status_t onTransact( uint32_t code,
84 const Parcel& data,
85 Parcel* reply,
86 uint32_t flags = 0);
87};
88
89// ----------------------------------------------------------------------
90
91}; // namespace android
92
93#endif // ANDROID_IAPP_OPS_SERVICE_H