@@ -93,7 +93,7 @@ def execute_script_new_thread(scriptname, is_file):
9393if "camtest" in scriptname :
9494print ("Starting camtest with extra stack size!" )
9595stack = 32 * 1024
96- elif "appstore" in scriptname :
96+ elif "appstore" in scriptname :
9797print ("Starting appstore with extra stack size!" )
9898stack = 24 * 1024 # this doesn't do anything because it's all started in the same thread
9999else :
@@ -111,17 +111,16 @@ def start_app(fullname):
111111start_time = utime .ticks_ms ()
112112app = PackageManager .get (fullname )
113113if not app :
114- print (f"Warning: start_appcould not find app{ fullname } , aborting... " )
114+ print (f"Warning: start_appcan't find app{ fullname } " )
115115return
116116if not app .installed_path :
117- print (f"Warning: start_appcould not find installed_path for { fullname } , aborting... " )
117+ print (f"Warning: start_appcan't start { fullname } because no it doesn't have an installed_path " )
118118return
119- main_launcher_activity = PackageManager .find_main_launcher_activity (app )
120- if not main_launcher_activity :
121- print (f"WARNING: can't start{ fullname } because no main_launcher_activity was found." )
119+ if not app .main_launcher_activity :
120+ print (f"WARNING: start_app can't start{ fullname } because it doesn't have a main_launcher_activity" )
122121return
123- start_script_fullpath = f"{ app .installed_path } /{ main_launcher_activity .get ('entrypoint' )} "
124- execute_script (start_script_fullpath ,True ,app .installed_path + "/assets/" ,main_launcher_activity .get ("classname" ))
122+ start_script_fullpath = f"{ app .installed_path } /{ app . main_launcher_activity .get ('entrypoint' )} "
123+ execute_script (start_script_fullpath ,True ,app .installed_path + "/assets/" ,app . main_launcher_activity .get ("classname" ))
125124# Launchers have the bar, other apps don't have it
126125if PackageManager .is_launcher (fullname ):
127126mpos .ui .topmenu .open_bar ()
@@ -137,7 +136,7 @@ def restart_launcher():
137136# No need to stop the other launcher first, because it exits after building the screen
138137for app in mpos .package_manager .PackageManager .get_app_list ():
139138#print(f"checking {app}")
140- if app .category == "launcher" and PackageManager . find_main_launcher_activity ( app ):
139+ if app .category == "launcher" and app . main_launcher_activity : # if it's a launcher and it has a main_launcher_activity
141140print (f"Found launcher, starting{ app .fullname } " )
142141start_app (app .fullname )
143142
@@ -157,6 +156,7 @@ def __init__(self, name, publisher, short_description, long_description, icon_ur
157156self .image_dsc = None
158157self .activities = activities
159158self .installed_path = installed_path
159+ self .main_launcher_activity = self ._find_main_launcher_activity ()
160160
161161def __str__ (self ):
162162return (f"App(name='{ self .name } ', "
@@ -167,6 +167,22 @@ def __str__(self):
167167f"activities='{ self .activities } ', "
168168f"installed_path={ self .installed_path } )" )
169169
170+ def _find_main_launcher_activity (self ):
171+ result = None
172+ for activity in self .activities :
173+ if not activity .get ("entrypoint" )or not activity .get ("classname" ):
174+ print (f"Warning: activity{ activity } has no entrypoint and classname, skipping..." )
175+ continue
176+ print ("checking activity's intent_filters..." )
177+ for intent_filter in activity .get ("intent_filters" ):
178+ print ("checking intent_filter..." )
179+ if intent_filter .get ("action" )== "main" and intent_filter .get ("category" )== "launcher" :
180+ print ("found main_launcher!" )
181+ result = activity
182+ break
183+ return result
184+
185+
170186def parse_manifest (appdir ):
171187print (f"parse_manifest({ appdir } )" )
172188manifest_path = f"{ appdir } /META-INF/MANIFEST.JSON"