码迷,mamicode.com
首页 > 移动开发 > 详细

Android新权限机制 AppOps

时间:2016-07-13 19:29:33      阅读:731      评论:0      收藏:0      [点我收藏+]

标签:

http://blog.csdn.net/hyhyl1990/article/details/46842915

http://m.blog.csdn.net/article/details?id=51693586

这两篇文章说的比较好了,但是并没有对void setMode ( int code,int uid,String packageName,int mode)的参数有具体的说明

code代表具体的操作权限,mode代表要更改成的类型(允许/禁止/提示)

具体权限对应的code,可以查看AppOpsManager.java源码里的描述。

好吧,又找源码,如下

http://tools.oesf.biz/android-4.3.0_r2.1/xref/frameworks/base/core/java/android/app/AppOpsManager.java

 public static final int MODE_ALLOWED = 0;
     59     public static final int MODE_IGNORED = 1;
     60     public static final int MODE_ERRORED = 2;
     61 
     62     // when adding one of these:
     63     //  - increment _NUM_OP
     64     //  - add rows to sOpToSwitch, sOpNames, sOpPerms
     65     //  - add descriptive strings to Settings/res/values/arrays.xml
     66     public static final int OP_NONE = -1;
     67     public static final int OP_COARSE_LOCATION = 0;
     68     public static final int OP_FINE_LOCATION = 1;
     69     public static final int OP_GPS = 2;
     70     public static final int OP_VIBRATE = 3;
     71     public static final int OP_READ_CONTACTS = 4;
     72     public static final int OP_WRITE_CONTACTS = 5;
     73     public static final int OP_READ_CALL_LOG = 6;
     74     public static final int OP_WRITE_CALL_LOG = 7;
     75     public static final int OP_READ_CALENDAR = 8;
     76     public static final int OP_WRITE_CALENDAR = 9;
     77     public static final int OP_WIFI_SCAN = 10;
     78     public static final int OP_POST_NOTIFICATION = 11;
     79     public static final int OP_NEIGHBORING_CELLS = 12;
     80     public static final int OP_CALL_PHONE = 13;
     81     public static final int OP_READ_SMS = 14;
     82     public static final int OP_WRITE_SMS = 15;
     83     public static final int OP_RECEIVE_SMS = 16;
     84     public static final int OP_RECEIVE_EMERGECY_SMS = 17;
     85     public static final int OP_RECEIVE_MMS = 18;
     86     public static final int OP_RECEIVE_WAP_PUSH = 19;
     87     public static final int OP_SEND_SMS = 20;
     88     public static final int OP_READ_ICC_SMS = 21;
     89     public static final int OP_WRITE_ICC_SMS = 22;
     90     public static final int OP_WRITE_SETTINGS = 23;
     91     public static final int OP_SYSTEM_ALERT_WINDOW = 24;
     92     public static final int OP_ACCESS_NOTIFICATIONS = 25;
     93     public static final int OP_CAMERA = 26;
     94     public static final int OP_RECORD_AUDIO = 27;
     95     public static final int OP_PLAY_AUDIO = 28;
     96     public static final int OP_READ_CLIPBOARD = 29;
     97     public static final int OP_WRITE_CLIPBOARD = 30;
     98     /** @hide */
     99     public static final int _NUM_OP = 31;
    100 
    101     /**
    102      * This maps each operation to the operation that serves as the
    103      * switch to determine whether it is allowed.  Generally this is
    104      * a 1:1 mapping, but for some things (like location) that have
    105      * multiple low-level operations being tracked that should be
    106      * presented to hte user as one switch then this can be used to
    107      * make them all controlled by the same single operation.
    108      */
    109     private static int[] sOpToSwitch = new int[] {
    110             OP_COARSE_LOCATION,
    111             OP_COARSE_LOCATION,
    112             OP_COARSE_LOCATION,
    113             OP_VIBRATE,
    114             OP_READ_CONTACTS,
    115             OP_WRITE_CONTACTS,
    116             OP_READ_CALL_LOG,
    117             OP_WRITE_CALL_LOG,
    118             OP_READ_CALENDAR,
    119             OP_WRITE_CALENDAR,
    120             OP_COARSE_LOCATION,
    121             OP_POST_NOTIFICATION,
    122             OP_COARSE_LOCATION,
    123             OP_CALL_PHONE,
    124             OP_READ_SMS,
    125             OP_WRITE_SMS,
    126             OP_READ_SMS,
    127             OP_READ_SMS,
    128             OP_READ_SMS,
    129             OP_READ_SMS,
    130             OP_WRITE_SMS,
    131             OP_READ_SMS,
    132             OP_WRITE_SMS,
    133             OP_WRITE_SETTINGS,
    134             OP_SYSTEM_ALERT_WINDOW,
    135             OP_ACCESS_NOTIFICATIONS,
    136             OP_CAMERA,
    137             OP_RECORD_AUDIO,
    138             OP_PLAY_AUDIO,
    139             OP_READ_CLIPBOARD,
    140             OP_WRITE_CLIPBOARD,
    141     };

 

Android新权限机制 AppOps

标签:

原文地址:http://www.cnblogs.com/heitan/p/5667554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!