Skip to content

Commit c70ed72

Browse files
Simplify is_launcher
1 parent 3828a5f commit c70ed72

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

internal_filesystem/lib/mpos/apps.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def start_app(fullname):
122122
start_script_fullpath = f"{app.installed_path}/{app.main_launcher_activity.get('entrypoint')}"
123123
execute_script(start_script_fullpath, True, app.installed_path + "/assets/", app.main_launcher_activity.get("classname"))
124124
# Launchers have the bar, other apps don't have it
125-
if PackageManager.is_launcher(fullname):
125+
if PackageManager.is_valid_launcher(app):
126126
mpos.ui.topmenu.open_bar()
127127
else:
128128
mpos.ui.topmenu.close_bar()
@@ -135,12 +135,10 @@ def restart_launcher():
135135
mpos.ui.empty_screen_stack()
136136
# No need to stop the other launcher first, because it exits after building the screen
137137
for app in mpos.package_manager.PackageManager.get_app_list():
138-
#print(f"checking {app}")
139-
if app.category == "launcher" and app.main_launcher_activity: # if it's a launcher and it has a main_launcher_activity
138+
if PackageManager.is_valid_launcher(app):
140139
print(f"Found launcher, starting {app.fullname}")
141140
start_app(app.fullname)
142141

143-
144142
class App:
145143
def __init__(self, name, publisher, short_description, long_description, icon_url, download_url, fullname, version, category, activities, installed_path=None):
146144
self.name = name

internal_filesystem/lib/mpos/package_manager.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ def is_installed_by_name(app_fullname):
221221
return PackageManager.is_installed_by_path(f"apps/{app_fullname}") or PackageManager.is_installed_by_path(f"builtin/apps/{app_fullname}")
222222

223223
@staticmethod
224-
def is_launcher(app_name):
225-
print(f"checking is_launcher for {app_name}")
226-
# Simple check, could be more elaborate by checking the MANIFEST.JSON for the app...
227-
return "launcher" in app_name or len(mpos.ui.screen_stack) < 2 # assumes the first one on the stack is the launcher
224+
def is_valid_launcher(app_obj):
225+
#print(f"checking is_valid_launcher for {app_obj}")
226+
return app_obj.category == "launcher" and app_obj.main_launcher_activity

0 commit comments

Comments
 (0)