diff --git a/internal_filesystem/builtin/apps/com.micropythonos.appstore/assets/app_detail.py b/internal_filesystem/builtin/apps/com.micropythonos.appstore/assets/app_detail.py index fff46b1d..aabe6716 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.appstore/assets/app_detail.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.appstore/assets/app_detail.py @@ -2,7 +2,7 @@ import os import json import lvgl as lv -from mpos import Activity, DownloadManager, PackageManager, TaskManager +from mpos import Activity, DownloadManager, AppManager, TaskManager class AppDetail(Activity): @@ -142,7 +142,7 @@ class AppDetail(Activity): self.install_label = lv.label(self.install_button) self.install_label.center() self.set_install_label(self.app.fullname) - if app.version and PackageManager.is_update_available(self.app.fullname, app.version): + if app.version and AppManager.is_update_available(self.app.fullname, app.version): self.install_button.set_size(lv.pct(47), 40) # make space for update button print("Update available, adding update button.") self.update_button = lv.button(buttoncont) @@ -171,10 +171,10 @@ class AppDetail(Activity): # - update is separate button, only shown if already installed and new version is_installed = True update_available = False - builtin_app = PackageManager.is_builtin_app(app_fullname) - overridden_builtin_app = PackageManager.is_overridden_builtin_app(app_fullname) + builtin_app = AppManager.is_builtin_app(app_fullname) + overridden_builtin_app = AppManager.is_overridden_builtin_app(app_fullname) if not overridden_builtin_app: - is_installed = PackageManager.is_installed_by_name(app_fullname) + is_installed = AppManager.is_installed_by_name(app_fullname) if is_installed: if builtin_app: if overridden_builtin_app: @@ -214,12 +214,12 @@ class AppDetail(Activity): self._show_progress_bar() await self._update_progress(21) await self._update_progress(42) - PackageManager.uninstall_app(app_fullname) + AppManager.uninstall_app(app_fullname) await self._update_progress(100, wait=False) self._hide_progress_bar() self.set_install_label(app_fullname) self.install_button.remove_state(lv.STATE.DISABLED) - if PackageManager.is_builtin_app(app_fullname): + if AppManager.is_builtin_app(app_fullname): self.update_button.remove_flag(lv.obj.FLAG.HIDDEN) self.install_button.set_size(lv.pct(47), 40) # if a builtin app was removed, then it was overridden, and a new version is available, so make space for update button @@ -256,7 +256,7 @@ class AppDetail(Activity): else: print("Downloaded .mpk file, size:", os.stat(temp_zip_path)[6], "bytes") # Install it: - PackageManager.install_mpk(temp_zip_path, dest_folder) # 60 until 80 percent is the unzip but no progress there... + AppManager.install_mpk(temp_zip_path, dest_folder) # 60 until 80 percent is the unzip but no progress there... await self._update_progress(80, wait=False) except Exception as e: print(f"Download failed with exception: {e}") diff --git a/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py b/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py index 7e85b91e..13a9b45d 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py @@ -9,7 +9,7 @@ # All icons took: 1250ms # Most of this time is actually spent reading and parsing manifests. import lvgl as lv -from mpos import AppearanceManager, PackageManager, Activity, DisplayMetrics +from mpos import AppearanceManager, AppManager, Activity, DisplayMetrics import time import uhashlib import ubinascii @@ -54,7 +54,7 @@ class Launcher(Activity): # ------------------------------------------------------------------ # 1. Build a *compact* representation of the current app list current_apps = [] - for app in PackageManager.get_app_list(): + for app in AppManager.get_app_list(): if app.category == "launcher": continue icon_hash = Launcher._hash_file(app.icon_path) # cheap SHA-1 of the icon file @@ -90,7 +90,7 @@ class Launcher(Activity): iconcont_width = icon_size + label_height iconcont_height = icon_size + label_height - for app in PackageManager.get_app_list(): + for app in AppManager.get_app_list(): if app.category == "launcher": continue @@ -128,7 +128,7 @@ class Launcher(Activity): # ----- events -------------------------------------------------- app_cont.add_event_cb( - lambda e, fullname=app.fullname: PackageManager.start_app(fullname), + lambda e, fullname=app.fullname: AppManager.start_app(fullname), lv.EVENT.CLICKED, None) app_cont.add_event_cb( lambda e, cont=app_cont: self.focus_app_cont(cont), diff --git a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py index 6ac9d652..231bf767 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py @@ -2,7 +2,7 @@ import lvgl as lv import ujson import time -from mpos import Activity, PackageManager, ConnectivityManager, TaskManager, DownloadManager, DisplayMetrics, DeviceInfo, BuildInfo +from mpos import Activity, AppManager, ConnectivityManager, TaskManager, DownloadManager, DisplayMetrics, DeviceInfo, BuildInfo class OSUpdate(Activity): @@ -770,7 +770,7 @@ class UpdateChecker: Returns: bool: True if remote version is newer """ - return PackageManager.compare_versions(remote_version, current_version) + return AppManager.compare_versions(remote_version, current_version) # Non-class functions: diff --git a/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py b/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py index 0e857b9d..6b87bbad 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py @@ -1,6 +1,6 @@ import lvgl as lv -from mpos import Intent, PackageManager, SettingActivity, SettingsActivity, TimeZone +from mpos import Intent, AppManager, SettingActivity, SettingsActivity, TimeZone from calibrate_imu import CalibrateIMUActivity from check_imu_calibration import CheckIMUCalibrationActivity @@ -44,7 +44,7 @@ class Settings(SettingsActivity): {"title": "Theme Color", "key": "theme_primary_color", "placeholder": "HTML hex color, like: EC048C", "ui": "dropdown", "ui_options": theme_colors, "changed_callback": self.theme_changed}, {"title": "Timezone", "key": "timezone", "ui": "dropdown", "ui_options": [(tz, tz) for tz in TimeZone.get_timezones()], "changed_callback": lambda *args: mpos.time.refresh_timezone_preference()}, # Advanced settings, alphabetically: - {"title": "Auto Start App", "key": "auto_start_app", "ui": "radiobuttons", "ui_options": [(app.name, app.fullname) for app in PackageManager.get_app_list()]}, + {"title": "Auto Start App", "key": "auto_start_app", "ui": "radiobuttons", "ui_options": [(app.name, app.fullname) for app in AppManager.get_app_list()]}, {"title": "Check IMU Calibration", "key": "check_imu_calibration", "ui": "activity", "activity_class": CheckIMUCalibrationActivity}, {"title": "Calibrate IMU", "key": "calibrate_imu", "ui": "activity", "activity_class": CalibrateIMUActivity}, # Expert settings, alphabetically @@ -92,7 +92,7 @@ class Settings(SettingsActivity): # This will throw an exception if there is already a "/builtin" folder present print("settings.py: WARNING: could not import/run freezefs_mount_builtin: ", e) print("Done mounting, refreshing apps") - PackageManager.refresh_apps() + AppManager.refresh_apps() def theme_changed(self, new_value): from mpos import AppearanceManager diff --git a/internal_filesystem/lib/mpos/__init__.py b/internal_filesystem/lib/mpos/__init__.py index 8552fe8a..fdef8adf 100644 --- a/internal_filesystem/lib/mpos/__init__.py +++ b/internal_filesystem/lib/mpos/__init__.py @@ -4,7 +4,7 @@ from .app.activity import Activity from .content.intent import Intent from .activity_navigator import ActivityNavigator -from .content.package_manager import PackageManager +from .content.app_manager import AppManager from .config import SharedPreferences from .net.connectivity_manager import ConnectivityManager from .net.wifi_service import WifiService @@ -65,7 +65,7 @@ __all__ = [ "Activity", "SharedPreferences", "ConnectivityManager", "DownloadManager", "WifiService", "AudioFlinger", "Intent", - "ActivityNavigator", "PackageManager", "TaskManager", "CameraManager", + "ActivityNavigator", "AppManager", "TaskManager", "CameraManager", # Device and build info "DeviceInfo", "BuildInfo", # Common activities diff --git a/internal_filesystem/lib/mpos/activity_navigator.py b/internal_filesystem/lib/mpos/activity_navigator.py index c987180b..e6579235 100644 --- a/internal_filesystem/lib/mpos/activity_navigator.py +++ b/internal_filesystem/lib/mpos/activity_navigator.py @@ -2,7 +2,7 @@ import sys import utime from .content.intent import Intent -from .content.package_manager import PackageManager +from .content.app_manager import AppManager import mpos.ui @@ -13,7 +13,7 @@ class ActivityNavigator: if not isinstance(intent, Intent): raise ValueError("Must provide an Intent") if intent.action: # Implicit intent: resolve handlers - handlers = PackageManager.resolve_activity(intent) + handlers = AppManager.resolve_activity(intent) if not handlers: print("No handler for action:", intent.action) return @@ -31,7 +31,7 @@ class ActivityNavigator: if not isinstance(intent, Intent): raise ValueError("Must provide an Intent") if intent.action: # Implicit intent: resolve handlers - handlers = PackageManager.resolve_activity(intent) + handlers = AppManager.resolve_activity(intent) if not handlers: print("No handler for action:", intent.action) return diff --git a/internal_filesystem/lib/mpos/app/activities/chooser.py b/internal_filesystem/lib/mpos/app/activities/chooser.py index 694d36cc..a93c731f 100644 --- a/internal_filesystem/lib/mpos/app/activities/chooser.py +++ b/internal_filesystem/lib/mpos/app/activities/chooser.py @@ -2,7 +2,7 @@ from ..activity import Activity # Chooser doesn't handle an action — it shows handlers # → No registration needed -from ...content.package_manager import PackageManager +from ...content.app_manager import AppManager class ChooserActivity(Activity): def __init__(self): @@ -27,7 +27,7 @@ class ChooserActivity(Activity): self.setContentView(screen) def _select_handler(self, handler_name, original_intent): - for handler in PackageManager.APP_REGISTRY.get(original_intent.action, []): + for handler in AppManager.APP_REGISTRY.get(original_intent.action, []): if handler.__name__ == handler_name: original_intent.activity_class = handler navigator.startActivity(original_intent) diff --git a/internal_filesystem/lib/mpos/app/activities/share.py b/internal_filesystem/lib/mpos/app/activities/share.py index bc2879ca..d4280a87 100644 --- a/internal_filesystem/lib/mpos/app/activities/share.py +++ b/internal_filesystem/lib/mpos/app/activities/share.py @@ -1,5 +1,5 @@ from ..activity import Activity -from ...content.package_manager import PackageManager +from ...content.app_manager import AppManager class ShareActivity(Activity): def __init__(self): @@ -35,4 +35,4 @@ class ShareActivity(Activity): else: print("Stopped for other screen") -PackageManager.register_activity("share", ShareActivity) +AppManager.register_activity("share", ShareActivity) diff --git a/internal_filesystem/lib/mpos/app/activities/view.py b/internal_filesystem/lib/mpos/app/activities/view.py index 38bb1c23..6123a0cf 100644 --- a/internal_filesystem/lib/mpos/app/activities/view.py +++ b/internal_filesystem/lib/mpos/app/activities/view.py @@ -1,5 +1,5 @@ from ..activity import Activity -from ...content.package_manager import PackageManager +from ...content.app_manager import AppManager class ViewActivity(Activity): def __init__(self): @@ -28,4 +28,4 @@ class ViewActivity(Activity): print("Stopped for other screen") # Register this activity for "view" intents -PackageManager.register_activity("view", ViewActivity) +AppManager.register_activity("view", ViewActivity) diff --git a/internal_filesystem/lib/mpos/content/package_manager.py b/internal_filesystem/lib/mpos/content/app_manager.py similarity index 90% rename from internal_filesystem/lib/mpos/content/package_manager.py rename to internal_filesystem/lib/mpos/content/app_manager.py index ff45e076..0202cdd7 100644 --- a/internal_filesystem/lib/mpos/content/package_manager.py +++ b/internal_filesystem/lib/mpos/content/app_manager.py @@ -28,7 +28,7 @@ Question: does it make sense to cache the database? ''' -class PackageManager: +class AppManager: _registry = {} # action → [ActivityClass, ...] @@ -52,9 +52,9 @@ class PackageManager: """Registry of all discovered apps. - * PackageManager.get_app_list() -> list of App objects (sorted by name) - * PackageManager[fullname] -> App (raises KeyError if missing) - * PackageManager.get(fullname) -> App or None + * AppManager.get_app_list() -> list of App objects (sorted by name) + * AppManager[fullname] -> App (raises KeyError if missing) + * AppManager.get(fullname) -> App or None """ _app_list = [] # sorted by app.name @@ -93,7 +93,7 @@ class PackageManager: @classmethod def refresh_apps(cls): - print("PackageManager finding apps...") + print("AppManager finding apps...") cls.clear() # <-- this guarantees both containers are empty seen = set() # avoid processing the same fullname twice @@ -117,7 +117,7 @@ class PackageManager: if not (st[0] & 0x4000): continue except Exception as e: - print("PackageManager: stat of {} got exception: {}".format(full_path, e)) + print("AppManager: stat of {} got exception: {}".format(full_path, e)) continue fullname = name @@ -132,7 +132,7 @@ class PackageManager: from ..app.app import App app = App.from_manifest(full_path) except Exception as e: - print("PackageManager: parsing {} failed: {}".format(full_path, e)) + print("AppManager: parsing {} failed: {}".format(full_path, e)) continue # ---- store in both containers --------------------------- @@ -141,7 +141,7 @@ class PackageManager: print("added app {}".format(app)) except Exception as e: - print("PackageManager: handling {} got exception: {}".format(base, e)) + print("AppManager: handling {} got exception: {}".format(base, e)) # ---- sort the list by display name (case-insensitive) ------------ cls._app_list.sort(key=lambda a: a.name.lower()) @@ -153,7 +153,7 @@ class PackageManager: shutil.rmtree(f"apps/{app_fullname}") # never in builtin/apps because those can't be uninstalled except Exception as e: print(f"Removing app_folder {app_folder} got error: {e}") - PackageManager.refresh_apps() + AppManager.refresh_apps() @staticmethod def install_mpk(temp_zip_path, dest_folder): @@ -169,7 +169,7 @@ class PackageManager: except Exception as e: print(f"Unzip and cleanup failed: {e}") # Would be good to show error message here if it fails... - PackageManager.refresh_apps() + AppManager.refresh_apps() @staticmethod def compare_versions(ver1: str, ver2: str) -> bool: @@ -200,20 +200,20 @@ class PackageManager: @staticmethod def is_builtin_app(app_fullname): - return PackageManager.is_installed_by_path(f"builtin/apps/{app_fullname}") + return AppManager.is_installed_by_path(f"builtin/apps/{app_fullname}") @staticmethod def is_overridden_builtin_app(app_fullname): - return PackageManager.is_installed_by_path(f"apps/{app_fullname}") and PackageManager.is_installed_by_path(f"builtin/apps/{app_fullname}") + return AppManager.is_installed_by_path(f"apps/{app_fullname}") and AppManager.is_installed_by_path(f"builtin/apps/{app_fullname}") @staticmethod def is_update_available(app_fullname, new_version): appdir = f"apps/{app_fullname}" builtinappdir = f"builtin/apps/{app_fullname}" - installed_app=PackageManager.get(app_fullname) + installed_app=AppManager.get(app_fullname) if not installed_app: return False - return PackageManager.compare_versions(new_version, installed_app.version) + return AppManager.compare_versions(new_version, installed_app.version) @staticmethod def is_installed_by_path(dir_path): @@ -231,7 +231,7 @@ class PackageManager: @staticmethod def is_installed_by_name(app_fullname): print(f"Checking if app {app_fullname} is installed...") - return PackageManager.is_installed_by_path(f"apps/{app_fullname}") or PackageManager.is_installed_by_path(f"builtin/apps/{app_fullname}") + return AppManager.is_installed_by_path(f"apps/{app_fullname}") or AppManager.is_installed_by_path(f"builtin/apps/{app_fullname}") @staticmethod def execute_script(script_source, is_file, classname, cwd=None): @@ -311,7 +311,7 @@ class PackageManager: mpos.ui.set_foreground_app(fullname) import utime start_time = utime.ticks_ms() - app = PackageManager.get(fullname) + app = AppManager.get(fullname) if not app: print(f"Warning: start_app can't find app {fullname}") return @@ -325,7 +325,7 @@ class PackageManager: else: entrypoint = app.main_launcher_activity.get('entrypoint') classname = app.main_launcher_activity.get("classname") - result = PackageManager.execute_script(app.installed_path + "/" + entrypoint, True, classname, app.installed_path + "/assets/") + result = AppManager.execute_script(app.installed_path + "/" + entrypoint, True, classname, app.installed_path + "/assets/") # Launchers have the bar, other apps don't have it if app.is_valid_launcher(): mpos.ui.topmenu.open_bar() @@ -343,5 +343,4 @@ class PackageManager: # Stop all apps mpos.ui.remove_and_stop_all_activities() # No need to stop the other launcher first, because it exits after building the screen - return PackageManager.start_app(PackageManager.get_launcher().fullname) - + return AppManager.start_app(AppManager.get_launcher().fullname) diff --git a/internal_filesystem/lib/mpos/main.py b/internal_filesystem/lib/mpos/main.py index 81e471f4..fa9421ce 100644 --- a/internal_filesystem/lib/mpos/main.py +++ b/internal_filesystem/lib/mpos/main.py @@ -5,7 +5,7 @@ import lvgl as lv import mpos.ui import mpos.ui.topmenu -from mpos import AppearanceManager, DisplayMetrics, PackageManager, SharedPreferences, TaskManager, DeviceInfo +from mpos import AppearanceManager, DisplayMetrics, AppManager, SharedPreferences, TaskManager, DeviceInfo # White text on black logo works (for dark mode) and can be inverted (for light mode) logo_white = "M:builtin/res/mipmap-mdpi/MicroPythonOS-logo-white-long-w296.png" # from the MPOS-logo repo @@ -124,12 +124,12 @@ except Exception as e: print(f"Couldn't start WifiService.auto_connect thread because: {e}") # Start launcher so it's always at bottom of stack -launcher_app = PackageManager.get_launcher() -started_launcher = PackageManager.start_app(launcher_app.fullname) +launcher_app = AppManager.get_launcher() +started_launcher = AppManager.start_app(launcher_app.fullname) # Then start auto_start_app if configured auto_start_app = prefs.get_string("auto_start_app", None) if auto_start_app and launcher_app.fullname != auto_start_app: - result = PackageManager.start_app(auto_start_app) + result = AppManager.start_app(auto_start_app) if result is not True: print(f"WARNING: could not run {auto_start_app} app") diff --git a/internal_filesystem/lib/mpos/testing/mocks.py b/internal_filesystem/lib/mpos/testing/mocks.py index 08462e9c..cd3a5a42 100644 --- a/internal_filesystem/lib/mpos/testing/mocks.py +++ b/internal_filesystem/lib/mpos/testing/mocks.py @@ -815,7 +815,7 @@ class MockThread: class MockApps: """ - Mock mpos.apps module for testing (deprecated, use MockPackageManager instead). + Mock mpos.apps module for testing (deprecated, use MockAppManager instead). This is kept for backward compatibility with existing tests. @@ -839,12 +839,12 @@ class MockApps: return True -class MockPackageManager: +class MockAppManager: """ - Mock mpos.content.package_manager module for testing. + Mock mpos.content.app_manager module for testing. Usage: - sys.modules['mpos.content.package_manager'] = MockPackageManager + sys.modules['mpos.content.app_manager'] = MockAppManager """ @staticmethod diff --git a/internal_filesystem/lib/mpos/ui/testing.py b/internal_filesystem/lib/mpos/ui/testing.py index 193afb96..0c3b2a78 100644 --- a/internal_filesystem/lib/mpos/ui/testing.py +++ b/internal_filesystem/lib/mpos/ui/testing.py @@ -13,10 +13,10 @@ infrastructure are already initialized (boot.py and main.py executed). Usage in tests: from mpos.ui.testing import wait_for_render, capture_screenshot - from mpos import PackageManager + from mpos import AppManager # Start your app - PackageManager.start_app("com.example.myapp") + AppManager.start_app("com.example.myapp") # Wait for UI to render wait_for_render() @@ -63,8 +63,8 @@ def wait_for_render(iterations=10): iterations: Number of task handler iterations to run (default: 10) Example: - from mpos import PackageManager - PackageManager.start_app("com.example.myapp") + from mpos import AppManager + AppManager.start_app("com.example.myapp") wait_for_render() # Ensure UI is ready assert verify_text_present(lv.screen_active(), "Welcome") """ diff --git a/internal_filesystem/lib/mpos/ui/topmenu.py b/internal_filesystem/lib/mpos/ui/topmenu.py index ce66846e..236f54e4 100644 --- a/internal_filesystem/lib/mpos/ui/topmenu.py +++ b/internal_filesystem/lib/mpos/ui/topmenu.py @@ -7,7 +7,7 @@ from .appearance_manager import AppearanceManager from .util import (get_foreground_app) from . import focus_direction from .widget_animator import WidgetAnimator -from mpos.content.package_manager import PackageManager +from mpos.content.app_manager import AppManager CLOCK_UPDATE_INTERVAL = 1000 # 10 or even 1 ms doesn't seem to change the framerate but 100ms is enough WIFI_ICON_UPDATE_INTERVAL = 1500 @@ -268,7 +268,7 @@ def create_drawer(): wifi_label.center() def wifi_event(e): close_drawer() - PackageManager.start_app("com.micropythonos.wifi") + AppManager.start_app("com.micropythonos.wifi") wifi_btn.add_event_cb(wifi_event,lv.EVENT.CLICKED,None) settings_btn=lv.button(drawer) settings_btn.set_size(lv.pct(drawer_button_pct),lv.pct(20)) @@ -278,7 +278,7 @@ def create_drawer(): settings_label.center() def settings_event(e): close_drawer() - PackageManager.start_app("com.micropythonos.settings") + AppManager.start_app("com.micropythonos.settings") settings_btn.add_event_cb(settings_event,lv.EVENT.CLICKED,None) launcher_btn=lv.button(drawer) launcher_btn.set_size(lv.pct(drawer_button_pct),lv.pct(20)) @@ -289,7 +289,7 @@ def create_drawer(): def launcher_event(e): print("Launch button pressed!") close_drawer(True) - PackageManager.restart_launcher() + AppManager.restart_launcher() launcher_btn.add_event_cb(launcher_event,lv.EVENT.CLICKED,None) ''' sleep_btn=lv.button(drawer) @@ -308,7 +308,7 @@ def create_drawer(): else: # assume unix: # maybe do a system suspend here? or at least show a popup toast "not supported" close_drawer(True) - PackageManager.restart_launcher() + AppManager.restart_launcher() sleep_btn.add_event_cb(sleep_event,lv.EVENT.CLICKED,None) ''' restart_btn=lv.button(drawer) diff --git a/tests/manual_test_camera.py b/tests/manual_test_camera.py index 70a2ec11..01fe0bc4 100644 --- a/tests/manual_test_camera.py +++ b/tests/manual_test_camera.py @@ -1,6 +1,6 @@ import unittest -from mpos import App, PackageManager +from mpos import App, AppManager from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling diff --git a/tests/manual_test_nostr_asyncio.py b/tests/manual_test_nostr_asyncio.py index 9bec4a12..4ef5f86f 100644 --- a/tests/manual_test_nostr_asyncio.py +++ b/tests/manual_test_nostr_asyncio.py @@ -5,7 +5,7 @@ import _thread import time import unittest -from mpos import App, PackageManager +from mpos import App, AppManager from nostr.relay_manager import RelayManager from nostr.message_type import ClientMessageType diff --git a/tests/test_graphical_about_app.py b/tests/test_graphical_about_app.py index 27d17bff..33b51251 100644 --- a/tests/test_graphical_about_app.py +++ b/tests/test_graphical_about_app.py @@ -27,7 +27,7 @@ from mpos import ( print_screen_labels, DeviceInfo, BuildInfo, - PackageManager + AppManager ) @@ -78,7 +78,7 @@ class TestGraphicalAboutApp(unittest.TestCase): print("\n=== Starting About app test ===") # Start the About app - result = PackageManager.start_app("com.micropythonos.about") + result = AppManager.start_app("com.micropythonos.about") self.assertTrue(result, "Failed to start About app") # Wait for UI to fully render @@ -146,7 +146,7 @@ class TestGraphicalAboutApp(unittest.TestCase): print("\n=== Starting About app OS version test ===") # Start the About app - result = PackageManager.start_app("com.micropythonos.about") + result = AppManager.start_app("com.micropythonos.about") self.assertTrue(result, "Failed to start About app") # Wait for UI to render diff --git a/tests/test_graphical_camera_settings.py b/tests/test_graphical_camera_settings.py index 44237027..08c404f5 100644 --- a/tests/test_graphical_camera_settings.py +++ b/tests/test_graphical_camera_settings.py @@ -31,7 +31,7 @@ from mpos import ( print_screen_labels, simulate_click, get_widget_coords, - PackageManager + AppManager ) @unittest.skipIf(sys.platform == 'darwin', "Camera tests not supported on macOS (no camera available)") @@ -117,7 +117,7 @@ class TestGraphicalCameraSettings(unittest.TestCase): print("\n=== Testing settings button click (no crash) ===") # Start the Camera app - result = PackageManager.start_app("com.micropythonos.camera") + result = AppManager.start_app("com.micropythonos.camera") self.assertTrue(result, "Failed to start Camera app") # Wait for camera to initialize and first frame to render @@ -251,7 +251,7 @@ class TestGraphicalCameraSettings(unittest.TestCase): print("\n=== Testing resolution change (no crash) ===") # Start the Camera app - result = PackageManager.start_app("com.micropythonos.camera") + result = AppManager.start_app("com.micropythonos.camera") self.assertTrue(result, "Failed to start Camera app") # Wait for camera to initialize diff --git a/tests/test_graphical_imu_calibration.py b/tests/test_graphical_imu_calibration.py index 5f106c23..4c20b1ae 100644 --- a/tests/test_graphical_imu_calibration.py +++ b/tests/test_graphical_imu_calibration.py @@ -27,7 +27,7 @@ from mpos import ( click_label, click_button, find_text_on_screen, - PackageManager + AppManager ) @@ -63,7 +63,7 @@ class TestIMUCalibration(unittest.TestCase): print("\n=== Testing CheckIMUCalibrationActivity ===") # Navigate: Launcher -> Settings -> Check IMU Calibration - result = PackageManager.start_app("com.micropythonos.settings") + result = AppManager.start_app("com.micropythonos.settings") self.assertTrue(result, "Failed to start Settings app") wait_for_render(15) @@ -98,7 +98,7 @@ class TestIMUCalibration(unittest.TestCase): print("\n=== Testing CalibrateIMUActivity Flow ===") # Navigate: Launcher -> Settings -> Calibrate IMU - result = PackageManager.start_app("com.micropythonos.settings") + result = AppManager.start_app("com.micropythonos.settings") self.assertTrue(result, "Failed to start Settings app") wait_for_render(15) @@ -155,7 +155,7 @@ class TestIMUCalibration(unittest.TestCase): print("\n=== Testing Check -> Calibrate Navigation ===") # Navigate to Check activity - result = PackageManager.start_app("com.micropythonos.settings") + result = AppManager.start_app("com.micropythonos.settings") self.assertTrue(result) wait_for_render(15) diff --git a/tests/test_graphical_imu_calibration_ui_bug.py b/tests/test_graphical_imu_calibration_ui_bug.py index 62adfc89..88a90e42 100755 --- a/tests/test_graphical_imu_calibration_ui_bug.py +++ b/tests/test_graphical_imu_calibration_ui_bug.py @@ -27,7 +27,7 @@ from mpos import ( click_label, click_button, find_text_on_screen, - PackageManager + AppManager ) @@ -46,7 +46,7 @@ class TestIMUCalibrationUI(unittest.TestCase): print("Step 2: Opening Settings app...") # Start Settings app by name - PackageManager.start_app("com.micropythonos.settings") + AppManager.start_app("com.micropythonos.settings") wait_for_render(iterations=30) print("Settings app opened\n") diff --git a/tests/test_graphical_launch_all_apps.py b/tests/test_graphical_launch_all_apps.py index 13147b47..0b808006 100644 --- a/tests/test_graphical_launch_all_apps.py +++ b/tests/test_graphical_launch_all_apps.py @@ -13,7 +13,7 @@ import time # This is a graphical test - needs boot and main to run first # Add tests directory to path for helpers -from mpos import wait_for_render, ui, PackageManager +from mpos import wait_for_render, ui, AppManager class TestLaunchAllApps(unittest.TestCase): @@ -30,7 +30,7 @@ class TestLaunchAllApps(unittest.TestCase): def _discover_apps(self): """Discover all installed apps.""" # Use PackageManager to get all apps - all_packages = PackageManager.get_app_list() + all_packages = AppManager.get_app_list() for package in all_packages: # Get the main activity for each app @@ -64,7 +64,7 @@ class TestLaunchAllApps(unittest.TestCase): try: # Launch the app by package name - result = PackageManager.start_app(package_name) + result = AppManager.start_app(package_name) # Wait for UI to render wait_for_render(iterations=5) @@ -188,7 +188,7 @@ class TestLaunchSpecificApps(unittest.TestCase): try: # Launch the app by package name - result = PackageManager.start_app(package_name) + result = AppManager.start_app(package_name) wait_for_render(iterations=5) # Check if start_app returned False (indicates error) diff --git a/tests/test_graphical_osupdate.py b/tests/test_graphical_osupdate.py index 71e535f2..45aa4642 100644 --- a/tests/test_graphical_osupdate.py +++ b/tests/test_graphical_osupdate.py @@ -14,7 +14,7 @@ from mpos import ( print_screen_labels, DeviceInfo, BuildInfo, - PackageManager + AppManager ) @@ -29,7 +29,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase): def test_app_launches_successfully(self): """Test that OSUpdate app launches without errors.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result, "Failed to start OSUpdate app") wait_for_render(10) @@ -40,7 +40,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase): def test_ui_elements_exist(self): """Test that all required UI elements are created.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(15) @@ -60,7 +60,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase): def test_force_checkbox_initially_unchecked(self): """Test that force update checkbox starts unchecked.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(15) @@ -103,7 +103,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase): def test_install_button_initially_disabled(self): """Test that install button starts in disabled state.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(15) @@ -139,7 +139,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase): def test_current_version_displayed(self): """Test that current OS version is displayed correctly.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(15) @@ -159,7 +159,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase): """Test status message when wifi is not connected.""" # This test assumes desktop mode where wifi check returns True # On actual hardware without wifi, it would show error - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(15) @@ -174,7 +174,7 @@ class TestOSUpdateGraphicalUI(unittest.TestCase): def test_screenshot_initial_state(self): """Capture screenshot of initial app state.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(20) @@ -207,7 +207,7 @@ class TestOSUpdateGraphicalStatusMessages(unittest.TestCase): def test_status_label_exists(self): """Test that status label is created and visible.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(15) @@ -226,7 +226,7 @@ class TestOSUpdateGraphicalStatusMessages(unittest.TestCase): def test_all_labels_readable(self): """Test that all labels are readable (no truncation issues).""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(15) @@ -264,14 +264,14 @@ class TestOSUpdateGraphicalScreenshots(unittest.TestCase): def test_capture_main_screen(self): """Capture screenshot of main OSUpdate screen.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(20) def test_capture_with_labels_visible(self): """Capture screenshot ensuring all text is visible.""" - result = PackageManager.start_app("com.micropythonos.osupdate") + result = AppManager.start_app("com.micropythonos.osupdate") self.assertTrue(result) wait_for_render(20) diff --git a/tests/test_graphical_start_app.py b/tests/test_graphical_start_app.py index 2fac3f72..9ad18a16 100644 --- a/tests/test_graphical_start_app.py +++ b/tests/test_graphical_start_app.py @@ -13,7 +13,7 @@ Usage: """ import unittest -from mpos import ui, wait_for_render, PackageManager +from mpos import ui, wait_for_render, AppManager class TestStartApp(unittest.TestCase): @@ -39,7 +39,7 @@ class TestStartApp(unittest.TestCase): """Test that launching an existing app succeeds.""" print("Testing normal app launch...") - result = PackageManager.start_app("com.micropythonos.launcher") + result = AppManager.start_app("com.micropythonos.launcher") wait_for_render(10) # Wait for app to load self.assertTrue(result, "com.micropythonos.launcher should start") @@ -49,7 +49,7 @@ class TestStartApp(unittest.TestCase): """Test that launching a non-existent app fails gracefully.""" print("Testing non-existent app launch...") - result = PackageManager.start_app("com.micropythonos.nonexistent") + result = AppManager.start_app("com.micropythonos.nonexistent") self.assertFalse(result, "com.micropythonos.nonexistent should not start") print("Non-existent app handled correctly") @@ -58,7 +58,7 @@ class TestStartApp(unittest.TestCase): """Test that restarting the launcher succeeds.""" print("Testing launcher restart...") - result = PackageManager.restart_launcher() + result = AppManager.restart_launcher() wait_for_render(10) # Wait for launcher to load self.assertTrue(result, "restart_launcher() should succeed") diff --git a/tests/test_multi_connect.py b/tests/test_multi_connect.py index 6d7fc0cc..e26bc6a8 100644 --- a/tests/test_multi_connect.py +++ b/tests/test_multi_connect.py @@ -2,7 +2,7 @@ import unittest import _thread import time -from mpos import App, PackageManager, TaskManager +from mpos import App, AppManager, TaskManager from websocket import WebSocketApp diff --git a/tests/test_multi_websocket_with_bad_ones.py b/tests/test_multi_websocket_with_bad_ones.py index 9d50c511..44447d73 100644 --- a/tests/test_multi_websocket_with_bad_ones.py +++ b/tests/test_multi_websocket_with_bad_ones.py @@ -2,7 +2,7 @@ import unittest import _thread import time -from mpos import App, PackageManager +from mpos import App, AppManager from mpos import TaskManager from websocket import WebSocketApp diff --git a/tests/test_osupdate.py b/tests/test_osupdate.py index 9167b8ca..e36e4893 100644 --- a/tests/test_osupdate.py +++ b/tests/test_osupdate.py @@ -38,7 +38,7 @@ class MockPartition: # Import PackageManager which is needed by UpdateChecker # The test runs from internal_filesystem/ directory, so we can import from lib/mpos -from mpos import PackageManager +from mpos import AppManager # Import the actual classes we're testing # Tests run from internal_filesystem/, so we add the assets directory to path diff --git a/tests/test_package_manager.py b/tests/test_package_manager.py index eebca586..bd7e76e9 100644 --- a/tests/test_package_manager.py +++ b/tests/test_package_manager.py @@ -1,50 +1,50 @@ import unittest -from mpos import App, PackageManager +from mpos import App, AppManager class TestCompareVersions(unittest.TestCase): def test_lower_short(self): - self.assertFalse(PackageManager.compare_versions("1" , "4")) + self.assertFalse(AppManager.compare_versions("1" , "4")) def test_lower(self): - self.assertFalse(PackageManager.compare_versions("1.2.3" , "4.5.6")) + self.assertFalse(AppManager.compare_versions("1.2.3" , "4.5.6")) def test_equal(self): - self.assertFalse(PackageManager.compare_versions("1.2.3" , "1.2.3")) + self.assertFalse(AppManager.compare_versions("1.2.3" , "1.2.3")) def test_higher(self): - self.assertTrue(PackageManager.compare_versions("4.5.6", "1.2.3")) + self.assertTrue(AppManager.compare_versions("4.5.6", "1.2.3")) def test_higher_medium_and_long(self): - self.assertTrue(PackageManager.compare_versions("4.5", "1.2.3")) + self.assertTrue(AppManager.compare_versions("4.5", "1.2.3")) def test_words(self): - self.assertFalse(PackageManager.compare_versions("weird" , "input")) + self.assertFalse(AppManager.compare_versions("weird" , "input")) def test_one_empty(self): - self.assertFalse(PackageManager.compare_versions("1.2.3" , "")) + self.assertFalse(AppManager.compare_versions("1.2.3" , "")) -class TestPackageManager_is_installed_by_name(unittest.TestCase): +class TestAppManager_is_installed_by_name(unittest.TestCase): def test_installed_builtin(self): - self.assertTrue(PackageManager.is_installed_by_name("com.micropythonos.appstore")) + self.assertTrue(AppManager.is_installed_by_name("com.micropythonos.appstore")) def test_installed_not_builtin(self): - self.assertTrue(PackageManager.is_installed_by_name("com.micropythonos.helloworld")) + self.assertTrue(AppManager.is_installed_by_name("com.micropythonos.helloworld")) def test_not_installed(self): - self.assertFalse(PackageManager.is_installed_by_name("com.micropythonos.badname")) + self.assertFalse(AppManager.is_installed_by_name("com.micropythonos.badname")) -class TestPackageManager_get_app_list(unittest.TestCase): +class TestAppManager_get_app_list(unittest.TestCase): def test_get_app_list(self): - app_list = PackageManager.get_app_list() + app_list = AppManager.get_app_list() self.assertGreaterEqual(len(app_list), 13) # more if the symlinks in internal_filesystem/app aren't dangling def test_get_app(self): - app_list = PackageManager.get_app_list() - hello_world_app = PackageManager.get("com.micropythonos.helloworld") + app_list = AppManager.get_app_list() + hello_world_app = AppManager.get("com.micropythonos.helloworld") self.assertIsInstance(hello_world_app, App) - self.assertEqual(hello_world_app.icon_path, "apps/com.micropythonos.helloworld/res/mipmap-mdpi/icon_64x64.png") - self.assertEqual(len(hello_world_app.icon_data), 5378) + self.assertEqual(hello_world_app.icon_path, "apps/com.micropythonos.helloworld/res/mipmap-mdpi/icon_64x64.png") + self.assertEqual(len(hello_world_app.icon_data), 5378) diff --git a/tests/test_syspath_restore.py b/tests/test_syspath_restore.py index 0941d787..afe837db 100644 --- a/tests/test_syspath_restore.py +++ b/tests/test_syspath_restore.py @@ -8,7 +8,7 @@ class TestSysPathRestore(unittest.TestCase): def test_syspath_restored_after_execute_script(self): """Test that sys.path is restored to original state after script execution""" # Import here to ensure we're in the right context - from mpos import PackageManager + from mpos import AppManager # Capture original sys.path original_path = sys.path[:] @@ -31,7 +31,7 @@ x = 42 # Call execute_script with cwd parameter # Note: This will fail because there's no Activity to start, # but that's fine - we're testing the sys.path restoration - result = PackageManager.execute_script( + result = AppManager.execute_script( test_script, is_file=False, classname="NonExistentClass", @@ -56,7 +56,7 @@ x = 42 def test_syspath_not_affected_when_no_cwd(self): """Test that sys.path is unchanged when cwd is None""" - from mpos import PackageManager + from mpos import AppManager # Capture original sys.path original_path = sys.path[:] @@ -66,7 +66,7 @@ x = 42 ''' # Call without cwd parameter - result = PackageManager.execute_script( + result = AppManager.execute_script( test_script, is_file=False, classname="NonExistentClass", diff --git a/tests/test_websocket.py b/tests/test_websocket.py index ac91b84b..46ad55af 100644 --- a/tests/test_websocket.py +++ b/tests/test_websocket.py @@ -3,7 +3,7 @@ import unittest import _thread import time -from mpos import App, PackageManager +from mpos import App, AppManager from mpos import TaskManager from websocket import WebSocketApp