mirror of
https://github.com/by-sonic/tglock.git
synced 2026-11-05 15:21:55 +03:00
Recognize accessible Android power button labels
This commit is contained in:
@@ -45,7 +45,10 @@ def ui_dump(label):
|
|||||||
|
|
||||||
def label_node(tree, label):
|
def label_node(tree, label):
|
||||||
for node in tree.iter("node"):
|
for node in tree.iter("node"):
|
||||||
if label in (node.get("text", ""), node.get("content-desc", "")):
|
# Android aggregates the decorative arrow into the button's accessible
|
||||||
|
# text (observed in the API35 CI dump). Accept only that exact suffix.
|
||||||
|
names = (node.get("text", "").strip(), node.get("content-desc", "").strip())
|
||||||
|
if any(name in (label, f"{label} →") for name in names):
|
||||||
bounds = re.fullmatch(r"\[(\d+),(\d+)\]\[(\d+),(\d+)\]", node.get("bounds", ""))
|
bounds = re.fullmatch(r"\[(\d+),(\d+)\]\[(\d+),(\d+)\]", node.get("bounds", ""))
|
||||||
if bounds:
|
if bounds:
|
||||||
x1, y1, x2, y2 = map(int, bounds.groups())
|
x1, y1, x2, y2 = map(int, bounds.groups())
|
||||||
|
|||||||
Reference in New Issue
Block a user