Languages

Menu
Sites
Language
Prevent background service from getting suspended

I'm trying to develop a background services that is permanently running. My main loop is looking like this:

void service_app_control(app_control_h app_control, void *data)
{
    device_power_request_lock(POWER_LOCK_CPU, 0);
    while(true) {
        	tick();
    		sleep(TICK_INTERVAL_SECONDS);
    }
    return;
}

TICK_INTERVAL_SECONDS is currently set to 201. In the tick(), I'm just sending a heartbeat to a server if the last heartbeat submission is older than 10 minutes.

This results in the following heartbeats arriving at the server:

No matter if the power is connected or not, a lot of the heartbeats are missing. That is because according to what I can see in the logs my service app gets suspended for long periods of time. My question is: is it possible at all to run a background service that is permanently active? And if so, how should it be done?

For reference, here is my manifest file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="MYPACKAGE" version="1.0.0">
    <profile name="wearable"/>
    <service-application appid="MYPACKAGE" auto-restart="true" exec="MYBINARY" multiple="false" nodisplay="true" on-boot="true" taskmanage="false" type="capp">
        <label>MYNAME</label>
        <icon>MYICON</icon>
        <background-category value="background-network"/>
        <background-category value="sensor"/>
        <background-category value="download"/>
        <background-category value="iot-communication"/>
        <background-category value="location"/>
        <background-category value="media"/>
    </service-application>
    <privileges>
        <privilege>http://tizen.org/privilege/network.get</privilege>
        <privilege>http://tizen.org/privilege/network.set</privilege>
        <privilege>http://tizen.org/privilege/internet</privilege>
        <privilege>http://tizen.org/privilege/packagemanager.info</privilege>
        <privilege>http://tizen.org/privilege/network.profile</privilege>
        <privilege>http://tizen.org/privilege/power</privilege>
    </privileges>
</manifest>

 

Responses

1 Replies
chua enze

Hi, did you manage to run it always?