Fixed setting of screen saver state crashing on some version of Android.
Setting Window flags seems to affect Views and must be handled on UI thread.
This commit is contained in:
parent
0ec4fc6589
commit
69e989c667
2 changed files with 21 additions and 17 deletions
|
@ -77,7 +77,6 @@ static jmethodID midAudioWriteShortBuffer;
|
|||
static jmethodID midAudioWriteByteBuffer;
|
||||
static jmethodID midAudioQuit;
|
||||
static jmethodID midPollInputDevices;
|
||||
static jmethodID midSuspendScreenSaver;
|
||||
|
||||
/* Accelerometer data storage */
|
||||
static float fLastAccelerometer[3];
|
||||
|
@ -132,8 +131,6 @@ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls)
|
|||
"audioQuit", "()V");
|
||||
midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||
"pollInputDevices", "()V");
|
||||
midSuspendScreenSaver = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
|
||||
"suspendScreenSaver", "(Z)V");
|
||||
|
||||
bHasNewData = false;
|
||||
|
||||
|
@ -450,12 +447,6 @@ static SDL_bool LocalReferenceHolder_IsActive()
|
|||
return s_active > 0;
|
||||
}
|
||||
|
||||
void Android_JNI_SuspendScreenSaver(SDL_bool suspend)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
(*env)->CallStaticObjectMethod(env, mActivityClass, midSuspendScreenSaver, suspend);
|
||||
}
|
||||
|
||||
ANativeWindow* Android_JNI_GetNativeWindow(void)
|
||||
{
|
||||
ANativeWindow* anw;
|
||||
|
@ -1311,6 +1302,9 @@ void Android_JNI_PollInputDevices()
|
|||
(*env)->CallStaticVoidMethod(env, mActivityClass, midPollInputDevices);
|
||||
}
|
||||
|
||||
/* See SDLActivity.java for constants. */
|
||||
#define COMMAND_SET_KEEP_SCREEN_ON 5
|
||||
|
||||
/* sends message to be handled on the UI event dispatch thread */
|
||||
int Android_JNI_SendMessage(int command, int param)
|
||||
{
|
||||
|
@ -1326,6 +1320,11 @@ int Android_JNI_SendMessage(int command, int param)
|
|||
return success ? 0 : -1;
|
||||
}
|
||||
|
||||
void Android_JNI_SuspendScreenSaver(SDL_bool suspend)
|
||||
{
|
||||
Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1);
|
||||
}
|
||||
|
||||
void Android_JNI_ShowTextInput(SDL_Rect *inputRect)
|
||||
{
|
||||
JNIEnv *env = Android_JNI_GetEnv();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue