]>
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 subprocess
.run(command
, stdout
=subprocess
.PIPE
).stdout
.decode('utf-8').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 platformService
= IPlatform
.get_service(args
)
25 return platformService
.getprop(prop
, "")
27 logging
.error("Failed to access IPlatform service")
29 def set(args
, prop
, value
):
30 platformService
= IPlatform
.get_service(args
)
32 platformService
.setprop(prop
, value
)
34 logging
.error("Failed to access IPlatform service")
36 def file_get(args
, file, prop
):
37 with open(file) as build_prop
:
38 for line
in build_prop
:
40 if len(line
) == 0 or line
[0] == "#":
42 k
,v
= line
.partition("=")[::2]