Closed Bug 1163245 Opened 9 years ago Closed 9 years ago

[Battery] Implementation of battery discharging remaining time

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: zbraniecki, Assigned: zbraniecki)

References

Details

Attachments

(1 file, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #1116368 +++

This bug is to discuss the implementation of battery discharging remaining time.
Currently, we didn't have calculation of battery discharging remaining time, there are only two values, kUnknownRemainingTime and kDefaultRemainingTime.
https://dxr.mozilla.org/mozilla-central/source/hal/gonk/GonkHal.cpp?from=GonkHal.cpp&case=true#670-672
No longer blocks: 1115921
Attached patch patch (obsolete) — Splinter Review
Dave, this patch is parallel to patch from bug 1116368.

I tested it on Nexus 5 and it seems to work well. I'd like to use it for plotting battery chart over time.
Assignee: nobody → gandalf
Status: NEW → ASSIGNED
Attachment #8603679 - Flags: review?(dhylands)
Just a reminder for myself: it seems that switching charging state uses previous state for calculation. We probably need to reset the previous state when charging changes.
Status: ASSIGNED → NEW
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #2)
> Just a reminder for myself: it seems that switching charging state uses
> previous state for calculation. We probably need to reset the previous state
> when charging changes.

lastLevelChange is cleared whenever the state changes from charging to discharging (or vice-versa).

I don't see the static variable remainingTime being reset though.
Comment on attachment 8603679 [details] [diff] [review]
patch

Review of attachment 8603679 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good except for the point about remainingTime.

::: hal/gonk/GonkHal.cpp
@@ +691,5 @@
> +
> +    } else {
> +      clock_gettime(CLOCK_MONOTONIC, &now);
> +      dtime = now.tv_sec - lastLevelChange.tv_sec;
> +      if (dtime < remainingTime) {

It seems like remainingTime might not be set properly if you change state from charging to dischanrging and aBatteryInfo->level() == previousLevel

remainingTime would contain the remaining time to reach full charge, not the remainingTime until discharged. This would autocorrect fairly quickly, but that's the only case I don't see handled properly.
Attachment #8603679 - Flags: review?(dhylands) → review+
Attached patch patch v2Splinter Review
Updated the patch to reset remainingTime. Carrying r+
Attachment #8603679 - Attachment is obsolete: true
Attachment #8604392 - Flags: review+
Blocks: 896847
No longer blocks: 1163867
Status: NEW → ASSIGNED
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: