NDK检测应用程序是否可调试

时间:2011-06-20 02:41:34

标签: android android-ndk

我使用以下代码检查AndroidManifest.xml中是否将debuggable标记设置为true或false。

strcpy( name, "ro.debuggable" );
__system_property_get( name, buf );
__android_log_print( ANDROID_LOG_INFO, "ro.debuggable", "%s",buf );

但不管怎样,它总是返回0 ......

我错过了什么吗?

1 个答案:

答案 0 :(得分:4)

AndroidManifest.xml中可调试标记的信息位于ApplicationInfo中。您需要在Java端获取信息。

/* exception handling code is omitted */
PackageManager pm = context.getPackageManager();
ApplicationInfo ai = new ApplicationInfo();
ai = pm.getApplicationInfo(context.getPackageName(), 0);
if ((ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) ==
        ApplicationInfo.FLAG_DEBUGGABLE ) {
    /* android:debuggable="true" */
}
相关问题