Skip to content

[Patch] | PR BLOCKED . posting patch as issue instead | idle timeout : idle drain safe guard . remove from power intensive apps  #5128

@john-peterson

Description

@john-peterson

[Patch] | PR BLOCKED . posting patch as issue instead | idle timeout : idle drain safe guard . remove from power intensive apps

I can't post pull request

gh pr create
pull request create failed: GraphQL:  john-peterson does not have the correct permissions to execute `CreatePullRequest` (createPullRequest) 

https://github.com/john-peterson/termux-app/pull/new/u/alarm

An owner of this repository has limited the ability to open a pull request to users that are collaborators on this repository.

gh api repos/termux/termux-app/collaborators 
{"message":"Must have push access to view repository collaborators.","documentation_url":"https://docs.github.com/rest/collaborators/collaborators#list-repository-collaborators","status":"403"}

I can't find any new info anywhere about contributing in readme or any other file . I can't see any issue or discussion asking about how to contribute now or the reason for blocking pull request

GUI show a request three weeks ago from a user with no team label

https://github.com/termux/termux-app/pulls

so I assume this was changed less than three weeks ago and no explanation was given or asked for yet

I looked at recent closed pull request to see what could have caused this change

the last closed pull request had an explanation posted on matrix . some kind of IRC server . that translation are not accepted

before that GUI show many apparent accidental pr by aripitek to change the files to his fork for no explanation . maybe he doesn't even know he posted it here

it seems like he is accidentally submitting pr for every patch he is pushing to his fork

https://github.com/termux/termux-app/pulls?q=is%3Aclosed

gh pr list --state closed
gh pr list --label spam --state all|v

I assume some of the owners blocked public access instead of blocking the accidental user aripitek

if it's only for one user it's better to block the user that doesn't know how to use GitHub instead of blocking public access


I post this patch as an issue instead . if I still have permission to create issue or if that also is restricted to an invite list

https://github.com/john-peterson/termux-app/commits/u/alarm

I hope it can be merged anyway . but I'm not optimistic about it it will probably get lost amongst the mass of other issues

it's a quality patch that some users need to prevent battery drain


this should remove termux from power intensive apps . the idle drain blame list . otherwise it will get the label

Stop the dormancy of the system

this happens to apps in the Active apps fragment list that is opened from the bottom of quick settings drawer if this message appears

1 app is active

if you open the fragment you get a warning about idle drain

I don't know how it works on all phones settings is always modified . this applies to unisoc phones that I use for price to value reasons

new config file

enable 30 minute time out with a different config file

vim $DATA/shared_prefs/config.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
	<int name="idle_timeout" value="30" />
</map>

if you try to edit this file

vim $DATA/shared_prefs/com.termux_preferences.xml

the changes will be overridden by commit functions designed for GUI with absolutely no CLI in mind

the new config file is CLI aware. it will not be changed randomly by commit functions

keep or close orphans

my termux session will restore an existing tmux session

vim .bashrc
procs=$(pidof tmux | wc | tr -s " " | cut -f3 -d" ")
if [ $procs -eq 0 ]; then
	tmux
elif test $procs -eq 1; then
	test -z "$TMUX" && tmux a
fi

one time this tmux session was still running seven hours later

logcat -d|ack -i alarm|tail
05-23 23:00:00.431 26893 26893 D Termux.SystemEventReceiver:   ALARM shut down  battery level   93%

date|copy
Sun May 24 06:35:54 ADT 2026
termux-battery-status | jq .level
92

battery drain was negligible it was as probably frozen and did no harm

I don't know if it happens when termux is in the foreground or why it doesn't purge child apps . usually they are quickly removed when termux is gone

I have tried to remove them myself to save battery

john-peterson/termux-app@orphan

but I reverted back to keeping them because I some times accidentally cross the 32 app limit and lose the tmux client and crucially the only termux bash child

