]>
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
6 import tools
.helpers
.run
7 from tools
.interfaces
import IPlatform
10 def host_get(args
, prop
):
11 if which("getprop") is not None:
12 command
= ["getprop", prop
]
13 return tools
.helpers
.run
.user(args
, command
, output_return
=True).strip()
17 def host_set(args
, prop
, value
):
18 if which("setprop") is not None:
19 command
= ["setprop", prop
, value
]
20 tools
.helpers
.run
.user(args
, command
)
23 if os
.path
.exists(tools
.config
.session_defaults
["config_path"]):
24 session_cfg
= tools
.config
.load_session()
25 if session_cfg
["session"]["state"] == "RUNNING":
26 platformService
= IPlatform
.get_service(args
)
28 return platformService
.getprop(prop
, "")
30 logging
.error("Failed to access IPlatform service")
32 logging
.error("WayDroid container is {}".format(
33 session_cfg
["session"]["state"]))
35 logging
.error("WayDroid session is stopped")
37 def set(args
, prop
, value
):
38 if os
.path
.exists(tools
.config
.session_defaults
["config_path"]):
39 session_cfg
= tools
.config
.load_session()
40 if session_cfg
["session"]["state"] == "RUNNING":
41 platformService
= IPlatform
.get_service(args
)
43 platformService
.setprop(prop
, value
)
45 logging
.error("Failed to access IPlatform service")
47 logging
.error("WayDroid container is {}".format(
48 session_cfg
["session"]["state"]))
50 logging
.error("WayDroid session is stopped")