X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/waydroid.git/blobdiff_plain/a1e631dff1e59ef65c280cb161cd51904e14c806..22f671bf0520df68fc6b3cf106e1fc97f462da86:/tools/services/user_manager.py diff --git a/tools/services/user_manager.py b/tools/services/user_manager.py index 4e7455b..09b6bab 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,17 @@ 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" + #TODO: Drop me + if os.path.exists(desktop_file_path): + with open(desktop_file_path) as file: + filedata = file.read() + filedata = filedata.replace( + "Icon=" + args.old_waydroid_data, "Icon=" + args.waydroid_data) + with open(desktop_file_path, 'w') as file: + file.write(filedata) + os.chmod(desktop_file_path, 0o755) + if not os.path.exists(desktop_file_path): lines = ["[Desktop Entry]", "Type=Application"] lines.append("Name=" + appInfo["name"]) @@ -34,8 +44,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 +63,17 @@ 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"] + #TODO: Drop me + args.old_waydroid_data = session_cfg["session"]["host_user"] + \ + "/waydroid/data" + 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 +82,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)