]>
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")
31 os
.remove(tmp_dir
+ "/base.apk")
33 if session
["state"] == "FROZEN":
35 except (dbus
.DBusException
, KeyError):
36 logging
.error("WayDroid session is stopped")
40 tools
.helpers
.ipc
.DBusSessionService()
42 cm
= tools
.helpers
.ipc
.DBusContainerService()
43 session
= cm
.GetSession()
44 if session
["state"] == "FROZEN":
47 platformService
= IPlatform
.get_service(args
)
49 ret
= platformService
.removeApp(args
.PACKAGE
)
51 logging
.error("Failed to uninstall package: {}".format(args
.PACKAGE
))
53 if session
["state"] == "FROZEN":
55 except dbus
.DBusException
:
56 logging
.error("WayDroid session is stopped")
58 def maybeLaunchLater(args
, launchNow
):
60 tools
.helpers
.ipc
.DBusSessionService()
62 tools
.helpers
.ipc
.DBusContainerService().Unfreeze()
64 logging
.error("Failed to unfreeze container. Trying to launch anyways...")
66 except dbus
.DBusException
:
67 logging
.error("Starting waydroid session")
68 tools
.actions
.session_manager
.start(args
, launchNow
)
72 platformService
= IPlatform
.get_service(args
)
74 platformService
.setprop("waydroid.active_apps", args
.PACKAGE
)
75 ret
= platformService
.launchApp(args
.PACKAGE
)
76 multiwin
= platformService
.getprop(
77 "persist.waydroid.multi_windows", "false")
78 if multiwin
== "false":
79 platformService
.settingsPutString(
80 2, "policy_control", "immersive.status=*")
82 platformService
.settingsPutString(
83 2, "policy_control", "immersive.full=*")
85 logging
.error("Failed to access IPlatform service")
86 maybeLaunchLater(args
, justLaunch
)
90 tools
.helpers
.ipc
.DBusSessionService()
92 cm
= tools
.helpers
.ipc
.DBusContainerService()
93 session
= cm
.GetSession()
94 if session
["state"] == "FROZEN":
97 platformService
= IPlatform
.get_service(args
)
99 appsList
= platformService
.getAppsInfo()
101 print("Name: " + app
["name"])
102 print("packageName: " + app
["packageName"])
104 for cat
in app
["categories"]:
107 if session
["state"] == "FROZEN":
110 logging
.error("Failed to access IPlatform service")
111 except dbus
.DBusException
:
112 logging
.error("WayDroid session is stopped")
114 def showFullUI(args
):
116 platformService
= IPlatform
.get_service(args
)
118 platformService
.setprop("waydroid.active_apps", "Waydroid")
119 platformService
.settingsPutString(2, "policy_control", "null*")
120 # HACK: Refresh display contents
121 statusBarService
= IStatusBarService
.get_service(args
)
123 statusBarService
.expand()
125 statusBarService
.collapse()
126 maybeLaunchLater(args
, justShow
)
130 platformService
= IPlatform
.get_service(args
)
132 ret
= platformService
.launchIntent(args
.ACTION
, args
.URI
)
135 pkg
= ret
if ret
!= "android" else "Waydroid"
136 platformService
.setprop("waydroid.active_apps", pkg
)
137 multiwin
= platformService
.getprop(
138 "persist.waydroid.multi_windows", "false")
139 if multiwin
== "false":
140 platformService
.settingsPutString(
141 2, "policy_control", "immersive.status=*")
143 platformService
.settingsPutString(
144 2, "policy_control", "immersive.full=*")
146 logging
.error("Failed to access IPlatform service")
147 maybeLaunchLater(args
, justLaunch
)