关于AndroidManifest.xml中的android:debuggable
在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.
页:
[1]