Closed angelog0 closed 1 year ago
Normally the wake lock is a permission granted to apps without user conset IIRC. You can try searching Termux in your app list in the settings app and look for denied permissions.
@tareksander, here it asked. There was a sort of warning about the usage of app in background consuming battery. I searched in Settings (Termux, Notifications, Battery) but found anything of useful.. and about my question n. 2?
Do you have the Termux:API app installed?
@tareksander, I installed the termux-api
and jq
packages..
You have to install the app: https://github.com/termux/termux-api
Ah, ok... and for my question n. 1? I would interested to revert consensus..
@angelog0 If you disabled the battery optimization, it can be enabled again in the battery settings of Android OS. There is a dedicated list of apps and their battery optimization status. Applicable to Samsung and other device models unless they run exotic fork of Android.
Left is menu on Pixel 5 and the right on Samsung Galaxy S7:
termux-wake-lock
or button in the notification will ask to disable battery optimization only if this was not done. You won't be asked again when the optimization has been disabled. This is done through Android Intent ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
, so basically it works one way - to disable the optimization and will not let you enable it again. Moreover that's the point, to disable the optimization once and never ask for doing it again.
I don't think that's possible.
@sylirre, thanks for all your suggestion but here, Xiaomi with AOS 8.1, in Settings - App-Termux-Energy saving
, Termux has Save Battery (suggested)
enabled (the other would be Unrestricted, etc.)
instead in Settings - Battery and performance - battery - save energy app
there are many app listed between which Termux and tapping on it it returns to what I have just described above... and termux-wake-lock
does ask any more..
Xiaomi phones and others have multiple battery related settings for apps, you will have to find on your own, check https://dontkillmyapp.com/xiaomi
Termux will not ask user for disabling battery optimizations if already granted by user, no point in that and it is working as intended. To disable battery optimizations with an android prompt yourself, run am start --user 0 -a android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS -d "package:com.termux"
and select Allow
. If optimizations are already disabled, then no prompt will be shown and
the battery optimizations settings for all apps will need to be opened with am start --user 0 -a android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS
.
Use following after granting termux DUMP
permission with adb
or root
. 356a442c
adb shell dumpsys power | grep -E 'PARTIAL_WAKE_LOCK.*termux:service-wakelock'
PARTIAL_WAKE_LOCK 'termux:service-wakelock' ACQ=-1m48s379ms LONG (uid=10169 pid=15126)
Problem description
Running
termux-wake-lock
the first time opens a popup asking for consensus: this only the first time than it does not ask any more.How can I revert this so that the next time I run that command it asks for consensus?
How can I know if the wake lock is active? Tried:
but it seems to hang: I have to CTRL-C..
Steps to reproduce the behavior.
.
What is the expected behavior?
No response
System information