]>
glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/helpers/props.py
1 # Copyright 2021 Oliver Smith
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 from shutil
import which
7 import tools
.helpers
.run
8 from tools
.interfaces
import IPlatform
11 def host_get(args
, prop
):
12 if which("getprop") is not None:
13 command
= ["getprop", prop
]
14 return subprocess
.run(command
, stdout
=subprocess
.PIPE
).stdout
.decode('utf-8').strip()
18 def host_set(args
, prop
, value
):
19 if which("setprop") is not None:
20 command
= ["setprop", prop
, value
]
21 tools
.helpers
.run
.user(args
, command
)
24 if os
.path
.exists(tools
.config
.session_defaults
["config_path"]):
25 session_cfg
= tools
.config
.load_session()
26 if session_cfg
["session"]["state"] == "RUNNING":
27 platformService
= IPlatform
.get_service(args
)
29 return platformService
.getprop(prop
, "")
31 logging
.error("Failed to access IPlatform service")
33 logging
.error("WayDroid container is {}".format(
34 session_cfg
["session"]["state"]))
36 logging
.error("WayDroid session is stopped")
38 def set(args
, prop
, value
):
39 if os
.path
.exists(tools
.config
.session_defaults
["config_path"]):
40 session_cfg
= tools
.config
.load_session()
41 if session_cfg
["session"]["state"] == "RUNNING":
42 platformService
= IPlatform
.get_service(args
)
44 platformService
.setprop(prop
, value
)
46 logging
.error("Failed to access IPlatform service")
48 logging
.error("WayDroid container is {}".format(
49 session_cfg
["session"]["state"]))
51 logging
.error("WayDroid session is stopped")