I'm currently developing a small application for temporarily monitoring sensors in c, that should initiate a wakelock and release it after it ran but not release it, if a wakelock was aquired before execution.
essentially this is my goal:
was wake lock present before the application was executed?
- ignore it
wasn't it present before the application was executed?
- obtain and clear it throughout the lifetime of this application
---
when running
termux-notification-list
, I can check if a wakelock is currently present by searching through it's output until I find this:
{
"id": 1337,
"tag": "",
"key": "0|com.termux|1337|null|10179",
"group": "",
"packageName": "com.termux",
"title": "Termux",
"content": "1 session (wake lock held)",
"when": "2024-11-04 15:14:24"
}
### is there a better way to figure out if a wakelock is currently in place?
I consider querying notifications a bad idea, as notifications can be discarded even if they are permanent.
Asked by GottZ
(101 rep)
Nov 4, 2024, 02:27 PM