File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
internal_filesystem/lib/mpos/app Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ import os
12import ujson
23from ..activity_navigator import ActivityNavigator
34
@@ -30,11 +31,26 @@ def __init__(
3031
3132 self .image = None
3233 self .image_dsc = None
34+ self .icon_path = self ._find_icon_path ()
3335 self .main_launcher_activity = self ._find_main_launcher_activity ()
3436
3537 def __str__ (self ):
3638 return f"App({ self .name } , v{ self .version } , { self .category } )"
3739
40+ def _check_icon_path (self , tocheck ):
41+ try :
42+ #print(f"checking {tocheck}")
43+ st = os .stat (tocheck )
44+ #print(f"_find_icon_path got {st}")
45+ return tocheck
46+ except Exception as e :
47+ #print(f"No app icon found: {e}")
48+ return None
49+
50+ def _find_icon_path (self ):
51+ fullpath = "apps/" + self .fullname + "/res/mipmap-mdpi/icon_64x64.png"
52+ return self ._check_icon_path (fullpath ) or self ._check_icon_path ("builtin/" + fullpath )
53+
3854 def _find_main_launcher_activity (self ):
3955 for act in self .activities :
4056 if not act .get ("entrypoint" ) or not act .get ("classname" ):
Original file line number Diff line number Diff line change 11import unittest
22
3- from mpos import PackageManager
3+ from mpos import App , PackageManager
44
55class TestCompareVersions (unittest .TestCase ):
66
@@ -35,3 +35,15 @@ def test_installed_not_builtin(self):
3535
3636 def test_not_installed (self ):
3737 self .assertFalse (PackageManager .is_installed_by_name ("com.micropythonos.badname" ))
38+
39+ class TestPackageManager_get_app_list (unittest .TestCase ):
40+
41+ def test_get_app_list (self ):
42+ app_list = PackageManager .get_app_list ()
43+ self .assertEqual (len (app_list ), 17 )
44+
45+ def test_get_app (self ):
46+ app_list = PackageManager .get_app_list ()
47+ hello_world_app = PackageManager .get ("com.micropythonos.helloworld" )
48+ self .assertIsInstance (hello_world_app , App )
49+ self .assertEqual (hello_world_app .icon_path , "apps/com.micropythonos.helloworld/res/mipmap-mdpi/icon_64x64.png" )
You can’t perform that action at this time.
0 commit comments