Merge lp:~mdeslaur/indicator-power/fix-priorities into lp:indicator-power/15.10

Proposed by Marc Deslauriers on 2015-06-02
Status: Approved
Approved by: Charles Kerr on 2015-09-15
Approved revision: 289
Proposed branch: lp:~mdeslaur/indicator-power/fix-priorities
Merge into: lp:indicator-power/15.10
Diff against target: 71 lines (+25/-3)
3 files modified
debian/changelog (+7/-0)
src/service.c (+11/-2)
tests/test-device.cc (+7/-1)
To merge this branch: bzr merge lp:~mdeslaur/indicator-power/fix-priorities
Reviewer Review Type Date Requested Status
Charles Kerr (community) 2015-06-02 Approve on 2015-09-15
PS Jenkins bot continuous-integration Approve on 2015-06-02
Ted Gould 2015-08-28 Pending
Review via email: mp+260903@code.launchpad.net

Description of the Change

Don't prioritize discharging items with no time estimate that have more
than 10% power remaining.

Devices with no time estimates are most likely low-power devices that
have long-lasting batteries, such as a mouse with AA batteries. For those
type of devices that contain batteries that last weeks, there is no value
in displaying their status in preference to devices that have a rapid
charge/discharge cycle.

However, there is value in knowing if the device has a battery that needs
replacing imminently, so only display it if it falls to a 10% charge or
under.

To post a comment you must log in.
Charles Kerr (charlesk) wrote :

LGTM, this is a nice improvement.

You might want to ping mpt as a courtesy, this is the kind of detail that in the past he's documented at https://wiki.ubuntu.com/Power

review: Approve
Matthew Paul Thomas (mpt) wrote :

Does "prioritize" mean "show in the menu title"?

For a desktop PC connected to AC power with a wireless mouse, the mouse would be the only interesting thing in the menu. What would be the title of the menu when the mouse had >10% charge?

Marc Deslauriers (mdeslaur) wrote :

The priority determines what shows in the menu title, yes.

This doesn't remove it, it simply sets it with a lower priority than other devices. On a desktop PC with AC power and a wireless mouse, the mouse would be displayed at all times.

Marc Deslauriers (mdeslaur) wrote :

Oh, actually, let me check that.

Marc Deslauriers (mdeslaur) wrote :

@mpt: ah, yes, that scenario isn't properly handled. Thanks for spotting that, I'll prepare a new merge request.

Would this be a reasonable order?

   1. discharging items from least time remaining until most time remaining
   2. charging items from most time left to charge to least time left to charge
   3. charging items with an unknown time remaining
   4. discharging items with an unknown time remaining, but 10% or below
   5. batteries
   6. non-line power
   7. discharging items with an unknown time remaining, but above 10%
   8. line-power

Marc Deslauriers (mdeslaur) wrote :

The mouse should be shown in preference to a fully-charged UPS, so this would be better:

Would this be a reasonable order?

   1. discharging items from least time remaining until most time remaining
   2. charging items from most time left to charge to least time left to charge
   3. charging items with an unknown time remaining
   4. discharging items with an unknown time remaining, but 10% or below
   5. batteries
   6. discharging items with an unknown time remaining, but above 10%
   7. non-line power
   8. line-power

Matthew Paul Thomas (mpt) wrote :

Clarifying that language from our discussion on IRC:

   1. discharging things - from least time remaining, to most time remaining
   2. charging things - from most time left to charge, to least time left to charge
   3. charging things with unknown time remaining
   4. discharging things with unknown time remaining, 10% or less charge
   5. notebook batteries fully charged
   6. discharging things with unknown time remaining, more than 10% charge
   7. anything else fully charged

I still doubt that it's a good idea to judge things with unknown time remaining based on percentage. A quick Web search shows me people reporting their mouse battery lasting anywhere from "5 months or so" down to just "2-3 weeks". Someone who got used to the mouse icon showing up when they had 15 days left (10% * 5 months) would be unpleasantly surprised when a different mouse showed up with only 1.5 days warning (10% * 2 weeks).

Wherever it falls on that scale, though, upower has at least a week in which it can measure the decline and make an estimate of time remaining. If it is failing to make an estimate in that time, why is this not a bug in upower?

Unmerged revisions

289. By Marc Deslauriers on 2015-06-02

Don't prioritize discharging items with no time estimate that have more
than 10% power remaining.

Devices with no time estimates are most likely low-power devices that
have long-lasting batteries, such as a mouse with AA batteries. For those
type of devices that contain batteries that last weeks, there is no value
in displaying their status in preference to devices that have a rapid
charge/discharge cycle.

