2

I’m making some optimizations on my app for devices with "power saving mode" enabled.

Here's the sample code:

import android.content.Context;
import android.os.PowerManager;
import android.provider.Settings;

//for MIUI
private boolean isPowerSaveModeMiui(Context context) throws Settings.SettingNotFoundException{
//available for normal or ultra power save mode
//In recent tests, miui use PowerManager.isPowerSaveMOde() on Android S
    return Settings.System.getInt(
        context.getContentResolver(),
        "POWER_SAVE_MODE_OPEN"
    )==1;
}

//for Huawei(EMUI/HARMONY)
private boolean isPowerSaveModeHuawei(Context context) throws Settings.SettingNotFoundException{
    //this is only available for normal power save mode
    //when ultra power save mode is enabled or power save mode is disabled,it returns 1
    return Settings.System.getInt(
        context.getContentResolver(),
        "SmartModeStatus"
    )==4;
    //I can't find any docs for this
}

//for other systems which is api21+
private boolean isPowerSaveMode(Context context){
    return ((PowerManager)context.getSystemService("power"))
        .isPowerSaveMode();
}

Huawei's cloud debugging platform
https://developer.huawei.com/consumer/cn/console#/openCard/AppService/1045


log outputs
enable normal power save mode
power save mode on:"SmartModeStatus" is 4

disable normal power save mode
power save mode off:"SmartModeStatus" is 1

enable ultra power save mode
"SmartModeStatus" set to 1
An intent was sent but don't know if it's public.


So how can I detect "Ultra power save mode" in Huawei devices with Settings.System.getInt method(or their own api)?
btw, does Sony/Samsung or others has their own properties for this?
Thx

Ayaka_Ago
  • 89
  • 9
  • I found [solution here](https://stackoverflow.com/a/70793546/16141229). For testing, use [Huawei's cloud debugging service](https://developer.huawei.com/consumer/cn/console#/openCard/AppService/1045), to enable `Ultra power save mode` (they may block you from openning system settings page), select **EMUI 8.2.0**, **Nova 3**, and toggle it in `quick settings tile`. – Ayaka_Ago Mar 04 '22 at 16:09

0 Answers0