Autor Tema: PixPlantilla : suspend in idle state  (Leído 6425 veces)

blabla

  • Jr. Member
  • **
  • Mensajes: 72
  • Karma: 5
    • GameBlabla
PixPlantilla : suspend in idle state
« en: Mayo 31, 2015, 03:51:37 am »
Hello,
so i have submitted Rubby Bird to the Jolla Store so sailfish users can play it.
You can also submit an Android APK, because the device is Android-compatible.
However, the review process is severe and they will not allow any apps on their market.
For Rubby Bird, they complained the app does not go in suspend state while in idle state.
Citar
Your application does not go to suspend state while the device is on idle state, so it is causing high power consumption to the device.
It is very critical that application goes to idle state and does not cause high power consumptions to the user.
It is also critical that application does not cause suspends to the device and wake_locks are empty.

How i can implement this feature on my application ?
Is there any way to know on Android if it is in idle state ?
Maybe i should use a software solution...

I'm open for your ideas.
If this suceeds, then Rubby Bird will be the first BennuGD game for Sailfish OS.

panreyes

  • Administrator
  • *****
  • Mensajes: 2154
  • Karma: 74
    • panreyes.com
Re:PixPlantilla : suspend in idle state
« Respuesta #1 en: Mayo 31, 2015, 09:49:46 am »
Hi,


I don't remember the current state of the old pixplantilla, but i think there's some lines in controles.pr- with this content:
Código: [Seleccionar]

if(os_id==1003 and !focus_status)
salir_android();
end


If so, I think there's some salir_android function in your main prg. This is what you'll need for a perfect suspend:


Código: [Seleccionar]

Function salir_android();
Begin
pause_game();
while(!focus_status) frame; end
resume_game();
End


Function pause_game();
Begin
signal(ALL_PROCESS,s_freeze);
if(exists(father)) signal(father,s_wakeup); end
from i=0 to 9;
timer_store[i]=timer[i];
end
pause_song();
End


Function resume_game();
Begin
signal(ALL_PROCESS,s_wakeup);
from i=0 to 9;
timer[i]=timer_store[i];
end
resume_song();
End


Try it and tell me if it works alright for you. By the way, you may check if the app is suspended by looking in Settings/Applications and seeing if it's consuming more than 2% of CPU.

blabla

  • Jr. Member
  • **
  • Mensajes: 72
  • Karma: 5
    • GameBlabla
Re:PixPlantilla : suspend in idle state
« Respuesta #2 en: Mayo 31, 2015, 03:41:18 pm »
Hi,


I don't remember the current state of the old pixplantilla, but i think there's some lines in controles.pr- with this content:
Código: [Seleccionar]

if(os_id==1003 and !focus_status)
salir_android();
end


If so, I think there's some salir_android function in your main prg. This is what you'll need for a perfect suspend:


Código: [Seleccionar]

Function salir_android();
Begin
pause_game();
while(!focus_status) frame; end
resume_game();
End


Function pause_game();
Begin
signal(ALL_PROCESS,s_freeze);
if(exists(father)) signal(father,s_wakeup); end
from i=0 to 9;
timer_store[i]=timer[i];
end
pause_song();
End


Function resume_game();
Begin
signal(ALL_PROCESS,s_wakeup);
from i=0 to 9;
timer[i]=timer_store[i];
end
resume_song();
End


Try it and tell me if it works alright for you. By the way, you may check if the app is suspended by looking in Settings/Applications and seeing if it's consuming more than 2% of CPU.
Thanks but i had already that in my code.
The problem is that it only works when you go back to Android, not when you put it in idle.
In fact, i'm not sure what they mean by "idle state" ?

I guess I could try a software solution :
If the user does nothing for a while, then we freeze the app.
To unfreeze it, they have to press again on the screen.

In this case though, how can i put the cpu in sleep ?
In ANSI C, i can use SDL_Delay or usleep but what's the equivalent in BennuGD,
i don't remember.

Thanks