Need Help: HowTo start to programm a first app: "Pause" (break or "face down") for Xperia 10 III

Hi together,
I’d like to try to develop an app (have had a short “Android App training” some years ago and some experience with general python programming).

Using a “Moto G9 play” I’m enthusiastic of one feature:
If you put down the Moto G9 “face down” on a table, the “don’t disturb”-mode is activated, but Bluetooth keeps enabled, which is nice for hearing music. This feature I’d like to transport similarly to Sailfish for my Xperia 10 III.

GOAL:
If you put down a Xperia 10 III on a horizontal surface (+/- 5°) with the display down (“face down”), the app should do the following automatically:

  • recognize, that the phone is put “face down” on a surface
  • confirm that with 2 short vibration alarms
  • detect: mobile data enabled ? → save the actual setting, disable mobile data
  • detect: wifi enabled ? → save the actual setting, disable wifi
  • detect: do not disturb-mode enabled ? → save the actual setting, enable do not disturb
  • detect: Bluetooth enabled ? → save the actual setting, disable Bluetooth (if configured so by user for e.g. in checkboxes)

After that, the phone should check the state of lying on a table every 0,5s. If the phone is picked up, this should be again confirmed by a vibration and all functions, that have been disabled before, should be activated again (without any further interaction of the user with the phone).

As written in other topics, active WiFi/mobile Data drains the battery much too fast. A main purpose of this future app would be to prevent this battery discharging.

If such an app is invented, perhaps the user could choose in “options” in a checkbox, which things should be disabled by “face down” (I assume that as a feature request).

Questions:

  1. Where should I begin reading to learn about app-programming?
  2. Which IDE should I use (on Ubuntu 20.04)?
  3. How does the sensors in Xperia 10 III work to detect the horizontal state?
  4. Is there anybody, who would help me to invent such an app :slight_smile: ?

Regards

2 Likes

I think this is where you should start reading…

Hello, I am faced with the same questions, and for me (for now) answers are next:
Q:Where should I begin reading to learn about app-programming?
A: I am wrote my first app using QT6 book https://www.qt.io/hubfs/_website/QML%20Book/qt6book-with-frontpage.pdf?utm_referrer=https%3A%2F%2Fwww.qt.io%2Fproduct%2Fqt6%2Fqml-book

Q: Which IDE should I use (on Ubuntu 20.04)?
A: Official Sailfish SDK Sailfish SDK | Sailfish OS Documentation

I’m wondering if Situations can’t handle all these conditions.

let me know if you find something about it as this is what I wanted to do. As you can see no replies in this regard. Not sure if I’m doing something wrong or this is not totally possible blocked or something.

No, proximity only.

no surface up.down and also no save states…
only actions

  • recognize, that the phone is put “face down” on a surface

There’s the Proximity Sensor

  • confirm that with 2 short vibration alarms

There is surely a command to apply this. So, still possible with Situations.

  • detect: mobile data enabled ? → save the actual setting, disable mobile data

I found this option too

  • detect: wifi enabled ? → save the actual setting, disable wifi

Available too

  • detect: do not disturb-mode enabled ? → save the actual setting, enable do not disturb

Present

  • detect: Bluetooth enabled ? → save the actual setting, disable Bluetooth (if configured so by user for e.g. in checkboxes)

Available

So if there is a missing function, better contribute to Situations instead of developing a new app.

1 Like

Ok, I tried only some simple things with Situations, but wasn’t sure, that everything would be available. First I try harder with Situations before starting a new app.
@Dima2387 : Thanks for the links, SDK is installing.

Hi perjung,
thanks for your hints. I discoverd more items in the menu “functions”.
Now I’ve testet the following, see screenshot.
First problems:

  • Still looking at the opened app Situation: I got the message “current Situation: Pause”
    → this “Pause”-Situation should only be activated, if I lay the phone “face down” on a table or so.
    → Although it was shown activated, the “what’s” (german: was) are not done: no vibration discovered, no don’t disturb activated, no wifi deactivated
  • In the menu > “i”, I tap on “Sonar install”, nothing happens (external source are activated)

depending on the version of sfos you are running you might run into sailjail issues with situations.
there is a thread about it, basically it says you should modify .desktop file of situations to exclude it and then people claim situation would work as expected.

1 Like

Instead of Aus, try with Started. It doesn’t sound logic, but you want to start something when the proximity sensor is seeing something.

Hi, I just managed to get most of the wanted behaviour:
Wifi is disabled, I can see it on the router. The other items reduce battery discharge, too.

One thing I’m missing at the moment:
I’d like to have a short confirmation, that the Situation “Pause” is activated. Does anyone know a direct console-command for: either a short vibration or a sound (SMS, e-mail, …)?

It’s possible to enable notifications. Situations->Settings->Notifications.

1 Like

I just realized that. The last thing I added was the “energy saving mode”. Now if I turn the phone “face down”, starting the energy saving mode confirms with a sound, nice.
(EDIT: Done with sailfish 4.0.0.64, sonar had to be installed from github.)

I’m sorry to ask again: Today I deleted one of the “default situations” (at home). After a reboot of the Phone, I got an error. No tap on either button did anything.

I deleted Situations from the phone and reinstalled it → got the same failure.
Does someone has experience with such a failure?

Does someone know where the config-files of Situations are? Perhaps I could delete them all by ssh and reinstall it again.

With the help of Heikki Haveri, Pastilli Labs, I could reinstall it completly:

devel-su
[root@Xperia10III defaultuser]# pkcon remove situations
[root@Xperia10III defaultuser]# rm -r .local/share/harbour-situations2application/
rm: descend into directory '.local/share/harbour-situations2application'? y
rm: remove directory '.local/share/harbour-situations2application'? y
[root@Xperia10III defaultuser]# pkcon remove situations-sonar

Restart the phone.
Reinstall ‘Situations’ and ’ situations-sonar-0.0.9-9.aarch64.rpm’ (from github).

This time I deactivated the default situations, before I organized my personal “Pause”.

New try with 4.4.0.72:

  1. installation of situations (+add function: “display”)
  2. installation situations-sonar-0.0.9-9.aarch64.rpm (from github)
  3. configuration of Situation “display down” as desired, see picture:

Aim:
a) Save battery:
While the phone is worn in the trousers or laid down on the display → WiFi should be disabled.
b) Get notifications only when I actively check the phone.

Observations:

  1. First morning, the WiFi was disabled correctly, as seen on the router or by the messages of Situations.
  2. Problem: Some hours later, Situations disabled WiFi, although the display was “on”, when I came near to the proximity sensor (e.g. when tapping on a top corner in an app).

To solve this, I restarted the phone once. Now I got the same (white failure screen as mentioned on 5th of july)

If Situations works like configured, it would spare a certain amount of battery.
Can someone confirm this behaviour? How could I get Situations to work properly?

Hello,
it seems that “situations” app is not compatible with Sailjail. Do you start it from the launcher or from a terminal?
You can try to start it from the terminal (thus avoiding Sailjail restrictions) and see if the behaviour is the same.

1 Like

How can I start “situations” from the terminal?
If I tab “sit” in terminal, I got only “situations-sonar”.