pstree
?─┬─?─┬─com.termux───/data/data/com.termux/files/usr/bin/bash───tmux
  │   └─com.termux.api
  └─tmux─┬─-bash─┬─bash───bash
         │       └─pstree

which will close termux

but if I quickly start it again the server is some times still running with my entire session intact

this has led me to consider a redesigne to ask if I want to restart bash instead of closing termux with the hope of saving my tmux server and session from disappearing

Todo restart killed bash client when 32 app limit is tripped

if you trip the 32 app limit the first child app will be closed by android . this will also close the tmux client and perhaps incorrectly the entire termux session and service

ack -i signal -t java
terminal-emulator/src/main/java/com/termux/terminal/TerminalSession.java
exitDescription += " (signal " + (-exitCode) + ")";
exitDescription += " - press Enter]";

this could be re designed to restart the bash client instead of closing termux and risk losing all children

exitDescription += " - press Enter to close or r to restart ]";

this might save the tmux service and all children

when I close termux is seems like the system immediately close all children . or even termux I don't know what it does when closing exactly

power intensive apps settings fragment

I've had this on both my latest unisoc phones called Hisense and umidigi in different markets

if this exist

getprop |ack pwctl

power intensive apps button is under battery page . but not the main activity

am start -n 'com.android.settings/.Settings$BatteryActivity'
am start -a android.intent.action.BATTERY_SUMMARY

a different looking page with more buttons under this label

App battery settings

nothing of this is exported or explained

dumpsys package com.android.settings|vack apk
cp /system_ext/priv-app/Settings/Settings.apk .
apktool d -j1 -o settings Settings.apk
vim smali/com/android/settings/fuelgauge/PowerIntensiveAppsPreferenceController.smali
.field private final isSupportUnisocPowerManager:Z
const-string p1, "persist.sys.pwctl.enable"

unisoc doesn't have the right files up . only the regular aosp app

unisoc-android/android_packages_apps_Settings

another vendor has posted their source

gh search code TYPE_APP_POWER_INTENSIVE
jingpad-bsp/vendor_sprd_platform_packages_apps_Settings src/com/android/settings/fuelgauge/SprdPowerIntensiveAppsPreferenceController.java

it's in a fragment that can't be launched from terminal without adb

I am impressed by the idle drain on my unisoc phones but they haven't been able to convince upstream apparently

todo same for termux API

termux API should also be removed from the list with the same fix

the listening socket should time out when screen off for a long time

a sad update in my android 14 unisoc the API socket connection fails constantly . otherwise everything works the same as in android 13

race between alarm and cancel alarm

you may see termux close when you unlock your phone . this is not a coincidence it's a race condition

there is no elegant way to avoid it

my investigation of all alternative is in

john-peterson/openapp@timer

all the more complicated solutions are riddled with bugs . this solution is the simplest and best it never fails

my branch versus this branch

if the build fails it's because I use another branch with all my patches

john-peterson/termux-app@alarm

barring possible typos this is a solid patch I have used it for months it never fails

idle drain problem

the only way to get idle drain to zero is to remove or patch all apps on the power intensive apps list . and use battery saver

with out battery saver idle drain is so severe battery only last three days .
even when all radios are off with air plane mode active

battery saver makes a gigantic difference around a factor of ten

if battery saver is functional battery drain should be three per cent per day or equivalent one month

on expedition this should make it possible to retrieve a location occasionally for a month until a broken sun panel can be replaced

I was is Australia when this problem became so severe I had to create this patch

the crucial setting for this drastic difference is

force_background_check

these have only minor effect on long term drain

force_all_apps_standby
enable_quick_doze

and increase drain for wake up. it requires more battery to return from a deep sleep state . the others are meaningless and

enable_night_mode

a disaster because the phone can't be used in day light

I have posted a new settings API that solve this problem as explained on the post

there is no way to reduce idle drain more or completely block back ground workers for most apps . this is a job opportunity

some app stores are notorious for their enormous bombardment of meaningless workers to increase ad revenue and engagement . but this applies to many apps with aggressive monetisation or poor design

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions