About: Fixes Bug 1896 - Android app is running while the screen is locked

About: Fixes Bug 1896 - Android app is running while the screen is locked

When the android device has a security lock screen enabled then when you
lock the screen it pauses
but when you unlock the screen with the hard button and you see the
android unlock screen (slide to unlock)
it un-pauses and even play the game music.

Is this supposed to happen?

Thanks
Giorgos

2013/7/8 Giorgos Sarris

About: Fixes Bug 1896 - Android app is running while the screen is lockedhttp://hg.libsdl.org/SDL/raw-rev/1aadd7170248

When the android device has a security lock screen enabled then when you
lock the screen it pauses
but when you unlock the screen with the hard button and you see the
android unlock screen (slide to unlock)
it un-pauses and even play the game music.

Is this supposed to happen?

Thanks
Giorgos


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

On my phone, a Nexus 4, this is not what I’m seeing. I lock the screen with
the power button, the app suspends and music stops. If I wake up the device
with the power button again, I see the unlock screen, but the app remains
paused. When I enter the unlock code, it comes back to life.

Can you provide more information on your device, Android version, and more
importantly, can you check the adb log and see what events the app is
getting when you turn it on, pre unlock and post unlock?–
Gabriel.

There’s definitively something different in our devices. On mine I get the
"Lock screen displayed!" message, but my app doesn’t get the onResume
message until after I enter the unlock code.

So, two questions:

  1. Do you have any customizations on your app manifest or configuration
    that can make this happen?
  2. Thinking out loud here, but if this is an Android problem, how to work
    around it? Basically how do we detect the lock screen is active.

Can anyone else pitch in with a quick test?

Gabriel.

2013/7/8 Giorgos Sarris > Gabriel,

I attach the log.
In the log (onPause and onResume)

  1. I press the ‘lock key’ I see blank screen and the music stops.
  2. I press it again and I see the lock screen but the music started.
  3. I unlock the screen and see the app normally.

I have a galaxy tab 2 with 4.0.4 OS.

Thanks,
Giorgos

-------- Original Message --------
Subject: Re: [SDL] About: Fixes Bug 1896 - Android app is running while
the screen is locked
From: Gabriel Jacobo <@Gabriel_Jacobo> <@Gabriel_Jacobo>
To: SDL Development List
Date: 08/07/2013 14:53

2013/7/8 Giorgos Sarris

About: Fixes Bug 1896 - Android app is running while the screen is
locked http://hg.libsdl.org/SDL/raw-rev/1aadd7170248

When the android device has a security lock screen enabled then when you
lock the screen it pauses
but when you unlock the screen with the hard button and you see the
android unlock screen (slide to unlock)
it un-pauses and even play the game music.

Is this supposed to happen?

Thanks
Giorgos


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

On my phone, a Nexus 4, this is not what I’m seeing. I lock the screen
with the power button, the app suspends and music stops. If I wake up the
device with the power button again, I see the unlock screen, but the app
remains paused. When I enter the unlock code, it comes back to life.

Can you provide more information on your device, Android version, and
more importantly, can you check the adb log and see what events the app is
getting when you turn it on, pre unlock and post unlock?


Gabriel.


SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.

Every device behaves differently.
I have already fixed the problem manually with this:

// Events
protected void onPause() {
super.onPause();

Log.v(“SDL”, “onPause”);
// If the screen is off then the device has been locked
PowerManager powerManager = (PowerManager)
getSystemService(POWER_SERVICE);
boolean isScreenOn = powerManager.isScreenOn();

//Screen locked
if (!isScreenOn) {
if (screenLock == 0){
screenLock = 1;
Log.v(“SDL”, "screen locked: " + screenLock);
// The screen has been locked
PauseMusic();
}
}
}

