Timer for on/off Android support

Sony Xperia 10 II SFOS 4.3 etc

I do not use at the moment both Bluez and Amazfit in operation due to a high battery idle percentage drop over night as between 30 to 35 % / 7.5 hours.

Also with Android support on, the battery drain is 20 to 25 % over night.

After took off Android support, the battery drain over night was only 1 to 2 % overnight with Xperia 10 II.

After using without any success in both for opening and closing Android support by dbus commands in Situations App, I’d like to revise my wish for you all in dear Community:

It should be great if Android support should include an inbound timer for putting on and putting off that support.

PS. Yes, doing it manually several times around a year does not sound as a smart phone. :grinning_face_with_smiling_eyes:

Looking forward to this.

Merry Christmas All.

1 Like

I prefer to do that manually instead of defining fixed times, but the idea is the same.
In my case the Situations app, supported by some shell scripts and a suitable sudo configuration, does the work based on active ambience. Configured this way, my “night” ambience cares for flight mode, silence, and stops some unneeded services (such as Android app support). Additionally, restarting services on a daily basis seems to improve general stability.

1 Like

It seems to me that it would be more important to fix whatever’s actually causing the battery drain rather than implementing a feature you would really only use because something isn’t working the way it should. On the same device, same OS version, my battery only goes down a few % overnight and Android support is always active, so it would be good to find out what’s causing your battery to go down so quickly.

This is basically the same answer you’d get from Jolla: it’s better to fix a problem than it is to add workarounds for it but leave the problem intact. The fact that you can start/stop Android app support from the UI at all is already a workaround for times when it doesn’t work properly. Should the Android app support ever work ‘flawlessly’, I’m pretty sure the UI option to start/stop it will be removed.

3 Likes

The problems started after SFOS 4.2.xx. Before this update, with Android support on & Bt+Amazfit on the battery idle drain was only 1 to 3 % / 7,5 hours. As far as I know, there are problems with bluez (bt) and with Android support sofar. Thus I’m not fond of doing factory reset at first.

What comes to starting / stopping the Android support at morning and in the late evening, respectively. I want to stop Whatsapp and Telegram over night, thus the show must stop for the night. Having a smart in my phone, the manually controlling things are useless. If doing everything manually, why do I then have a smart phone?

By the way, the first Jolla principles in the beginning 2013 - 2014 was to avoid the useless jumping in and jumping out in the apps, that causes just a useless power consumption due to awakening of the phone.
It’s also a matter of principle. Yes, you can sell your principles, but what’s left after that?

Hi ziellos, how did you manage to run a command like systemctl stop <name.service> without entering a password? Many thanks for the help in advance :slight_smile:

There used to be this:

https://openrepos.net/content/schturman/patch-stopstart-dalvik-specific-time

It stopped working some time ago, maybe it can serve as inspiration…

1 Like

Easy answer:
Some services may be controlled without root privileges by using systemctl --user, for instance Exchange Activesync (EAS). Unfortunately, --user is not valid for all services, so there is a …

Long answer:
I installed sudo and configured it so the systemctl binary may be invoked by the user, but runs with root privileges. This way, controlling any service is possible.
Of cause sudo may be used to invoke any other commands that require root privileges.
See here how to install it: How to use 'sudo'? [closed] - together.jolla.com
In contrast to other hacks, sudo is designed to do exactly that, running privileged commands as a user without knowing root password. It has been part of Unix security architecture for ages.

1 Like

Thanks for the info. I will give it a try.

I installed sudo. I’ve tried adding

nemo ALL = NOPASSWD: /usr/bin/dbus-send
nemo ALL = NOPASSWD: /bin/systemctl
nemo ALL = NOPASSWD: /usr/bin/connmanctl

to the end of sudoers file via nano and then saving. I’ve set up the Situations app to execute sudo /bin/systemctl stop aliendalvik.service when I turn on Airplane mode but it’s not working. Any help is appreciated.

1 Like

First, verify that your default user is ‘nemo’ (on new installed sfos it’s ‘defaultuser’).
Second, you should use ‘visudo’ to edit sudoers file.
Third, the line should be:

nemo ALL = (ALL) NOPASSWD: /usr/bin/connmanctl

2 Likes

When I add defaultuser ALL = (ALL) NOPASSWD: /usr/bin/connmanctl at the end of the sudoers file via visudo command this is the output from the terminal when I type in ‘sudo systemctl stop aliendalvik.service’: ‘Sorry, user defaultuser is not allowed to execute ‘/usr/bin/systemctl stop aliendalvik.service’ as root on dzukelica.’

Is there something that I’m missing?

This line awards privileged execution to ‘connmanctl’. To award privileged execution to ‘systemctl’, you must add:

defaultuser ALL = (ALL) NOPASSWD: /usr/bin/systemctl

2 Likes

By the way, what is the result of ‘whoami’ command when you are not logged as root?

I added this one as well (I forgot to add (ALL) before)

Now, it’s working like a charm. Thank you very much, @phklrz

1 Like

You’re welcome.

1 Like

Ref phklrz and branja6

Great work. I got it,too, working. One question:
When I have this order /usr/bin/systemctl start or stop aliendalvik.service in Situations Apps … why the security code is asked to restart aliendalvik.service before allowing to do the action? Do I have to give root rights for Situations App, too, or something else?

Or how I can insert the security code in the order in Situations app?

However, great work indeed fellows!

(I used that defaultuser ALL = …)

1 Like

If you’ve properly set up sudo (sudoers file), you shouldn’t need to enter any passcodes.
Also, I use this command with Situations App - sudo systemctl stop aliendalvik.service (or start, in order for it to start, ofc).

Thank you branja6. Yes, there have to be some problem with:

defaultuser ALL = (ALL) NOPASSWD: /usr/bin/systemctl

These models are problematic, because don’t know whether there is a blanco (empty) or more between letters. I have read different sources and there are differences. I get different error messages while programming …

I do not understand error:
"bash: syntax error: unexpected “(”

1 Like

Here is how the relevant entries in my sudoers file look like:

defaultuser     ALL = NOPASSWD: /usr/bin/dbus-send                              
defaultuser     ALL = NOPASSWD: /usr/bin/systemctl
defaultuser     ALL = NOPASSWD: /usr/bin/connmanctl

These are used to control services, switch airplan mode, and others.

2 Likes

Maybe they can add an Option that Android Support will be stopped automatically if you close the last running Android App.