| 308 | } |
| 309 | |
| 310 | void GetSecureInfo(SystemInfo* info) |
| 311 | { |
| 312 | dmAndroid::ThreadAttacher thread; |
| 313 | JNIEnv* env = thread.GetEnv(); |
| 314 | if (!env) |
| 315 | { |
| 316 | return; |
| 317 | } |
| 318 | jclass activity_class = env->FindClass("android/app/NativeActivity"); |
| 319 | jmethodID get_content_resolver_method = env->GetMethodID(activity_class, "getContentResolver", "()Landroid/content/ContentResolver;"); |
| 320 | jobject content_resolver = env->CallObjectMethod(thread.GetActivity()->clazz, get_content_resolver_method); |
| 321 | |
| 322 | jclass secure_class = env->FindClass("android/provider/Settings$Secure"); |
| 323 | if (secure_class) |
| 324 | { |
| 325 | jstring android_id_string = env->NewStringUTF("android_id"); |
| 326 | jmethodID get_string_method = env->GetStaticMethodID(secure_class, "getString", "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;"); |
| 327 | jstring android_id_obj = (jstring)env->CallStaticObjectMethod(secure_class, get_string_method, content_resolver, android_id_string); |
| 328 | env->DeleteLocalRef(android_id_string); |
| 329 | if (android_id_obj) |
| 330 | { |
| 331 | const char* android_id = env->GetStringUTFChars(android_id_obj, NULL); |
| 332 | dmStrlCpy(info->m_DeviceIdentifier, android_id, sizeof(info->m_DeviceIdentifier)); |
| 333 | env->ReleaseStringUTFChars(android_id_obj, android_id); |
| 334 | } |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | dmLogWarning("Unable to get 'android.id'. Is permission android.permission.READ_PHONE_STATE set?"); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | bool GetApplicationInfo(const char* id, ApplicationInfo* info) |
| 343 | { |
nothing calls this directly
no test coverage detected