]>
glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/actions/app_manager.py
1 # Copyright 2021 Erfan Abdi
2 # SPDX-License-Identifier: GPL-3.0-or-later
8 import tools
.helpers
.props
9 import tools
.helpers
.ipc
10 from tools
.interfaces
import IPlatform
11 from tools
.interfaces
import IStatusBarService
16 tools
.helpers
.ipc
.DBusSessionService()
18 tmp_dir
= tools
.config
.session_defaults
["waydroid_data"] + "/waydroid_tmp"
19 if not os
.path
.exists(tmp_dir
):
22 shutil
.copyfile(args
.PACKAGE
, tmp_dir
+ "/base.apk")
23 platformService
= IPlatform
.get_service(args
)
25 platformService
.installApp("/data/waydroid_tmp/base.apk")
26 os
.remove(tmp_dir
+ "/base.apk")
27 except (dbus
.DBusException
, KeyError):
28 logging
.error("WayDroid session is stopped")
32 tools
.helpers
.ipc
.DBusSessionService()
34 platformService
= IPlatform
.get_service(args
)
36 ret
= platformService
.removeApp(args
.PACKAGE
)
38 logging
.error("Failed to uninstall package: {}".format(args
.PACKAGE
))
39 except dbus
.DBusException
:
40 logging
.error("WayDroid session is stopped")
42 def maybeLaunchLater(args
, launchNow
):
44 tools
.helpers
.ipc
.DBusSessionService()
46 tools
.helpers
.ipc
.DBusContainerService().Unfreeze()
48 logging
.error("Failed to unfreeze container. Trying to launch anyways...")
50 except dbus
.DBusException
:
51 logging
.error("Starting waydroid session")
52 tools
.actions
.session_manager
.start(args
, launchNow
)
56 platformService
= IPlatform
.get_service(args
)
58 platformService
.setprop("waydroid.active_apps", args
.PACKAGE
)
59 ret
= platformService
.launchApp(args
.PACKAGE
)
60 multiwin
= platformService
.getprop(
61 "persist.waydroid.multi_windows", "false")
62 if multiwin
== "false":
63 platformService
.settingsPutString(
64 2, "policy_control", "immersive.status=*")
66 platformService
.settingsPutString(
67 2, "policy_control", "immersive.full=*")
69 logging
.error("Failed to access IPlatform service")
70 maybeLaunchLater(args
, justLaunch
)
74 tools
.helpers
.ipc
.DBusSessionService()
76 platformService
= IPlatform
.get_service(args
)
78 appsList
= platformService
.getAppsInfo()
80 print("Name: " + app
["name"])
81 print("packageName: " + app
["packageName"])
83 for cat
in app
["categories"]:
86 logging
.error("Failed to access IPlatform service")
87 except dbus
.DBusException
:
88 logging
.error("WayDroid session is stopped")
92 platformService
= IPlatform
.get_service(args
)
94 platformService
.setprop("waydroid.active_apps", "Waydroid")
95 platformService
.settingsPutString(2, "policy_control", "null*")
96 # HACK: Refresh display contents
97 statusBarService
= IStatusBarService
.get_service(args
)
99 statusBarService
.expand()
101 statusBarService
.collapse()
102 maybeLaunchLater(args
, justShow
)
106 platformService
= IPlatform
.get_service(args
)
108 ret
= platformService
.launchIntent(args
.ACTION
, args
.URI
)
111 pkg
= ret
if ret
!= "android" else "Waydroid"
112 platformService
.setprop("waydroid.active_apps", pkg
)
113 multiwin
= platformService
.getprop(
114 "persist.waydroid.multi_windows", "false")
115 if multiwin
== "false":
116 platformService
.settingsPutString(
117 2, "policy_control", "immersive.status=*")
119 platformService
.settingsPutString(
120 2, "policy_control", "immersive.full=*")
122 logging
.error("Failed to access IPlatform service")
123 maybeLaunchLater(args
, justLaunch
)