forked from GrapheneOS/Vanadium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0032-stub-out-the-battery-status-API.patch
67 lines (57 loc) · 2.3 KB
/
0032-stub-out-the-battery-status-API.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From b4afc58ae2ed12b42ea40b96a6bac27a6495813f Mon Sep 17 00:00:00 2001
From: Daniel Micay <[email protected]>
Date: Mon, 17 Jun 2019 11:29:21 -0400
Subject: [PATCH 32/48] stub out the battery status API
Pretend that the device is always plugged in and fully charged.
---
.../modules/battery/battery_manager.cc | 25 +++----------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/third_party/blink/renderer/modules/battery/battery_manager.cc b/third_party/blink/renderer/modules/battery/battery_manager.cc
index 25c3e426682c..34b21b674c1a 100644
--- a/third_party/blink/renderer/modules/battery/battery_manager.cc
+++ b/third_party/blink/renderer/modules/battery/battery_manager.cc
@@ -44,45 +44,28 @@ ScriptPromise BatteryManager::StartRequest(ScriptState* script_state) {
}
bool BatteryManager::charging() {
- return battery_status_.Charging();
+ return true;
}
double BatteryManager::chargingTime() {
- return battery_status_.charging_time();
+ return 0.0;
}
double BatteryManager::dischargingTime() {
- return battery_status_.discharging_time();
+ 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_ = *BatteryDispatcher::Instance().LatestData();
-
if (battery_property_->GetState() == ScriptPromisePropertyBase::kPending) {
battery_property_->Resolve(this);
return;
}
-
- Document* document = To<Document>(GetExecutionContext());
- DCHECK(document);
- if (document->IsContextPaused() || document->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() {
--
2.23.0