src/core/android/SDL_android.c
changeset 9174 f9244b2a1511
parent 9173 c677ab1148c5
child 9231 ec22701132b5
     1.1 --- a/src/core/android/SDL_android.c	Mon Oct 20 10:10:39 2014 -0300
     1.2 +++ b/src/core/android/SDL_android.c	Mon Oct 20 22:19:09 2014 +0200
     1.3 @@ -77,7 +77,6 @@
     1.4  static jmethodID midAudioWriteByteBuffer;
     1.5  static jmethodID midAudioQuit;
     1.6  static jmethodID midPollInputDevices;
     1.7 -static jmethodID midSuspendScreenSaver;
     1.8  
     1.9  /* Accelerometer data storage */
    1.10  static float fLastAccelerometer[3];
    1.11 @@ -132,8 +131,6 @@
    1.12                                  "audioQuit", "()V");
    1.13      midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.14                                  "pollInputDevices", "()V");
    1.15 -    midSuspendScreenSaver = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
    1.16 -                                "suspendScreenSaver", "(Z)V");
    1.17  
    1.18      bHasNewData = false;
    1.19  
    1.20 @@ -450,12 +447,6 @@
    1.21      return s_active > 0;
    1.22  }
    1.23  
    1.24 -void Android_JNI_SuspendScreenSaver(SDL_bool suspend)
    1.25 -{
    1.26 -    JNIEnv *env = Android_JNI_GetEnv();
    1.27 -    (*env)->CallStaticObjectMethod(env, mActivityClass, midSuspendScreenSaver, suspend);
    1.28 -}
    1.29 -
    1.30  ANativeWindow* Android_JNI_GetNativeWindow(void)
    1.31  {
    1.32      ANativeWindow* anw;
    1.33 @@ -1311,6 +1302,9 @@
    1.34      (*env)->CallStaticVoidMethod(env, mActivityClass, midPollInputDevices);    
    1.35  }
    1.36  
    1.37 +/* See SDLActivity.java for constants. */
    1.38 +#define COMMAND_SET_KEEP_SCREEN_ON    5
    1.39 +
    1.40  /* sends message to be handled on the UI event dispatch thread */
    1.41  int Android_JNI_SendMessage(int command, int param)
    1.42  {
    1.43 @@ -1326,6 +1320,11 @@
    1.44      return success ? 0 : -1;
    1.45  }
    1.46  
    1.47 +void Android_JNI_SuspendScreenSaver(SDL_bool suspend)
    1.48 +{
    1.49 +    Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1);
    1.50 +}
    1.51 +
    1.52  void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
    1.53  {
    1.54      JNIEnv *env = Android_JNI_GetEnv();