| 914 | } |
| 915 | |
| 916 | void keepScreenOn() { |
| 917 | |
| 918 | // Attaches the current thread to the JVM. |
| 919 | jint lResult; |
| 920 | jint lFlags = 0; |
| 921 | JavaVM* lJavaVM = platState.engine->app->activity->vm; |
| 922 | JNIEnv* lJNIEnv = platState.engine->app->activity->env; |
| 923 | |
| 924 | JavaVMAttachArgs lJavaVMAttachArgs; |
| 925 | lJavaVMAttachArgs.version = JNI_VERSION_1_6; |
| 926 | lJavaVMAttachArgs.name = "NativeThread"; |
| 927 | lJavaVMAttachArgs.group = NULL; |
| 928 | |
| 929 | lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs); |
| 930 | if (lResult == JNI_ERR) { |
| 931 | return; |
| 932 | } |
| 933 | |
| 934 | // Retrieves NativeActivity. |
| 935 | jobject lNativeActivity = platState.engine->app->activity->clazz; |
| 936 | jclass ClassNativeActivity = lJNIEnv->GetObjectClass(lNativeActivity); |
| 937 | |
| 938 | // Runs getWindow().getDecorView(). |
| 939 | jmethodID MethodGetWindow = lJNIEnv->GetMethodID( |
| 940 | ClassNativeActivity, "getWindow", |
| 941 | "()Landroid/view/Window;"); |
| 942 | jobject lWindow = lJNIEnv->CallObjectMethod(lNativeActivity, |
| 943 | MethodGetWindow); |
| 944 | jclass ClassWindow = lJNIEnv->FindClass( |
| 945 | "android/view/Window"); |
| 946 | jmethodID MethodGetDecorView = lJNIEnv->GetMethodID( |
| 947 | ClassWindow, "getDecorView", "()Landroid/view/View;"); |
| 948 | jobject lDecorView = lJNIEnv->CallObjectMethod(lWindow, |
| 949 | MethodGetDecorView); |
| 950 | |
| 951 | jclass ClassView = lJNIEnv->FindClass("android/view/View"); |
| 952 | jmethodID MethodSetKeepScreenOn = lJNIEnv->GetMethodID( |
| 953 | ClassView, "setKeepScreenOn", "(Z)V"); |
| 954 | jboolean on = true; |
| 955 | lJNIEnv->CallVoidMethod(lDecorView, MethodSetKeepScreenOn, on); |
| 956 | |
| 957 | // Finished with the JVM. |
| 958 | lJavaVM->DetachCurrentThread(); |
| 959 | } |
| 960 | |
| 961 | void T2DActivity::loadCacheDir() { |
| 962 | |