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
24namespace android {
25
26// ----------------------------------------------------------------------
27
28class IAppOpsService : public IInterface
29{
30public:
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
44    enum {
45        CHECK_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
46        NOTE_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+1,
47        START_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+2,
48        FINISH_OPERATION_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+3,
49        START_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+4,
50        STOP_WATCHING_MODE_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+5,
51        GET_TOKEN_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+6,
52    };
53
54    enum {
55        MODE_ALLOWED = 0,
56        MODE_IGNORED = 1,
57        MODE_ERRORED = 2
58    };
59};
60
61// ----------------------------------------------------------------------
62
63class BnAppOpsService : public BnInterface<IAppOpsService>
64{
65public:
66    virtual status_t    onTransact( uint32_t code,
67                                    const Parcel& data,
68                                    Parcel* reply,
69                                    uint32_t flags = 0);
70};
71
72// ----------------------------------------------------------------------
73
74}; // namespace android
75
76#endif // ANDROID_IAPP_OPS_SERVICE_H
77