AndroidManifest——add custom permission
来源:互联网 发布:ioc java 编辑:程序博客网 时间:2024/05/19 02:31
1、首先,在Android系统源代码中,给API接口添加权限的位置为:frameworks/base/core/res/AndroidManifest.xml
2、添加自定义权限的语法规则为:(frameworks/base/core/res/AndroidManifest.xml)
<permission android:name="android.permission.SYSTEMCONTROL"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
android:protectionLevel="normal"
android:description="@string/system_ctl"
android:label="normal" />
<permission-group android:name="android.permission-group.SYSTEM_TOOLS"
android:label="@string/permgrouplab_systemTools"
android:icon="@drawable/perm_group_system_tools"
android:description="@string/permgroupdesc_systemTools"
android:priority="100" />
3、在frameworks/base/core/res/res/values/string.xml中添加:
<string name="system_ctl">is access to system control!</string>
<string name="permgrouplab_systemTools">System tools</string>
<string name="permgroupdesc_systemTools">Lower-level access and controls of the system.</string>等2中相关的信息
4、然后,在源码中添加完权限之后,在eclipse中写用到这些权限的API的测试用例时,需要在测试项目的AndroidManifest.xml中写上:
5、API接口类的方法中的框架为:
public class SystemControl {static Context mContext = null;private static final String TAG = "systemcontrol";private static final boolean DBG = true; public SystemControl(Context mCont) {mContext = mCont;} public static String checkSystemUpdate(String cfgFile) {String res = null;if (mContext == null)return res;if (mContext.checkCallingOrSelfPermission("android.permission.SYSTEMCONTROL") != PackageManager.PERMISSION_GRANTED) {if (DBG)Log.d(TAG, "is not have permission");return res;}if (DBG)Log.d(TAG,"============== checkSystemUpdate() ==================\n"); /*write function*/ return res;}6、在测试的时候,可以适当的添加一下Log.i(“dd”,"ddd");Log.e(" "," ");来进行调试。
- AndroidManifest——add custom permission
- AndroidManifest.xml——permission
- AndroidManifest.xml——grant-uri-permission
- AndroidManifest.xml——path-permission
- AndroidManifest.xml——permission-group
- AndroidManifest.xml——permission-tree
- AndroidManifest.xml 详解 (四) 之uses-permission—— 译自《Beginning Android Games》
- AndroidManifest.xml 之uses-permission
- AndroidManifest配置之uses-permission
- Android—debug Unable to add window android.view.View--permission denied for this window type .
- How to add custom scripts
- add custom font on iOS
- AndroidManifest.xml文件详解(permission)
- AndroidManifest.xml文件详解(path-permission)
- AndroidManifest.xml文件详解(permission-group)
- AndroidManifest.xml文件详解(permission-tree)
- AndroidManifest.xml文件详解(uses-permission)
- AndroidManifest.xml文件详解(permission)
- javacc安装教程
- CvArr、Mat、CvMat、IplImage、BYTE转换
- PHP判断手机端、PC端 、微信代码实例
- YOLO在windows下的配置
- 基于注解和反射的Java ORM框架(2)-设计理念
- AndroidManifest——add custom permission
- LayoutInflater的inflate方法参数
- 【蓝桥杯】错误票据
- 科锐课堂笔记:2017/3/16 二级指针与函数指针
- 噩梦射手(SurvivalShooter)教程(十)
- TCP可靠传输的实现
- 最长回文子串的4种解法
- 基于注解和反射的Java ORM框架(3)-极速CRUD操作
- MVC框架