]>
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 cm
= tools
.helpers
.ipc
.DBusContainerService()
19 session
= cm
.GetSession()
20 if session
["state"] == "FROZEN":
23 tmp_dir
= tools
.config
.session_defaults
["waydroid_data"] + "/waydroid_tmp"
24 if not os
.path
.exists(tmp_dir
):
27 shutil
.copyfile(args
.PACKAGE
, tmp_dir
+ "/base.apk")
28 platformService
= IPlatform
.get_service(args
)
30 platformService
.installApp("/data/waydroid_tmp/base.apk")
32 logging
.error("Failed to access IPlatform service")
33 os
.remove(tmp_dir
+ "/base.apk")
35 if session
["state"] == "FROZEN":
37 except (dbus
.DBusException
, KeyError):
38 logging
.error("WayDroid session is stopped")
42 tools
.helpers
.ipc
.DBusSessionService()
44 cm
= tools
.helpers
.ipc
.DBusContainerService()
45 session
= cm
.GetSession()
46 if session
["state"] == "FROZEN":
49 platformService
= IPlatform
.get_service(args
)
51 ret
= platformService
.removeApp(args
.PACKAGE
)
53 logging
.error("Failed to uninstall package: {}".format(args
.PACKAGE
))
55 logging
.error("Failed to access IPlatform service")
57 if session
["state"] == "FROZEN":
59 except dbus
.DBusException
:
60 logging
.error("WayDroid session is stopped")
62 def maybeLaunchLater(args
, launchNow
):
64 tools
.helpers
.ipc
.DBusSessionService()
66 tools
.helpers
.ipc
.DBusContainerService().Unfreeze()
68 logging
.error("Failed to unfreeze container. Trying to launch anyways...")
70 except dbus
.DBusException
:
71 logging
.error("Starting waydroid session")
72 tools
.actions
.session_manager
.start(args
, launchNow
)
76 platformService
= IPlatform
.get_service(args
)
78 platformService
.setprop("waydroid.active_apps", args
.PACKAGE
)
79 ret
= platformService
.launchApp(args
.PACKAGE
)
80 multiwin
= platformService
.getprop(
81 "persist.waydroid.multi_windows", "false")
82 if multiwin
== "false":
83 platformService
.settingsPutString(
84 2, "policy_control", "immersive.status=*")
86 platformService
.settingsPutString(
87 2, "policy_control", "immersive.full=*")
89 logging
.error("Failed to access IPlatform service")
90 maybeLaunchLater(args
, justLaunch
)
94 tools
.helpers
.ipc
.DBusSessionService()
96 cm
= tools
.helpers
.ipc
.DBusContainerService()
97 session
= cm
.GetSession()
98 if session
["state"] == "FROZEN":
101 platformService
= IPlatform
.get_service(args
)
103 appsList
= platformService
.getAppsInfo()
105 print("Name: " + app
["name"])
106 print("packageName: " + app
["packageName"])
108 for cat
in app
["categories"]:
111 logging
.error("Failed to access IPlatform service")
113 if session
["state"] == "FROZEN":
115 except dbus
.DBusException
:
116 logging
.error("WayDroid session is stopped")
118 def showFullUI(args
):
120 platformService
= IPlatform
.get_service(args
)
122 platformService
.setprop("waydroid.active_apps", "Waydroid")
123 platformService
.settingsPutString(2, "policy_control", "null*")
124 # HACK: Refresh display contents
125 statusBarService
= IStatusBarService
.get_service(args
)
127 statusBarService
.expand()
129 statusBarService
.collapse()
131 logging
.error("Failed to access IPlatform service")
132 maybeLaunchLater(args
, justShow
)
136 platformService
= IPlatform
.get_service(args
)
138 ret
= platformService
.launchIntent(args
.ACTION
, args
.URI
)
141 pkg
= ret
if ret
!= "android" else "Waydroid"
142 platformService
.setprop("waydroid.active_apps", pkg
)
143 multiwin
= platformService
.getprop(
144 "persist.waydroid.multi_windows", "false")
145 if multiwin
== "false":
146 platformService
.settingsPutString(
147 2, "policy_control", "immersive.status=*")
149 platformService
.settingsPutString(
150 2, "policy_control", "immersive.full=*")
152 logging
.error("Failed to access IPlatform service")
153 maybeLaunchLater(args
, justLaunch
)