Skip to content

Commit f510269

Browse files
committed
fix(battery_plus): Do not call hidden flag on Samsung with Android versions >= 12
1 parent 2cf9297 commit f510269

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • packages/battery_plus/battery_plus/android/src/main/kotlin/dev/fluttercommunity/plus/battery

packages/battery_plus/battery_plus/android/src/main/kotlin/dev/fluttercommunity/plus/battery/BatteryPlusPlugin.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ class BatteryPlusPlugin : MethodCallHandler, EventChannel.StreamHandler, Flutter
124124
}
125125

126126
private fun isSamsungPowerSaveModeActive(): Boolean {
127-
val mode = Settings.System.getString(
128-
applicationContext!!.contentResolver,
129-
POWER_SAVE_MODE_SAMSUNG_NAME
130-
)
127+
// psm_switch check is only available before Android 12 (S)
128+
val mode = if (VERSION.SDK_INT < VERSION_CODES.S) {
129+
Settings.System.getString(
130+
applicationContext!!.contentResolver,
131+
POWER_SAVE_MODE_SAMSUNG_NAME
132+
)
133+
} else {
134+
null
135+
}
136+
131137
return if (mode == null) {
132138
checkPowerServiceSaveMode()
133139
} else {

0 commit comments

Comments
 (0)