]>
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 platformService
= IPlatform
.get_service(args
)
26 return platformService
.getprop(prop
, "")
28 logging
.error("Failed to access IPlatform service")
30 def set(args
, prop
, value
):
31 platformService
= IPlatform
.get_service(args
)
33 platformService
.setprop(prop
, value
)
35 logging
.error("Failed to access IPlatform service")
37 def file_get(args
, file, prop
):
38 with open(file) as build_prop
:
39 for line
in build_prop
:
41 if len(line
) == 0 or line
[0] == "#":
43 k
,v
= line
.partition("=")[::2]