Home | History | Annotate | Download | only in binder
      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 // ---------------------------------------------------------------------------
     25 namespace android {
     26 
     27 class AppOpsManager
     28 {
     29 public:
     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         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,
     91         OP_USE_SIP = 53,
     92         OP_PROCESS_OUTGOING_CALLS = 54,
     93         OP_USE_FINGERPRINT = 55,
     94         OP_BODY_SENSORS = 56,
     95         OP_AUDIO_ACCESSIBILITY_VOLUME = 64,
     96     };
     97 
     98     AppOpsManager();
     99 
    100     int32_t checkOp(int32_t op, int32_t uid, const String16& callingPackage);
    101     int32_t noteOp(int32_t op, int32_t uid, const String16& callingPackage);
    102     int32_t startOp(int32_t op, int32_t uid, const String16& callingPackage);
    103     void finishOp(int32_t op, int32_t uid, const String16& callingPackage);
    104     void startWatchingMode(int32_t op, const String16& packageName,
    105             const sp<IAppOpsCallback>& callback);
    106     void stopWatchingMode(const sp<IAppOpsCallback>& callback);
    107     int32_t permissionToOpCode(const String16& permission);
    108 
    109 private:
    110     Mutex mLock;
    111     sp<IAppOpsService> mService;
    112 
    113     sp<IAppOpsService> getService();
    114 };
    115 
    116 
    117 }; // namespace android
    118 // ---------------------------------------------------------------------------
    119 #endif // ANDROID_APP_OPS_MANAGER_H
    120