We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

Work around/disable power saving mode (best practice)

asked 2018-03-18 19:58:01 +0300

takimata gravatar image

Which methodology is intended by Jolla for disabling certain power saving features (because an application needs to execute code while the device is not actively used)?

(This was also asked on the SfOS mailing list and I stumbled upon it because I'm currently developing an application which disabled charging after reaching a given limit (say 70%) in order to conserve battery lifetime, just as a small exercise)

I found 2 possible approaches (see below), but I wonder why the hell neither of them is documented at all (there's just plain code, nothing else).

This was somehow already asked and even marked as "tracked by Jolla" 3 years ago, but I couldn't find any official statement from Jolla regarding this issue ever since.

edit retag flag offensive close delete

Comments

What about Jolla Powersave Settings? https://openrepos.net/content/coderus/jolla-powersave-settings

objectifnul ( 2018-03-18 21:46:34 +0300 )edit

That's snakeoil for me - I don't know the meaning of the dbus settings it modifies, and hey, even the dev said he doesn't know... There is another charge control app out there, but afaik not for Xperia X (or it at least used other, imho strange, sysfs paths).

takimata ( 2018-03-18 22:39:49 +0300 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2018-03-18 19:59:59 +0300

takimata gravatar image

libkeepalive approach

The library is part of Sfos: https://together.jolla.com/question/175209/sudo-make-me-a-sandwich/?answer=175235#post-id-175235

sth. like:

#include <keepalive/backgroundactivity.h>

// see https://git.merproject.org/mer-core/nemo-keepalive/blob/12a1528bacd20e0a07e9bbcbc287b08641986265/lib/backgroundactivity.h
BackgroundActivity activity;

connect(&activity, SIGNAL(running()), this, SLOT(backgroundActivity()));
activity.setWakeupFrequency(BackgroundActivity::TwoAndHalfMinutes);


void backgroundActivity() {
    // background job in regular intervals, executed even if the device is not actively used
}
edit flag offensive delete publish link more

Comments

But is it Harbour compatible ?

MartinK ( 2018-03-19 03:06:56 +0300 )edit
2

It is. I am using it on one of my apps. The validator failed but I complaint and got an email stating that they will fix it.

FloR707 ( 2018-03-19 15:36:24 +0300 )edit

@FloR707: Okay, thanks!

takimata ( 2018-03-20 17:55:02 +0300 )edit
0

answered 2018-03-18 19:59:04 +0300

takimata gravatar image

DBUS approach, e.g., execute dbus-send --system --print-reply --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.set_config string:'/system/osso/dsm/display/autosuspend_policy' variant:int32:$MAGIC_NUMBER

in C++:

/** enables (-> best power saving) or disables (-> cpu active) deep suspend/sleep

 * @param deepSuspendAllowed
 */
void allowDeepSuspend(bool deepSuspendAllowed) {

    QDBusMessage msg = QDBusMessage::createMethodCall("com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", "set_config");

    // set the two arguments:

    msg << "/system/osso/dsm/display/autosuspend_policy";

    // Always stay in on-mode:  SUSPEND_POLICY_DISABLED = 0
    // Normal transitions between on, early suspend, and late suspend:  SUSPEND_POLICY_ENABLED = 1
    // Allow on and early suspend, but never enter late suspend:  SUSPEND_POLICY_EARLY_ONLY = 2
    // this keeps at least one cpu core running for our application!
    // Disable suspend when charger is connected:  SUSPEND_POLICY_DISABLE_ON_CHARGER = 3
    // Note: Applies only when device is running normally in the USER mode, i.e. not in ACT_DEAD etc special modes.
    //
    // see https://git.merproject.org/mer-core/mce/blob/master/tools/mcetool.c
    // and https://git.merproject.org/mer-core/mce/blob/master/modules/display.h
    msg << QVariant::fromValue(QDBusVariant((deepSuspendAllowed ? 1 : 2)));

    // MINOR: hoping that the msg gets through, no error checking yet (but it's quite reliable, though)
    // maybe there's a dbus signal available?
    QDBusConnection::systemBus().send(msg);
}
edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
5 followers

Stats

Asked: 2018-03-18 19:58:01 +0300

Seen: 486 times

Last updated: Mar 18 '18