AppOpsManager.h revision e88a85e0d0a25c943e974114557770ba10b81847
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#ifndef ANDROID_APP_OPS_MANAGER_H
18#define ANDROID_APP_OPS_MANAGER_H
19
20#include <binder/IAppOpsService.h>
21
22#include <utils/threads.h>
23
24// ---------------------------------------------------------------------------
25namespace android {
26
27class AppOpsManager
28{
29public:
30    enum {
31        MODE_ALLOWED = IAppOpsService::MODE_ALLOWED,
32        MODE_IGNORED = IAppOpsService::MODE_IGNORED,
33        MODE_ERRORED = IAppOpsService::MODE_ERRORED
34    };
35
36    enum {
37        OP_NONE = -1,
38        OP_COARSE_LOCATION = 0,
39        OP_FINE_LOCATION = 1,
40        OP_GPS = 2,
41        OP_VIBRATE = 3,
42        OP_READ_CONTACTS = 4,
43        OP_WRITE_CONTACTS = 5,
44        OP_READ_CALL_LOG = 6,
45        OP_WRITE_CALL_LOG = 7,
46        OP_READ_CALENDAR = 8,
47        OP_WRITE_CALENDAR = 9,
48        OP_WIFI_SCAN = 10,
49        OP_POST_NOTIFICATION = 11,
50        OP_NEIGHBORING_CELLS = 12,
51        OP_CALL_PHONE = 13,
52        OP_READ_SMS = 14,
53        OP_WRITE_SMS = 15,
54        OP_RECEIVE_SMS = 16,
55        OP_RECEIVE_EMERGECY_SMS = 17,
56        OP_RECEIVE_MMS = 18,
57        OP_RECEIVE_WAP_PUSH = 19,
58        OP_SEND_SMS = 20,
59        OP_READ_ICC_SMS = 21,
60        OP_WRITE_ICC_SMS = 22,
61        OP_WRITE_SETTINGS = 23,
62        OP_SYSTEM_ALERT_WINDOW = 24,
63        OP_ACCESS_NOTIFICATIONS = 25,
64        OP_CAMERA = 26,
65        OP_RECORD_AUDIO = 27,
66        OP_PLAY_AUDIO = 28
67    };
68
69    AppOpsManager();
70
71    int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage);
72    int32_t noteOp(int32_t op, int32_t uid, const String16& callingPackage);
73    int32_t startOp(int32_t op, int32_t uid, const String16& callingPackage);
74    void finishOp(int32_t op, int32_t uid, const String16& callingPackage);
75    void startWatchingMode(int32_t op, const String16& packageName,
76            const sp<IAppOpsCallback>& callback);
77    void stopWatchingMode(const sp<IAppOpsCallback>& callback);
78
79private:
80    Mutex mLock;
81    sp<IAppOpsService> mService;
82
83    sp<IAppOpsService> getService();
84};
85
86
87}; // namespace android
88// ---------------------------------------------------------------------------
89#endif // ANDROID_APP_OPS_MANAGER_H
90