Android Question Xiaomi (and others?) killing foreground services during night time

ema01

Member
Licensed User
Longtime User
Hi,
first: I will check again tonight with the location background service app.

second: all power management optimizations has been disabled for the app, app can auto launch itself

third: the app has been working until about a month ago. All of the work (scan BLE, connect to particular device, do stuff with device) is done inside a service, which is supposed to be running at all time, it also has a "restarter" service that will restart the BLE service daily (every day at some time halt BLE service, wait a couple of seconds, restart BLE service, reschedule restarter)

However, now every night the process gets killed by the OS. Tonight i woke up a couple of times, service was not running, so i started the app again and i went back to sleep. Woke up again, service was not running.

During the day the service never gets killed.

I pulled out the logs from the device
B4X:
11-05 04:36:31.071  1908  4552 I ProcessManager: AutoLockOffClean: kill com.package.myapp Adj=200 State=3
11-05 04:36:31.073  1908  4552 I ActivityManager: Killing 14193:com.package.myapp/u0a438 (adj 200): AutoLockOffClean
11-05 04:36:31.075  1908  4552 I ProcessManager: AutoLockOffClean: kill com.google.android.gm Adj=900 State=17
11-05 04:36:31.076  1908  4552 I ActivityManager: Killing 12538:com.google.android.gm/u0a124 (adj 900): AutoLockOffClean
11-05 04:36:31.084  1908  4552 I ProcessManager: AutoLockOffClean: kill com.qti.diagservices Adj=500 State=11
11-05 04:36:31.085  1908  4552 I ActivityManager: Killing 16651:com.qti.diagservices/1000 (adj 500): AutoLockOffClean
11-05 04:36:31.087  1908  4552 I ProcessManager: AutoLockOffClean: kill com.qualcomm.qti.workloadclassifier Adj=500 State=11
11-05 04:36:31.088  1908  4552 I ActivityManager: Killing 16625:com.qualcomm.qti.workloadclassifier/1000 (adj 500): AutoLockOffClean
11-05 04:36:31.090  1908  4552 I ProcessManager: AutoLockOffClean: kill com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0 Adj=100 State=9
11-05 04:36:31.091  1908  4552 I ActivityManager: Killing 16557:com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0/u0a111i52 (adj 100): AutoLockOffClean
11-05 04:36:31.094  1908  4552 I ProcessManager: AutoLockOffClean: kill com.miui.analytics Adj=100 State=4
11-05 04:36:31.095  1908  4552 I ActivityManager: Killing 16434:com.miui.analytics/u0a98 (adj 100): AutoLockOffClean
11-05 04:36:31.097  1908  4552 I ProcessManager: AutoLockOffClean: kill com.miui.msa.global Adj=100 State=9
11-05 04:36:31.098  1908  4552 I ActivityManager: Killing 16377:com.miui.msa.global/u0a111 (adj 100): AutoLockOffClean
11-05 04:36:31.101  1908  4552 I ProcessManager: AutoLockOffClean: kill com.qualcomm.telephony Adj=800 State=11
11-05 04:36:31.101  1908  4552 I ActivityManager: Killing 16351:com.qualcomm.telephony/u0a144 (adj 800): AutoLockOffClean
11-05 04:36:31.103  1908  4552 I ProcessManager: AutoLockOffClean: kill com.whatsapp Adj=200 State=5
11-05 04:36:31.104  1908  4552 I ActivityManager: Killing 15451:com.whatsapp/u0a190 (adj 200): AutoLockOffClean
11-05 04:36:31.106  1908  4552 I ProcessManager: AutoLockOffClean: kill com.google.android.youtube Adj=100 State=7
11-05 04:36:31.106  1908  4552 I ActivityManager: Killing 11107:com.google.android.youtube/u0a148 (adj 100): AutoLockOffClean
11-05 04:36:31.109  1908  4552 I ProcessManager: AutoLockOffClean: kill com.facebook.services Adj=800 State=11
11-05 04:36:31.109  1908  4552 I ActivityManager: Killing 11438:com.facebook.services/u0a24 (adj 800): AutoLockOffClean
11-05 04:36:31.111  1908  4552 I ProcessManager: AutoLockOffClean: kill com.android.settings:remote Adj=800 State=11
11-05 04:36:31.111  1908  4552 I ActivityManager: Killing 11912:com.android.settings:remote/1000 (adj 800): AutoLockOffClean
11-05 04:36:31.112  1908  4552 I ProcessManager: AutoLockOffClean: kill com.android.smspush Adj=100 State=7
11-05 04:36:31.112  1908  4552 I ActivityManager: Killing 10923:com.android.smspush/u0a93 (adj 100): AutoLockOffClean
11-05 04:36:31.115  4686  5057 W ProcessUtils: killProcess failed []
11-05 04:36:31.175  1908  2688 I WindowManager: WIN DEATH: Window{43f2aa6 u0 com.package.myapp/com.package.myapp.main}

[...]

11-05 04:36:31.315  1908  6106 D ProcessManager: skip restart com.package.myapp because this device is a lowmemory device!
 

agraham

Expert
Licensed User
Longtime User
I have a Redmi Note 9 Pro (A Xaiomi brand) and a Xaiomi Mi Max 3 and both seem quite aggressive at killing apps. I find B4ABridge is regularly killed whereas on other makes of device it persists with no problem . It seems to be a common feature of Xaiomi devices that they kill backgound apps in order to potentially extend battery life. I haven't investigated whether there is anything to override this behaviour as it is not that important for me.
 
Upvote 0
Top