The best way to detect it (kotlin):
```
fun isBatterySaveModeEnabled(context: Context): Boolean {
val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
val manufacturer = Build.MANUFACTURER.orEmpty().lowercase()
return when {
manufacturer == "xiaomi" -> {
try {
Settings.System.getInt(
context.contentResolver,
"POWER_SAVE_MODE_OPEN",
0
) == 1
} catch (e: Settings.SettingNotFoundException) {
pm.isPowerSaveMode
}
}
manufacturer == "huawei" || manufacturer == "honor" -> {
try {
val status = Settings.System.getInt(
context.contentResolver,
"SmartModeStatus",
-1
)
val status2 = Settings.System.getInt(
context.contentResolver,
"POWER_SAVE_MODE_OPEN",
0
)
if (manufacturer == "huawei") {
status == 4 || status == 1
} else {
status == 4 || status == 3
}
} catch (e: Settings.SettingNotFoundException) {
pm.isPowerSaveMode
}
}
else -> pm.isPowerSaveMode
}
}
```
You need to detect it for Xiaomi, Huawei and Honor like this:
```
fun isBatterySaveModeEnabled(context: Context): Boolean {
val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
val manufacturer = Build.MANUFACTURER.orEmpty().lowercase()
return when {
manufacturer == "xiaomi" -> {
try {
Settings.System.getInt(
context.contentResolver,
"POWER_SAVE_MODE_OPEN",
0
) == 1
} catch (e: Settings.SettingNotFoundException) {
pm.isPowerSaveMode
}
}
manufacturer == "huawei" || manufacturer == "honor" -> {
try {
val status = Settings.System.getInt(
context.contentResolver,
"SmartModeStatus",
-1
)
val status2 = Settings.System.getInt(
context.contentResolver,
"POWER_SAVE_MODE_OPEN",
0
)
if (manufacturer == "huawei") {
status == 4 || status == 1
} else {
status == 4 || status == 3
}
} catch (e: Settings.SettingNotFoundException) {
pm.isPowerSaveMode
}
}
else -> pm.isPowerSaveMode
}
}
```