In the unlikely case someone finds himself in the same situation, here my final solution so far, a python script to run as root with ‘sailcron’. It seems to protect me from unnoticed offline times.
Thank you all for the help.
# Robomike's workaround to STAY mostly connected in Germany.
# My Sailfish-devices have massive problems in weak, messy
# mobile cells. Maybe the problem is also related to my provider
# (O2) or whatever, anyway, when in an area with multiple cells with
# similar bad signal strength, something goes wrong and the phone is
# not only offline, but also does no attempt to regain a network anymore.
# This python script checks the situation and restarts ofono, if necessary.
# It should be run as root by cron or similar mechanics repeatedly.
# (Setting up event loops are possible, but I'm not sure if
# battery friendly...)
# (thanks to the contributors in this thread)
# First discussions on this topic:
bus = dbus.SystemBus() # define the bus
busObject = bus.get_object('org.ofono','/ril_0') # define the bus-object
# Test if call is active.
callsInterface = dbus.Interface(busObject,dbus_interface='org.ofono.VoiceCallManager')
calls = callsInterface.GetCalls()
return (len(calls) > 0)
# Test if NetworkRegistration says 'registered' or 'roaming'
# According to https://git.sailfishos.org/mer-core/ofono/blob/master/ofono/doc/network-api.txt we'll find
# "unregistered" Not registered to any network
# "registered" Registered to home network
# "searching" Not registered, but searching
# "denied" Registration has been denied
# "unknown" Status is unknown
# "roaming" Registered, but roaming
netRegIface = dbus.Interface(busObject,dbus_interface='org.ofono.NetworkRegistration')
netRegInfos = netRegIface.GetProperties()
return ((netRegInfos['Status'] == 'registered') or (netRegInfos['Status'] == 'roaming'))
# In many cases ofono seems just blocked. We can see a 'registered' state then,
# but we are not able to make calls, recieve messages etc.
# Then, the sailfish status bar shows a signal strength indicator, but no
# '2G/3G/4G' quality at all. AFAIK the only way to find out is asking the
# 'ConnectionManager', if it is 'attached'.
dataConnIface = dbus.Interface(busObject,dbus_interface='org.ofono.ConnectionManager')
dataConnInfos = dataConnIface.GetProperties()
return (dataConnInfos['Attached'] == True)
problem = False
# If a call is active, we shouldn't even try to disrupt.
# This is not a guarantee that all is working!
pass # means problem remains 'False'
# But here's a known problem.
problem = True
#Okay, seems running well. Do not disturb.
problem = True # Here's the annoying situation I try to work around
# Thing here is, I tried several things to make
# ofono run properly again, but found no way to
# do it without restarting it.
# For some reasons restarting ofono in Sailfish 4.x is faster
# than in older versions. Normally we'll have immediate success.
# Ok then, finally:
print ('checkOfono.py is restarting ofono service NOW')
os.system("systemctl restart ofono")