protected void onResume() {
super.onResume();

Log.v(“SDL”, “onResume”);

KeyguardManager km = (KeyguardManager)
getSystemService(Context.KEYGUARD_SERVICE);
boolean screenlocked = km.inKeyguardRestrictedInputMode();
//Log.v(“SDL”, "locked " + screenlocked);

if (screenlocked == false){
if (screenLock != 0){
screenLock = 0;
Log.v(“SDL”, "screen unlocked: " + screenLock);
// The screen has been unlocked
ResumeMusic();
}
}
}

public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);

//Log.v(“SDL”, “onWindowFocusChanged”);
if(hasFocus){
if (screenLock != 0){
screenLock = 0;
Log.v(“SDL”, "screen unlocked: " + screenLock);
// The screen has been unlocked
ResumeMusic();
}
}
}> ----- Original Message -----

Subject: Re: [SDL] About: Fixes Bug 1896 - Android app is running while
the screen is locked
From: Gabriel Jacobo
To: SDL Development List
Date: 08/07/2013 18:08

There’s definitively something different in our devices. On mine I get
the “Lock screen displayed!” message, but my app doesn’t get the
onResume message until after I enter the unlock code.
So, two questions:

  1. Do you have any customizations on your app manifest or configuration
    that can make this happen?
  2. Thinking out loud here, but if this is an Android problem, how to
    work around it? Basically how do we detect the lock screen is active.
    Can anyone else pitch in with a quick test?
    Gabriel.

2013/7/8 Giorgos Sarris <@Giorgos_Sarris>

Gabriel,

I attach the log.
In the log (onPause and onResume)
1) I press the 'lock key' I see blank screen and the music stops.
2) I press it again and I see the lock screen but the music started.
3) I unlock the screen and see the app normally.

I have a galaxy tab 2 with 4.0.4 OS.

Thanks,
Giorgos

-------- Original Message --------
Subject: Re: [SDL] About: Fixes Bug 1896 - Android app is running
while the screen is locked
From: Gabriel Jacobo
To: SDL Development List
Date: 08/07/2013 14:53

  2013/7/8 Giorgos Sarris <@Giorgos_Sarris>

    About: Fixes Bug 1896 - Android app is running while the screen is
    locked

    When the android device has a security lock screen enabled then
    when you lock the screen it pauses
    but when you unlock the screen with the hard button and you see
    the android unlock screen (slide to unlock)
    it un-pauses and even play the game music.

    Is this supposed to happen?

    Thanks
    Giorgos
    _______________________________________________
    SDL mailing list
    SDL@lists.libsdl.org
    http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  On my phone, a Nexus 4, this is not what I'm seeing. I lock the
  screen with the power button, the app suspends and music stops. If I
  wake up the device with the power button again, I see the unlock
  screen, but the app remains paused. When I enter the unlock code, it
  comes back to life.
  Can you provide more information on your device, Android version,
  and more importantly, can you check the adb log and see what events
  the app is getting when you turn it on, pre unlock and post unlock?
  --
  Gabriel.

SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.


SDL mailing list
SDL@lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I can’t tell for sure since the logcat output hasn’t arrived to the
mailing list, or so it seems. I understand that onResume arrives when
the screen is powered on in your case, though.

Based on the following article, it may be a bit tricky to solve this, if
even possible in a generic form (i.e. from SDL’s side only, not the game’s):

It does give out a way that may work on more environments (but not
necessarily all), involving onPause, onResume and onFocusChanged.On 07/08/2013 06:08 PM, Gabriel Jacobo wrote:

There’s definitively something different in our devices. On mine I get
the “Lock screen displayed!” message, but my app doesn’t get the
onResume message until after I enter the unlock code.

So, two questions:

  1. Do you have any customizations on your app manifest or configuration
    that can make this happen?
  2. Thinking out loud here, but if this is an Android problem, how to
    work around it? Basically how do we detect the lock screen is active.

Can anyone else pitch in with a quick test?

Gabriel.

2013/7/8 Giorgos Sarris <giorgos at crazysoft.gr <mailto:giorgos at crazysoft.gr>>

Gabriel,

I attach the log.
In the log (onPause and onResume)
1) I press the 'lock key' I see blank screen and the music stops.
2) I press it again and I see the lock screen but the music started.
3) I unlock the screen and see the app normally.

