1 /*
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 
21 #ifndef __ANDROID_VNDK__
22 
23 #include <binder/IAppOpsCallback.h>
24 #include <binder/IInterface.h>
25 
26 namespace android {
27 
28 // ----------------------------------------------------------------------
29 
30 class IAppOpsService : public IInterface
31 {
32 public:
33     DECLARE_META_INTERFACE(AppOpsService)
34 
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;
37     virtual int32_t startOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
38             const String16& packageName, bool startIfModeDefault) = 0;
39     virtual void finishOperation(const sp<IBinder>& token, int32_t code, int32_t uid,
40             const String16& packageName) = 0;
41     virtual void startWatchingMode(int32_t op, const String16& packageName,
42             const sp<IAppOpsCallback>& callback) = 0;
43     virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) = 0;
44     virtual sp<IBinder> getToken(const sp<IBinder>& clientToken) = 0;
45     virtual int32_t permissionToOpCode(const String16& permission) = 0;
46 
47     enum {
48         CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
49         NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1,
50         START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2,
51         FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3,
52         START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
53         STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
54         GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
55         PERMISSION_TO_OP_CODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+7,
56     };
57 
58     enum {
59         MODE_ALLOWED = 0,
60         MODE_IGNORED = 1,
61         MODE_ERRORED = 2
62     };
63 };
64 
65 // ----------------------------------------------------------------------
66 
67 class BnAppOpsService : public BnInterface<IAppOpsService>
68 {
69 public:
70     virtual status_t    onTransact( uint32_t code,
71                                     const Parcel& data,
72                                     Parcel* reply,
73                                     uint32_t flags = 0);
74 };
75 
76 // ----------------------------------------------------------------------
77 
78 }; // namespace android
79 
80 #else // __ANDROID_VNDK__
81 #error "This header is not visible to vendors"
82 #endif // __ANDROID_VNDK__
83 
84 #endif // ANDROID_IAPP_OPS_SERVICE_H
85