关于AndroidManifest.xml中的android:debuggable
16lz
2021-01-25
在AndroidManifest.xml中,<application>可以设置attribute android:debuggable,其值为“true”或“fasle”。
在官方文档中对它的说明如下:
Whether or not the application can be debugged, even when running on a device in user mode — "true " if it can be, and "false " if not. The default value is "false ".
那么如何获知它的设置值呢?下面的可以提供了解。
1. 如何测试APK是否设置android:debuggable="false"
在此blog中介绍的两个方法。
第一种用于对apk文件的检测。使用下面的命令(在Ubuntu中示例):
aapt list -v -a apk文件名 |grep debuggable
得到如下输出:
A: android:debuggable(0x0101000f)=(type 0x12)0x0
这表示 android:debuggable="false"
第二种为单元测试的方法(此方法还未尝试)。其原文如下:
另外,还有一种测试方法:
使用android cts测试,http://source.android.com/compatibility/cts-intro.html
这是一种单元测试的方法,具体用到的类是android.permission.cts.DebuggableTest。
testNoDebuggable :如果是true,说明debuggable false;
testNoDebuggable :如果是false,说明debuggable true。
2. [打包、发布] 程序如何知道当前的apk包是不是处于debuggable
此贴中讨论的是在程序自身运行时获取设置值。关键点可以从贴中引用的一段话体现:
Now you can check this attribute's value from your code by checking the ApplicationInfo.FLAG_DEBUGGABLE flag in the ApplicationInfo obtained from PackageManager.
在官方文档中对它的说明如下:
Whether or not the application can be debugged, even when running on a device in user mode — "true " if it can be, and "false " if not. The default value is "false ".
那么如何获知它的设置值呢?下面的可以提供了解。
1. 如何测试APK是否设置android:debuggable="false"
在此blog中介绍的两个方法。
第一种用于对apk文件的检测。使用下面的命令(在Ubuntu中示例):
aapt list -v -a apk文件名 |grep debuggable
得到如下输出:
A: android:debuggable(0x0101000f)=(type 0x12)0x0
这表示 android:debuggable="false"
第二种为单元测试的方法(此方法还未尝试)。其原文如下:
另外,还有一种测试方法:
使用android cts测试,http://source.android.com/compatibility/cts-intro.html
这是一种单元测试的方法,具体用到的类是android.permission.cts.DebuggableTest。
testNoDebuggable :如果是true,说明debuggable false;
testNoDebuggable :如果是false,说明debuggable true。
2. [打包、发布] 程序如何知道当前的apk包是不是处于debuggable
此贴中讨论的是在程序自身运行时获取设置值。关键点可以从贴中引用的一段话体现:
Now you can check this attribute's value from your code by checking the ApplicationInfo.FLAG_DEBUGGABLE flag in the ApplicationInfo obtained from PackageManager.
更多相关文章
- Android中解析XML的方法
- Android7.0 禁止锁屏状态的下拉状态栏
- Parcelable接口的使用(跨进程,Intent传输)
- Android(安卓)View 绘制流程之四:绘制流程触发机制
- Android(安卓)SDK 更新时连接出现“https://dl-ssl.google.com r
- Android(安卓)aidl学习笔记-服务端
- Android判断当前网络是否可用
- Android(安卓)mk文件中引入第三方jar包的方法
- Handler使用总结