mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
fix: report a full battery at 100% while charging, so Steam stops showing 99% (#1577)
* fix: report a full battery at 100% while charging, so Steam stops showing 99% * test: charging at 100% is reported full
This commit is contained in:
1 parent
cf13762939
commit
02767b7e6c
2 files changed
+19
-4
No files matched your search
@@ -49,11 +49,25 @@ class BatteryComponentTest {
|
||||
assertEquals("-2000000", File(supplies, "BAT1/current_now").readText().trim())
|
||||
}
|
||||
|
||||
private fun start(supplies: File, vpower: File, currentUa: Long) {
|
||||
@Test fun chargingAtFullLevelIsReportedFullSoSteamStopsSaying99() {
|
||||
val supplies = tmp.newFolder("power_supply")
|
||||
val vpower = tmp.newFolder("vpower")
|
||||
start(supplies, vpower, 2_000_000L, BatteryManager.BATTERY_STATUS_CHARGING, 100)
|
||||
assertEquals("Full", File(supplies, "BAT1/status").readText().trim())
|
||||
assertEquals("Full", File(vpower, "battery_status").readText().trim())
|
||||
battery?.stop()
|
||||
start(supplies, vpower, 2_000_000L, BatteryManager.BATTERY_STATUS_CHARGING, 99)
|
||||
assertEquals("Charging", File(supplies, "BAT1/status").readText().trim())
|
||||
}
|
||||
|
||||
private fun start(
|
||||
supplies: File, vpower: File, currentUa: Long,
|
||||
status: Int = BatteryManager.BATTERY_STATUS_DISCHARGING, level: Int = 50,
|
||||
) {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
context.sendStickyBroadcast(Intent(Intent.ACTION_BATTERY_CHANGED).apply {
|
||||
putExtra(BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_DISCHARGING)
|
||||
putExtra(BatteryManager.EXTRA_LEVEL, 50)
|
||||
putExtra(BatteryManager.EXTRA_STATUS, status)
|
||||
putExtra(BatteryManager.EXTRA_LEVEL, level)
|
||||
putExtra(BatteryManager.EXTRA_SCALE, 100)
|
||||
putExtra(BatteryManager.EXTRA_VOLTAGE, 4000)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user