PixPlantilla : suspend in idle state

Started by blabla, May 31, 2015, 03:51:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blabla

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.
Quote
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

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:


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:




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

Quote from: PiXeL on May 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:


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:




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