Sony

Story

For recent Android versions on Sony devices, AOSP’s Battery saver mode is rebranded as STAMINA mode. If left on default settings, it behaves close to AOSP, but there is an additional opt-in setting under STAMINA mode called Prefer battery time which will have more aggressive limitations on background activity.

For older devices, Sony gets a high bar in our listing of toxic Android vendors, as historically Sony introduced the first very effective non-standard background process optimization and opened Pandora’s box. STAMINA mode on their older devices instantly breaks all background processes and all alarms if enabled.

Solution for users

STAMINA mode

“Prefer battery time”

Newer Android versions on Sony devices have an extra “STAMINA level” setting under STAMINA mode. Avoid setting it to “Prefer battery time” if you need AOSP behaviour.

For older Android versions, never use STAMINA mode if you want your device to do something useful when not actively using it. Despite the official description, it does not affect only mobile data and WiFi, it also terminates any background processes. Stamine mode can be found (and disabled) in either the Battery section or the Power management section.

Older Androids.
Newer Androids.

Intelligence Engine

On some phones, this alteration of stamina mode was reported - it can also break background tasks, or break DND mode schedules.

Adaptive battery

Adaptive battery was reported on Android 11, but it can be present on earlier versions too.

Power-saving feature

The app you need to run in the background needs to be set as Excepted from the Power-saving feature.

System settings ​→ Apps & Notifications ​→ Advanced ​→ Special app access ​→ Power saving feature

Switch Your app to Excepted.

Battery optimisation

Try to make your app not battery optimized in Phone settings > Battery > Three dots in the top right corner > Battery optimisation > Apps > your app.”

Solution for devs

For newer Android versions, check for Battery Saver mode, which for Sony devices is rebranded as STAMINA mode. There is no way to detect if “Prefer battery time” is set, but if your app’s notifications don’t show up or SurfaceFlinger is at a lower framerate than usual, it’s probably on. Alarms are not killed either way, but users can (and some will) deprive your app of the permission to set these alarms in the first place.

For older Android versions, there is no workaround to prevent background process optimizations in STAMINA mode, but apps can detect whether it’s enabled with the following code:

if (Build.MANUFACTURER.equals("sony") && android.provider.Settings.Secure.getInt(context.getContentResolver(), "somc.stamina_mode", 0) > 0) {
    // show warning
}

The problem is this will only tell if Stamina is enabled, but not if it is currently applied, but we can assume it is when not charged and battery is under X%. (TBS)

Badge

Copy embed code to clipboard