On Android the device doesn't lock when the power button is pushed and an app with FLAG_KEEP_SCREEN_ON runs in the foreground.
Adding the FLAG_ALLOW_LOCK_WHILE_SCREEN_ON flag in addition to FLAG_KEEP_SCREEN_ON, makes it possible to keep the screen on when the app is running and still lock the device when the power button is pressed.
On Android the device doesn't lock when the power button is pushed and an app with FLAG_KEEP_SCREEN_ON runs in the foreground.
Adding the FLAG_ALLOW_LOCK_WHILE_SCREEN_ON flag in addition to FLAG_KEEP_SCREEN_ON, makes it possible to keep the screen on when the app is running and still lock the device when the power button is pressed.