| 195 | } |
| 196 | |
| 197 | Result GetLogPath(char* path, uint32_t path_len) |
| 198 | { |
| 199 | dmAndroid::ThreadAttacher thread; |
| 200 | JNIEnv* env = thread.GetEnv(); |
| 201 | if (!env) |
| 202 | { |
| 203 | return RESULT_UNKNOWN; |
| 204 | } |
| 205 | |
| 206 | Result res = RESULT_OK; |
| 207 | |
| 208 | jclass activity_class = env->FindClass("android/app/NativeActivity"); |
| 209 | jmethodID get_files_dir_method = env->GetMethodID(activity_class, "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); |
| 210 | jobject files_dir_obj = env->CallObjectMethod(thread.GetActivity()->clazz, get_files_dir_method, 0); |
| 211 | if (!files_dir_obj) |
| 212 | { |
| 213 | dmLogError("Failed to get log directory. Is android.permission.WRITE_EXTERNAL_STORAGE set in AndroidManifest.xml?"); |
| 214 | res = RESULT_UNKNOWN; |
| 215 | } |
| 216 | else |
| 217 | { |
| 218 | jclass file_class = env->FindClass("java/io/File"); |
| 219 | jmethodID getPathMethod = env->GetMethodID(file_class, "getPath", "()Ljava/lang/String;"); |
| 220 | jstring path_obj = (jstring)env->CallObjectMethod(files_dir_obj, getPathMethod); |
| 221 | if (path_obj) |
| 222 | { |
| 223 | const char* filesDir = env->GetStringUTFChars(path_obj, NULL); |
| 224 | if (dmStrlCpy(path, filesDir, path_len) >= path_len) |
| 225 | { |
| 226 | res = RESULT_INVAL; |
| 227 | } |
| 228 | env->ReleaseStringUTFChars(path_obj, filesDir); |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | res = RESULT_UNKNOWN; |
| 233 | } |
| 234 | } |
| 235 | return res; |
| 236 | } |
| 237 | |
| 238 | void FillTimeZone(SystemInfo* info) |
| 239 | { |
nothing calls this directly
no test coverage detected