setScreenSaverEnabled logic inverted on Android?

Hi all,

I have the feeling that the logic in setScreenSaverEnabled is inverted in Android.
When I call “Desktop::getInstance().setScreenSaverEnabled(false);”, I don’t have the same behavior on Android and Windows.
On windows, as expected, the screensaver is disabled.
On Android, I have to call “Desktop::getInstance().setScreenSaverEnabled(true);” to disable the screen saver.
I might be wrong, but in juce_Android_windowing.cpp, the logic is wrong in the ternary operator
env->CallVoidMethod(mainWindow.get(), AndroidWindow.setFlags, shouldEnable ? FLAG_KEEP_SCREEN_ON : 0, FLAG_KEEP_SCREEN_ON);

I would change it to
env->CallVoidMethod(mainWindow.get(), AndroidWindow.setFlags, shouldEnable ? 0 : FLAG_KEEP_SCREEN_ON, FLAG_KEEP_SCREEN_ON);

Also, the static variable default value should be changed I guess
static bool androidScreenSaverEnabled = true;

Thanks for your help

Thanks for the report! This is fixed on the develop and juce6 branches now.

1 Like