blob: ea339527aee03a5de9605a1ec01c77c0dbd1ca14 [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#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 {
Eino-Ville Talvalae88a85e2013-02-19 12:54:57 -080031 MODE_ALLOWED = IAppOpsService::MODE_ALLOWED,
32 MODE_IGNORED = IAppOpsService::MODE_IGNORED,
33 MODE_ERRORED = IAppOpsService::MODE_ERRORED
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080034 };
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,
Svet Ganovf1377f52015-04-28 12:09:01 -070066 OP_PLAY_AUDIO = 28,
67 OP_READ_CLIPBOARD = 29,
68 OP_WRITE_CLIPBOARD = 30,
69 OP_TAKE_MEDIA_BUTTONS = 31,
70 OP_TAKE_AUDIO_FOCUS = 32,
71 OP_AUDIO_MASTER_VOLUME = 33,
72 OP_AUDIO_VOICE_VOLUME = 34,
73 OP_AUDIO_RING_VOLUME = 35,
74 OP_AUDIO_MEDIA_VOLUME = 36,
75 OP_AUDIO_ALARM_VOLUME = 37,
76 OP_AUDIO_NOTIFICATION_VOLUME = 38,
77 OP_AUDIO_BLUETOOTH_VOLUME = 39,
78 OP_WAKE_LOCK = 40,
79 OP_MONITOR_LOCATION = 41,
80 OP_MONITOR_HIGH_POWER_LOCATION = 42,
81 OP_GET_USAGE_STATS = 43,
82 OP_MUTE_MICROPHONE = 44,
83 OP_TOAST_WINDOW = 45,
84 OP_PROJECT_MEDIA = 46,
85 OP_ACTIVATE_VPN = 47,
86 OP_WRITE_WALLPAPER = 48,
87 OP_ASSIST_STRUCTURE = 49,
88 OP_ASSIST_SCREENSHOT = 50,
89 OP_READ_PHONE_STATE = 51,
90 OP_ADD_VOICEMAIL = 52
Dianne Hackborn5da5ca52013-02-12 15:12:21 -080091 };
92
93 AppOpsManager();
94
95 int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage);
96 int32_t noteOp(int32_t op, int32_t uid, const String16& callingPackage);
97 int32_t startOp(int32_t op, int32_t uid, const String16& callingPackage);
98 void finishOp(int32_t op, int32_t uid, const String16& callingPackage);
99 void startWatchingMode(int32_t op, const String16& packageName,
100 const sp<IAppOpsCallback>& callback);
101 void stopWatchingMode(const sp<IAppOpsCallback>& callback);
102
103private:
104 Mutex mLock;
105 sp<IAppOpsService> mService;
106
107 sp<IAppOpsService> getService();
108};
109
110
111}; // namespace android
112// ---------------------------------------------------------------------------
113#endif // ANDROID_APP_OPS_MANAGER_H