[FL-3847, FL-3513] Thread Signals (#3730)

* Add signal API
* Add signal support to loader
* Add signal support to ViewDispatcher
* Remove extra signal definitions
* Fix typos
  Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com>
* scripts: runfap: close current app pre-launch
* loader: enable backlight when starting an app
* scripts: removed distfap.py
* Do not expose signal API via ViewDispatcher
* scripts: runfap: iterative retry to launch
* Add a loader signal subcommand
* Furi, Gui: move signal handling from View Dispatcher to Event Loop

Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com>
Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Georgii Surkov
2024-06-21 23:44:36 +03:00
committed by GitHub
parent a0036d10fc
commit 4cf98867a0
16 changed files with 291 additions and 109 deletions
+20
View File
@@ -2,6 +2,7 @@
import operator
from functools import reduce
import time
from flipper.app import App
from flipper.storage import FlipperStorage, FlipperStorageOperations
@@ -9,6 +10,8 @@ from flipper.utils.cdc import resolve_port
class Main(App):
APP_POST_CLOSE_DELAY_SEC = 0.2
def init(self):
self.parser.add_argument("-p", "--port", help="CDC Port", default="auto")
self.parser.add_argument(
@@ -67,6 +70,23 @@ class Main(App):
if self.args.host_app:
startup_command = self.args.host_app
self.logger.info("Closing current app, if any")
for _ in range(10):
storage.send_and_wait_eol("loader close\r")
result = storage.read.until(storage.CLI_EOL)
if b"was closed" in result:
self.logger.info("App closed")
storage.read.until(storage.CLI_EOL)
time.sleep(self.APP_POST_CLOSE_DELAY_SEC)
elif result.startswith(b"No application"):
storage.read.until(storage.CLI_EOL)
break
else:
self.logger.error(
f"Unexpected response: {result.decode('ascii')}"
)
return 4
self.logger.info(f"Launching app: {startup_command}")
storage.send_and_wait_eol(f"loader open {startup_command}\r")