LeOSium_webview/mulch/patches/0001-Vanadium/0050-stub-out-the-battery-s...

66 lines
2.3 KiB
Diff
Raw Permalink Normal View History

2023-11-18 11:46:19 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Mon, 17 Jun 2019 11:29:21 -0400
Subject: [PATCH] stub out the battery status API
Pretend that the device is always plugged in and fully charged.
---
.../modules/battery/battery_manager.cc | 26 +++----------------
1 file changed, 4 insertions(+), 22 deletions(-)
diff --git a/third_party/blink/renderer/modules/battery/battery_manager.cc b/third_party/blink/renderer/modules/battery/battery_manager.cc
index 05cbfd0b52ddc..60fd8093ca695 100644
--- a/third_party/blink/renderer/modules/battery/battery_manager.cc
+++ b/third_party/blink/renderer/modules/battery/battery_manager.cc
@@ -78,46 +78,28 @@ ScriptPromise BatteryManager::StartRequest(ScriptState* script_state) {
}
bool BatteryManager::charging() {
- return battery_status_.Charging();
+ return true;
}
double BatteryManager::chargingTime() {
- return battery_status_.charging_time().InSecondsF();
+ return 0.0;
}
double BatteryManager::dischargingTime() {
- return battery_status_.discharging_time().InSecondsF();
+ return std::numeric_limits<double>::infinity();
}
double BatteryManager::level() {
- return battery_status_.Level();
+ return 1.0;
}
void BatteryManager::DidUpdateData() {
DCHECK(battery_property_);
- BatteryStatus old_status = battery_status_;
- battery_status_ = *battery_dispatcher_->LatestData();
-
if (battery_property_->GetState() == BatteryProperty::kPending) {
battery_property_->Resolve(this);
return;
}
-
- DCHECK(GetExecutionContext());
- if (GetExecutionContext()->IsContextPaused() ||
- GetExecutionContext()->IsContextDestroyed()) {
- return;
- }
-
- if (battery_status_.Charging() != old_status.Charging())
- DispatchEvent(*Event::Create(event_type_names::kChargingchange));
- if (battery_status_.charging_time() != old_status.charging_time())
- DispatchEvent(*Event::Create(event_type_names::kChargingtimechange));
- if (battery_status_.discharging_time() != old_status.discharging_time())
- DispatchEvent(*Event::Create(event_type_names::kDischargingtimechange));
- if (battery_status_.Level() != old_status.Level())
- DispatchEvent(*Event::Create(event_type_names::kLevelchange));
}
void BatteryManager::RegisterWithDispatcher() {