2828
2929'''
3030
31- class PackageManager :
31+ class AppManager :
3232
3333 _registry = {} # action → [ActivityClass, ...]
3434
@@ -52,9 +52,9 @@ def query_intent_activities(cls, intent):
5252
5353 """Registry of all discovered apps.
5454
55- * PackageManager .get_app_list() -> list of App objects (sorted by name)
56- * PackageManager [fullname] -> App (raises KeyError if missing)
57- * PackageManager .get(fullname) -> App or None
55+ * AppManager .get_app_list() -> list of App objects (sorted by name)
56+ * AppManager [fullname] -> App (raises KeyError if missing)
57+ * AppManager .get(fullname) -> App or None
5858 """
5959
6060 _app_list = [] # sorted by app.name
@@ -93,7 +93,7 @@ def clear(cls):
9393
9494 @classmethod
9595 def refresh_apps (cls ):
96- print ("PackageManager finding apps..." )
96+ print ("AppManager finding apps..." )
9797
9898 cls .clear () # <-- this guarantees both containers are empty
9999 seen = set () # avoid processing the same fullname twice
@@ -117,7 +117,7 @@ def refresh_apps(cls):
117117 if not (st [0 ] & 0x4000 ):
118118 continue
119119 except Exception as e :
120- print ("PackageManager : stat of {} got exception: {}" .format (full_path , e ))
120+ print ("AppManager : stat of {} got exception: {}" .format (full_path , e ))
121121 continue
122122
123123 fullname = name
@@ -132,7 +132,7 @@ def refresh_apps(cls):
132132 from ..app .app import App
133133 app = App .from_manifest (full_path )
134134 except Exception as e :
135- print ("PackageManager : parsing {} failed: {}" .format (full_path , e ))
135+ print ("AppManager : parsing {} failed: {}" .format (full_path , e ))
136136 continue
137137
138138 # ---- store in both containers ---------------------------
@@ -141,7 +141,7 @@ def refresh_apps(cls):
141141 print ("added app {}" .format (app ))
142142
143143 except Exception as e :
144- print ("PackageManager : handling {} got exception: {}" .format (base , e ))
144+ print ("AppManager : handling {} got exception: {}" .format (base , e ))
145145
146146 # ---- sort the list by display name (case-insensitive) ------------
147147 cls ._app_list .sort (key = lambda a : a .name .lower ())
@@ -153,7 +153,7 @@ def uninstall_app(app_fullname):
153153 shutil .rmtree (f"apps/{ app_fullname } " ) # never in builtin/apps because those can't be uninstalled
154154 except Exception as e :
155155 print (f"Removing app_folder { app_folder } got error: { e } " )
156- PackageManager .refresh_apps ()
156+ AppManager .refresh_apps ()
157157
158158 @staticmethod
159159 def install_mpk (temp_zip_path , dest_folder ):
@@ -169,7 +169,7 @@ def install_mpk(temp_zip_path, dest_folder):
169169 except Exception as e :
170170 print (f"Unzip and cleanup failed: { e } " )
171171 # Would be good to show error message here if it fails...
172- PackageManager .refresh_apps ()
172+ AppManager .refresh_apps ()
173173
174174 @staticmethod
175175 def compare_versions (ver1 : str , ver2 : str ) -> bool :
@@ -200,20 +200,20 @@ def compare_versions(ver1: str, ver2: str) -> bool:
200200
201201 @staticmethod
202202 def is_builtin_app (app_fullname ):
203- return PackageManager .is_installed_by_path (f"builtin/apps/{ app_fullname } " )
203+ return AppManager .is_installed_by_path (f"builtin/apps/{ app_fullname } " )
204204
205205 @staticmethod
206206 def is_overridden_builtin_app (app_fullname ):
207- return PackageManager .is_installed_by_path (f"apps/{ app_fullname } " ) and PackageManager .is_installed_by_path (f"builtin/apps/{ app_fullname } " )
207+ return AppManager .is_installed_by_path (f"apps/{ app_fullname } " ) and AppManager .is_installed_by_path (f"builtin/apps/{ app_fullname } " )
208208
209209 @staticmethod
210210 def is_update_available (app_fullname , new_version ):
211211 appdir = f"apps/{ app_fullname } "
212212 builtinappdir = f"builtin/apps/{ app_fullname } "
213- installed_app = PackageManager .get (app_fullname )
213+ installed_app = AppManager .get (app_fullname )
214214 if not installed_app :
215215 return False
216- return PackageManager .compare_versions (new_version , installed_app .version )
216+ return AppManager .compare_versions (new_version , installed_app .version )
217217
218218 @staticmethod
219219 def is_installed_by_path (dir_path ):
@@ -231,7 +231,7 @@ def is_installed_by_path(dir_path):
231231 @staticmethod
232232 def is_installed_by_name (app_fullname ):
233233 print (f"Checking if app { app_fullname } is installed..." )
234- return PackageManager .is_installed_by_path (f"apps/{ app_fullname } " ) or PackageManager .is_installed_by_path (f"builtin/apps/{ app_fullname } " )
234+ return AppManager .is_installed_by_path (f"apps/{ app_fullname } " ) or AppManager .is_installed_by_path (f"builtin/apps/{ app_fullname } " )
235235
236236 @staticmethod
237237 def execute_script (script_source , is_file , classname , cwd = None ):
@@ -311,7 +311,7 @@ def start_app(fullname):
311311 mpos .ui .set_foreground_app (fullname )
312312 import utime
313313 start_time = utime .ticks_ms ()
314- app = PackageManager .get (fullname )
314+ app = AppManager .get (fullname )
315315 if not app :
316316 print (f"Warning: start_app can't find app { fullname } " )
317317 return
@@ -325,7 +325,7 @@ def start_app(fullname):
325325 else :
326326 entrypoint = app .main_launcher_activity .get ('entrypoint' )
327327 classname = app .main_launcher_activity .get ("classname" )
328- result = PackageManager .execute_script (app .installed_path + "/" + entrypoint , True , classname , app .installed_path + "/assets/" )
328+ result = AppManager .execute_script (app .installed_path + "/" + entrypoint , True , classname , app .installed_path + "/assets/" )
329329 # Launchers have the bar, other apps don't have it
330330 if app .is_valid_launcher ():
331331 mpos .ui .topmenu .open_bar ()
@@ -343,5 +343,4 @@ def restart_launcher():
343343 # Stop all apps
344344 mpos .ui .remove_and_stop_all_activities ()
345345 # No need to stop the other launcher first, because it exits after building the screen
346- return PackageManager .start_app (PackageManager .get_launcher ().fullname )
347-
346+ return AppManager .start_app (AppManager .get_launcher ().fullname )
0 commit comments