X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/a1e631dff1e59ef65c280cb161cd51904e14c806..86b27f478965d3e9db906afd4e999e21cdba1be5:/tools/services/user_manager.py diff --git a/tools/services/user_manager.py b/tools/services/user_manager.py index 4e7455b..137c5de 100644 --- a/tools/services/user_manager.py +++ b/tools/services/user_manager.py @@ -8,7 +8,8 @@ from tools.interfaces import IUserMonitor from tools.interfaces import IPlatform -def start(args): +def start(args, unlocked_cb=None): + def makeDesktopFile(appInfo): showApp = False for cat in appInfo["categories"]: @@ -19,8 +20,7 @@ def start(args): packageName = appInfo["packageName"] - desktop_file_path = args.host_user + \ - "/.local/share/applications/" + packageName + ".desktop" + desktop_file_path = args.apps_dir + "/waydroid." + packageName + ".desktop" if not os.path.exists(desktop_file_path): lines = ["[Desktop Entry]", "Type=Application"] lines.append("Name=" + appInfo["name"]) @@ -34,8 +34,7 @@ def start(args): return 0 def makeWaydroidDesktopFile(hide): - desktop_file_path = args.host_user + \ - "/.local/share/applications/Waydroid.desktop" + desktop_file_path = args.apps_dir + "/Waydroid.desktop" if os.path.isfile(desktop_file_path): os.remove(desktop_file_path) lines = ["[Desktop Entry]", "Type=Application"] @@ -54,10 +53,14 @@ def start(args): logging.info("Android with user {} is ready".format(uid)) session_cfg = tools.config.load_session() args.waydroid_data = session_cfg["session"]["waydroid_data"] - args.host_user = session_cfg["session"]["host_user"] + args.apps_dir = session_cfg["session"]["xdg_data_home"] + \ + "/applications/" platformService = IPlatform.get_service(args) if platformService: + if not os.path.exists(args.apps_dir): + os.mkdir(args.apps_dir) + os.chmod(args.apps_dir, 0o700) appsList = platformService.getAppsInfo() for app in appsList: makeDesktopFile(app) @@ -66,13 +69,14 @@ def start(args): makeWaydroidDesktopFile(False) else: makeWaydroidDesktopFile(True) + if unlocked_cb: + unlocked_cb(args) def packageStateChanged(mode, packageName, uid): platformService = IPlatform.get_service(args) if platformService: appInfo = platformService.getAppInfo(packageName) - desktop_file_path = args.host_user + \ - "/.local/share/applications/" + packageName + ".desktop" + desktop_file_path = args.apps_dir + "/" + packageName + ".desktop" if mode == 0: # Package added makeDesktopFile(appInfo)