Increased service heartbeat timeout

This commit is contained in:
Mark Qvist 2022-12-16 23:57:07 +01:00
parent ac3412e50a
commit 0980dc7ee0

View File

@ -88,6 +88,8 @@ class SidebandApp(MDApp):
PKGNAME = "io.unsigned.sideband" PKGNAME = "io.unsigned.sideband"
SERVICE_TIMEOUT = 15
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
self.title = "Sideband" self.title = "Sideband"
@ -113,6 +115,7 @@ class SidebandApp(MDApp):
self.hardware_serial_ready = False self.hardware_serial_ready = False
self.final_load_completed = False self.final_load_completed = False
self.service_last_available = 0
Window.softinput_mode = "below_target" Window.softinput_mode = "below_target"
self.icon = self.sideband.asset_dir+"/icon.png" self.icon = self.sideband.asset_dir+"/icon.png"
@ -134,6 +137,7 @@ class SidebandApp(MDApp):
def update_init_status(self, dt): def update_init_status(self, dt):
self.update_loading_text() self.update_loading_text()
if not RNS.vendor.platformutils.is_android() or self.sideband.service_available(): if not RNS.vendor.platformutils.is_android() or self.sideband.service_available():
self.service_last_available = time.time()
self.start_final() self.start_final()
self.loading_updater.cancel() self.loading_updater.cancel()
@ -529,26 +533,30 @@ class SidebandApp(MDApp):
def jobs(self, delta_time): def jobs(self, delta_time):
if self.final_load_completed: if self.final_load_completed:
if not self.sideband.service_available(): if RNS.vendor.platformutils.is_android() and not self.sideband.service_available():
if self.app_state == SidebandApp.ACTIVE: if time.time() - self.service_last_available > SidebandApp.SERVICE_TIMEOUT:
info_text = "The Reticulum and LXMF service seem to have disappeared, and Sideband is no longer connected. This should not happen, and probably indicates a bug in the background service. Please restart Sideband to regain connectivity." if self.app_state == SidebandApp.ACTIVE:
ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18)) info_text = "The Reticulum and LXMF service seem to have disappeared, and Sideband is no longer connected. This should not happen, and probably indicates a bug in the background service. Please restart Sideband to regain connectivity."
dialog = MDDialog( ok_button = MDRectangleFlatButton(text="OK",font_size=dp(18))
title="Error", dialog = MDDialog(
text=info_text, title="Error",
buttons=[ ok_button ], text=info_text,
# elevation=0, buttons=[ ok_button ],
) # elevation=0,
def dl_ok(s): )
dialog.dismiss() def dl_ok(s):
self.quit_action() dialog.dismiss()
self.quit_action()
ok_button.bind(on_release=dl_ok)
self.final_load_completed = False ok_button.bind(on_release=dl_ok)
dialog.open() self.final_load_completed = False
dialog.open()
else: else:
self.quit_action() self.quit_action()
else:
self.service_last_available = time.time()
if self.root.ids.screen_manager.current == "messages_screen": if self.root.ids.screen_manager.current == "messages_screen":