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