Eliminate dual-target idle wakeups and stage upcoming a1114 (carbonara) build

- Replace continuous polling in bananarchy-lid and bananarchy-volume-keys with /dev/input inotify watching and IRQ-driven poll(..., -1) steady state, and sync CPU/schedutil/GPU power knobs on flip transitions

- Grant video-group write permissions to Adreno 304 devfreq governor, sync GPU powersave/simple_ondemand across bananarchy-display-power-sync and locker.so, and restore schedutil rate_limit_us on forced transitions

- Trim per-minute statusbar clock forks, skip unchanged ext4 brightness rewrites and no-op sxmo_autosuspend spawns on blanking, and make bananarchy-bt-obex fully event-driven via inotify and blocking select

- Register upcoming build a1114 (carbonara) in version.sh, check-rebuild.sh, CHANGELOG.md, AGENTS.md, and BATTERY-OPTIMIZATION-ANALYSIS.md while keeping a1111 (lennon) as the current public release
This commit is contained in:
Luxferre committed 2026-11-12 12:09:46 +02:00
1 parent ed04da3e23
commit e42024e90d
22 files changed
+416 -75

No files matched your search

+107 -24
View File
@@ -289,7 +289,29 @@ def handle_obex_rx_session(sock):
pass
def run_gamepad_uinput_bridge(is_running):
def open_input_inotify_fd():
try:
import ctypes
libc = ctypes.CDLL(None, use_errno=True)
libc.inotify_init.argtypes = []
libc.inotify_init.restype = ctypes.c_int
libc.inotify_add_watch.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_uint32]
libc.inotify_add_watch.restype = ctypes.c_int
fd = libc.inotify_init()
if fd < 0:
return -1
os.set_inheritable(fd, False)
os.set_blocking(fd, False)
# IN_ATTRIB (0x04) | IN_MOVED_TO (0x80) | IN_CREATE (0x100) | IN_DELETE (0x200)
if libc.inotify_add_watch(fd, b"/dev/input", 0x00000384) < 0:
os.close(fd)
return -1
return fd
except Exception:
return -1
def run_gamepad_uinput_bridge(is_running, wake_r=-1):
ev_fmt = "llHHi"
ev_size = struct.calcsize(ev_fmt)
ui_set_evbit = 0x40045564
@@ -328,6 +350,8 @@ def run_gamepad_uinput_bridge(is_running):
gamepads = {} # path -> {"fd": int, "hat_x": 0, "hat_y": 0, "lx": 0, "ly": 0, "ax": {}}
last_scan = 0.0
last_input_mtime = 0
inotify_fd = open_input_inotify_fd()
need_scan = True
def ensure_uinput():
nonlocal uinput_fd
@@ -385,7 +409,8 @@ def run_gamepad_uinput_bridge(is_running):
while is_running():
now = time.monotonic()
if now - last_scan >= 2.0:
if need_scan or (inotify_fd < 0 and now - last_scan >= 2.0):
need_scan = False
last_scan = now
try:
st_in = os.stat("/dev/input")
@@ -430,17 +455,37 @@ def run_gamepad_uinput_bridge(is_running):
except OSError:
pass
if not gamepads:
fd_map = {info["fd"]: (path, info) for path, info in list(gamepads.items())}
wait_fds = list(fd_map.keys())
if inotify_fd >= 0:
wait_fds.append(inotify_fd)
if wake_r >= 0:
wait_fds.append(wake_r)
if not wait_fds:
time.sleep(1.5)
continue
fd_map = {info["fd"]: (path, info) for path, info in list(gamepads.items())}
sel_timeout = None if (inotify_fd >= 0 and wake_r >= 0) else 2.0
try:
rlist, _, _ = select.select(list(fd_map.keys()), [], [], 1.0)
rlist, _, _ = select.select(wait_fds, [], [], sel_timeout)
except Exception:
time.sleep(0.5)
if is_running():
time.sleep(0.5)
continue
if not is_running():
break
if inotify_fd >= 0 and inotify_fd in rlist:
while True:
try:
if not os.read(inotify_fd, 512):
break
except BlockingIOError:
break
except OSError:
break
need_scan = True
for rfd in rlist:
path, info = fd_map.get(rfd, (None, None))
if not path:
@@ -518,6 +563,11 @@ def run_gamepad_uinput_bridge(is_running):
emit_key(108, 1)
info["ly"] = new_dir
if inotify_fd >= 0:
try:
os.close(inotify_fd)
except OSError:
pass
for info in gamepads.values():
try:
os.close(info["fd"])
@@ -696,10 +746,19 @@ def run_daemon():
notify_networks_ui()
running = True
wake_r, wake_w = os.pipe()
os.set_inheritable(wake_r, False)
os.set_inheritable(wake_w, False)
os.set_blocking(wake_r, False)
os.set_blocking(wake_w, False)
def stop_handler(_signum, _frame):
nonlocal running
running = False
try:
os.write(wake_w, b"\x01")
except OSError:
pass
signal.signal(signal.SIGTERM, stop_handler)
signal.signal(signal.SIGINT, stop_handler)
@@ -737,7 +796,7 @@ def run_daemon():
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
gp_thread = threading.Thread(target=run_gamepad_uinput_bridge,
args=(lambda: running,), daemon=True)
args=(lambda: running, wake_r), daemon=True)
gp_thread.start()
profile_path = "/org/bananarchy/obex_opp"
@@ -776,11 +835,20 @@ def run_daemon():
while running:
try:
if conn is not None:
try:
msg = conn.receive(timeout=1.0)
except TimeoutError:
msg = None
if msg is not None:
while running:
try:
msg = conn.receive(timeout=0.0)
except TimeoutError:
msg = None
except (EOFError, OSError):
try:
conn.close()
except Exception:
pass
conn = None
break
if msg is None:
break
if handle_agent_method_call(conn, msg, agent_path):
pass
elif msg.header.message_type == MessageType.method_call:
@@ -811,20 +879,35 @@ def run_daemon():
if iface == "org.bluez.Device1" and isinstance(changed, dict):
if any(k in changed for k in ("Connected", "Paired", "Bonded")):
notify_networks_ui()
else:
time.sleep(1.0)
if rfcomm_listener is not None:
try:
csock, _addr = rfcomm_listener.accept()
t = threading.Thread(target=handle_obex_rx_session,
args=(csock,), daemon=True)
t.start()
except BlockingIOError:
pass
except Exception:
time.sleep(0.5)
while running:
try:
csock, _addr = rfcomm_listener.accept()
t = threading.Thread(target=handle_obex_rx_session,
args=(csock,), daemon=True)
t.start()
except BlockingIOError:
break
if not running:
break
wait_fds = [wake_r]
if conn is not None and getattr(conn, "sock", None) is not None:
wait_fds.append(conn.sock)
if rfcomm_listener is not None:
wait_fds.append(rfcomm_listener)
select.select(wait_fds, [], [], None if len(wait_fds) > 1 else 5.0)
except Exception:
if running:
time.sleep(0.5)
for fd in (wake_r, wake_w):
try:
os.close(fd)
except OSError:
pass
try:
if os.path.exists(PID_FILE):
os.unlink(PID_FILE)