blob: 3dbd0d9f7af763d0fa63950fca4e5a0352616808 [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__
22
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080023#include <binder/IAppOpsCallback.h>
24#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
35 virtual int32_t checkOperation(int32_t code, int32_t uid, const String16& packageName) = 0;
36 virtual int32_t noteOperation(int32_t code, int32_t uid, const String16& packageName) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070037 virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
Svet Ganov616554c2018-02-26 13:27:26 -080038 const String16& packageName, bool startIfModeDefault) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070039 virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
40 const String16& packageName) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080041 virtual void startWatchingMode(int32_t op, const String16& packageName,
42 const sp<IAppOpsCallback>& callback) = 0;
43 virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
Dianne Hackborn913b63d2013-07-17 17:26:15 -070044 virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0;
Svetoslavb412f6e2015-04-29 16:50:41 -070045 virtual int32_t permissionToOpCode(const String16& permission) = 0;
Jean-Michel Trivi94a566d2019-02-25 12:16:02 -080046 virtual int32_t checkAudioOperation(int32_t code, int32_t usage,int32_t uid,
47 const String16& packageName) = 0;
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080048
49 enum {
50 CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
51 NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1,
52 START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2,
53 FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3,
54 START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
Dianne Hackborn913b63d2013-07-17 17:26:15 -070055 STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
56 GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
Svetoslavb412f6e2015-04-29 16:50:41 -070057 PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
Jean-Michel Trivi94a566d2019-02-25 12:16:02 -080058 CHECK_AUDIO_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+8,
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080059 };
Eino-Ville Talvalae88a85e2013-02-19 12:54:57 -080060
61 enum {
62 MODE_ALLOWED = 0,
63 MODE_IGNORED = 1,
64 MODE_ERRORED = 2
65 };
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080066};
67
68// ----------------------------------------------------------------------
69
70class BnAppOpsService : public BnInterface<IAppOpsService>
71{
72public:
Jiyong Parkb86c8662018-10-29 23:01:57 +090073 // NOLINTNEXTLINE(google-default-arguments)
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080074 virtual status_t onTransact( uint32_t code,
75 const Parcel& data,
76 Parcel* reply,
77 uint32_t flags = 0);
78};
79
80// ----------------------------------------------------------------------
81
82}; // namespace android
83
Jiyong Park47f876b2018-04-17 13:56:46 +090084#else // __ANDROID_VNDK__
85#error "This header is not visible to vendors"
86#endif // __ANDROID_VNDK__
87
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080088#endif // ANDROID_IAPP_OPS_SERVICE_H