Bug 92964 - [EFL] Change return value of battey level
Summary: [EFL] Change return value of battey level
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit EFL (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: http://www.w3.org/TR/battery-status/#...
Keywords:
Depends on:
Blocks: 92839
  Show dependency treegraph
 
Reported: 2012-08-02 02:36 PDT by Kihong Kwon
Modified: 2012-08-02 06:53 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.73 KB, patch)
2012-08-02 03:34 PDT, Kihong Kwon
no flags Details | Formatted Diff | Diff
Patch (1.84 KB, patch)
2012-08-02 03:54 PDT, Kihong Kwon
no flags Details | Formatted Diff | Diff
Patch (2.16 KB, patch)
2012-08-02 04:13 PDT, Kihong Kwon
no flags Details | Formatted Diff | Diff
Patch (1.95 KB, patch)
2012-08-02 05:39 PDT, Kihong Kwon
no flags Details | Formatted Diff | Diff
Patch (1.90 KB, patch)
2012-08-02 05:49 PDT, Kihong Kwon
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kihong Kwon 2012-08-02 02:36:16 PDT
Battery level is defined like below, in the Battery Status API spec.
------------------------------------------------------------
level of type double, readonly
Represents the current battery level scaled from 0 to 1.0.
No exceptions.
------------------------------------------------------------
But EFL battery returns 0 ~ 100 level.

Therefore we need to fix this to 0 ~ 1.0.
Comment 1 Kihong Kwon 2012-08-02 03:34:41 PDT
Created attachment 156027 [details]
Patch
Comment 2 Ryuan Choi 2012-08-02 03:50:00 PDT
Comment on attachment 156027 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156027&action=review

> Source/WebCore/platform/efl/BatteryProviderEfl.cpp:165
>          levelChanged = true;
>      level = property->val.d;
>  
> -    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level);
> +    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level / 100);

If then, should we compare with clientBatteryStatus->level() * 100 and property->val.d ?

IMO, you'd better to assign property->val.d / 100 to `level` to reduce confusion.
Comment 3 Kihong Kwon 2012-08-02 03:52:44 PDT
(In reply to comment #2)
> (From update of attachment 156027 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=156027&action=review
> 
> > Source/WebCore/platform/efl/BatteryProviderEfl.cpp:165
> >          levelChanged = true;
> >      level = property->val.d;
> >  
> > -    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level);
> > +    WTF::RefPtr<BatteryStatus> batteryStatus = BatteryStatus::create(charging, chargingTime, dischargingTime, level / 100);
> 
> If then, should we compare with clientBatteryStatus->level() * 100 and property->val.d ?
> 
> IMO, you'd better to assign property->val.d / 100 to `level` to reduce confusion.

You are right. It was my mistake.
Comment 4 Kihong Kwon 2012-08-02 03:54:48 PDT
Created attachment 156032 [details]
Patch
Comment 5 Ryuan Choi 2012-08-02 04:09:19 PDT
Comment on attachment 156032 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156032&action=review

> Source/WebCore/platform/efl/BatteryProviderEfl.cpp:163
> -    if (!clientBatteryStatus || clientBatteryStatus->level() != property->val.d)
> +    if (!clientBatteryStatus || clientBatteryStatus->level() != property->val.d / 100)
>          levelChanged = true;
> -    level = property->val.d;
> +    level = property->val.d / 100;

I am not sure why you use level, local variable.

IMO, you can remove level variable or assign it before 161 line with declaration.
Comment 6 Kihong Kwon 2012-08-02 04:13:53 PDT
Created attachment 156037 [details]
Patch
Comment 7 Kihong Kwon 2012-08-02 05:39:44 PDT
Created attachment 156051 [details]
Patch
Comment 8 Ryuan Choi 2012-08-02 05:44:49 PDT
Comment on attachment 156051 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=156051&action=review

> Source/WebCore/ChangeLog:11
> +        No new tests, no behavior changed.

I think that this comment is wrong.

This patch changes behavior but we can not make automated tests for this because we can not emulate E_Ukit.

> Source/WebCore/platform/efl/BatteryProviderEfl.cpp:155
> +    double level = property->val.d / 100;

I think that property of "Percentage" is not assigned yet.
Comment 9 Kihong Kwon 2012-08-02 05:49:59 PDT
Created attachment 156053 [details]
Patch
Comment 10 WebKit Review Bot 2012-08-02 06:46:00 PDT
Comment on attachment 156053 [details]
Patch

Clearing flags on attachment: 156053

Committed r124450: <http://trac.webkit.org/changeset/124450>
Comment 11 WebKit Review Bot 2012-08-02 06:46:05 PDT
All reviewed patches have been landed.  Closing bug.