desc:充电逻辑完善

main
xiaowusky 1 year ago
parent cedc31604d
commit 6094140fa6

@ -35,11 +35,15 @@ object BatteryHelper {
callbacks.forEach {
it.onLevel(level, batteryManager?.isCharging == true)
}
} /*else if (Intent.ACTION_POWER_CONNECTED == action) {
charging = true
} else if (Intent.ACTION_POWER_CONNECTED == action) {
callbacks.forEach {
it.onLevel(mLevel, batteryManager?.isCharging == true)
}
} else if (Intent.ACTION_POWER_DISCONNECTED == action) {
charging = false
}*/
callbacks.forEach {
it.onLevel(mLevel, batteryManager?.isCharging == true)
}
}
}
}
@ -79,8 +83,8 @@ object BatteryHelper {
private fun watchBattery(context: Context) {
val filter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)
// filter.addAction(Intent.ACTION_POWER_CONNECTED)
// filter.addAction(Intent.ACTION_POWER_DISCONNECTED)
filter.addAction(Intent.ACTION_POWER_CONNECTED)
filter.addAction(Intent.ACTION_POWER_DISCONNECTED)
context.registerReceiver(receiver, filter)
}

Loading…
Cancel
Save