However, there is value in knowing if the device has a battery that needs
replacing imminently, so only display it if it falls to a 10% charge or
under.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-05-22 17:54:53 +0000
3+++ debian/changelog 2015-06-02 23:29:33 +0000
4@@ -1,3 +1,10 @@
5+indicator-power (12.10.6+15.10.20150522-0ubuntu2) UNRELEASED; urgency=medium
6+
7+ * Don't prioritize discharging items with no time estimate that have more
8+ than 10% power remaining.
9+
10+ -- Marc Deslauriers <marc.deslauriers@ubuntu.com> Tue, 02 Jun 2015 19:17:14 -0400
11+
12 indicator-power (12.10.6+15.10.20150522-0ubuntu1) wily; urgency=medium
13
14 [ Charles Kerr ]
15
16=== modified file 'src/service.c'
17--- src/service.c 2015-05-14 21:53:02 +0000
18+++ src/service.c 2015-06-02 23:29:33 +0000
19@@ -164,8 +164,9 @@
20 1. discharging items from least time remaining until most time remaining
21 2. charging items from most time left to charge to least time left to charge
22 3. charging items with an unknown time remaining
23- 4. discharging items with an unknown time remaining
24- 5. batteries, then non-line power, then line-power */
25+ 4. discharging items with an unknown time remaining, but 10% or below
26+ 5. batteries, then non-line power, then line-power
27+ 6. discharging items with an unknown time remaining, but above 10% */
28 static gint
29 device_compare_func (gconstpointer ga, gconstpointer gb)
30 {
31@@ -183,6 +184,14 @@
32 ret = 0;
33
34 state = UP_DEVICE_STATE_DISCHARGING;
35+
36+ /* discharging items with more than 10% remaining always lose */
37+ if (!ret && (((a_state == state) && !a_time && (a_percentage > 10))))
38+ ret = 1;
39+
40+ if (!ret && (((b_state == state) && !b_time && (b_percentage > 10))))
41+ ret = -1;
42+
43 if (!ret && (((a_state == state) && a_time) ||
44 ((b_state == state) && b_time)))
45 {
46
47=== modified file 'tests/test-device.cc'
48--- tests/test-device.cc 2015-01-12 21:47:27 +0000
49+++ tests/test-device.cc 2015-06-02 23:29:33 +0000
50@@ -723,7 +723,9 @@
51 { "/some/path/f0", UP_DEVICE_KIND_BATTERY, UP_DEVICE_STATE_FULLY_CHARGED, 0, 100.0 }, // 6
52 { "/some/path/m0", UP_DEVICE_KIND_MOUSE, UP_DEVICE_STATE_DISCHARGING, 20, 80.0 }, // 7
53 { "/some/path/m1", UP_DEVICE_KIND_MOUSE, UP_DEVICE_STATE_FULLY_CHARGED, 0, 100.0 }, // 8
54- { "/some/path/pw", UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 } // 9
55+ { "/some/path/pw", UP_DEVICE_KIND_LINE_POWER, UP_DEVICE_STATE_UNKNOWN, 0, 0.0 }, // 9
56+ { "/some/path/m2", UP_DEVICE_KIND_MOUSE, UP_DEVICE_STATE_DISCHARGING, 0, 80.0 }, // 10
57+ { "/some/path/m3", UP_DEVICE_KIND_MOUSE, UP_DEVICE_STATE_DISCHARGING, 0, 5.0 }, // 11
58 };
59
60 std::vector<IndicatorPowerDevice*> devices;
61@@ -752,6 +754,10 @@
62
63 { { 0, 7 }, descriptions[0] }, // 1 discharging battery, 1 discharging mouse. pick the one with the least time left.
64 { { 2, 7 }, descriptions[7] }, // 1 discharging battery, 1 discharging mouse. pick the one with the least time left.
65+ { { 2, 10 }, descriptions[2] }, // 1 discharging battery, 1 discharging mouse over 10% with no time estimate. pick the battery.
66+ { { 6, 10 }, descriptions[6] }, // 1 fully charged battery, 1 discharging mouse over 10% with no time estimate. pick the battery.
67+ { { 2, 11 }, descriptions[2] }, // 1 discharging battery with time estimate, 1 discharging mouse below 10% with no time estimate. prefer the device with the time estimate.
68+ { { 6, 11 }, descriptions[11] }, // 1 fully charged battery, 1 discharging mouse below 10% with no time estimate. pick the mouse below 10%.
69
70 { { 0, 8 }, descriptions[0] }, // 1 discharging battery, 1 fully-charged mouse. pick the one that's discharging.
71 { { 6, 7 }, descriptions[7] }, // 1 discharging mouse, 1 fully-charged battery. pick the one that's discharging.

Subscribers

People subscribed via source and target branches