I have a galaxy tab 2 with 4.0.4 OS.

Thanks,
Giorgos

This should be fixed here http://hg.libsdl.org/SDL/rev/07c5fcdd3cad , let
me know if it works for you.

2013/7/8 Giorgos Sarris > Every device behaves differently.

I have already fixed the problem manually with this:

// Events
protected void onPause() {
    super.onPause();

    Log.v("SDL", "onPause");
    // If the screen is off then the device has been locked
    PowerManager powerManager = (PowerManager)

getSystemService(POWER_SERVICE);
boolean isScreenOn = powerManager.isScreenOn();

    //Screen locked
    if (!isScreenOn) {
        if (screenLock == 0){
            screenLock = 1;
            Log.v("SDL", "screen locked: " + screenLock);
            // The screen has been locked
            PauseMusic();
        }
    }
}

protected void onResume() {
    super.onResume();

    Log.v("SDL", "onResume");

    KeyguardManager km = (KeyguardManager)

getSystemService(Context.KEYGUARD_SERVICE);
boolean screenlocked = km.inKeyguardRestrictedInputMode();
//Log.v(“SDL”, "locked " + screenlocked);

    if (screenlocked == false){
        if (screenLock != 0){
            screenLock = 0;
            Log.v("SDL", "screen unlocked: " + screenLock);
            // The screen has been unlocked
            ResumeMusic();
        }
    }
}

public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    //Log.v("SDL", "onWindowFocusChanged");
    if(hasFocus){
       if (screenLock != 0){
           screenLock = 0;
           Log.v("SDL", "screen unlocked: " + screenLock);
           // The screen has been unlocked
           ResumeMusic();
       }
    }
}

-------- Original Message --------
Subject: Re: [SDL] About: Fixes Bug 1896 - Android app is running while
the screen is locked
From: Gabriel Jacobo <@Gabriel_Jacobo> <@Gabriel_Jacobo>
To: SDL Development List
Date: 08/07/2013 18:08

There’s definitively something different in our devices. On mine I get the
"Lock screen displayed!" message, but my app doesn’t get the onResume
message until after I enter the unlock code.

So, two questions:

  1. Do you have any customizations on your app manifest or configuration
    that can make this happen?
  2. Thinking out loud here, but if this is an Android problem, how to work
    around it? Basically how do we detect the lock screen is active.

Can anyone else pitch in with a quick test?

Gabriel.

2013/7/8 Giorgos Sarris

Gabriel,

I attach the log.
In the log (onPause and onResume)

  1. I press the ‘lock key’ I see blank screen and the music stops.
  2. I press it again and I see the lock screen but the music started.
  3. I unlock the screen and see the app normally.

I have a galaxy tab 2 with 4.0.4 OS.

Thanks,
Giorgos

-------- Original Message --------
Subject: Re: [SDL] About: Fixes Bug 1896 - Android app is running while
the screen is locked
From: Gabriel Jacobo <@Gabriel_Jacobo> <@Gabriel_Jacobo>
To: SDL Development List
Date: 08/07/2013 14:53

2013/7/8 Giorgos Sarris

About: Fixes Bug 1896 - Android app is running while the screen is
locked http://hg.libsdl.org/SDL/raw-rev/1aadd7170248

When the android device has a security lock screen enabled then when you
lock the screen it pauses
but when you unlock the screen with the hard button and you see the
android unlock screen (slide to unlock)
it un-pauses and even play the game music.

Is this supposed to happen?

Thanks
Giorgos


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

On my phone, a Nexus 4, this is not what I’m seeing. I lock the screen
with the power button, the app suspends and music stops. If I wake up the
device with the power button again, I see the unlock screen, but the app
remains paused. When I enter the unlock code, it comes back to life.

Can you provide more information on your device, Android version, and
more importantly, can you check the adb log and see what events the app is
getting when you turn it on, pre unlock and post unlock?


Gabriel.


SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.


SDL mailing listSDL at lists.libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.