Commit Graph

48 Commits

Author SHA1 Message Date
jackqdyulei
495de548bd Add wakeup alarm anomaly detector
Wakeup alarm count frequent is calculated by a / b, where
1. a: the total wakeup alarm count since the last full charge
2. b: total time running since last full charge
(include sleeping time)

This cl also has the following changes:
1. Move bunch of methods to BatteryUtils
2. Create type WAKEUP_ALARM
3. Add and update tests

Upcoming cl will make sure we get the threshold from
AnomalyDetectionPolicy

Bug: 36921529
Test: RunSettingsRoboTests
Change-Id: I4f7b85606df68b6057f6c7d3f3be7f9a9a747f1d
2017-05-23 09:49:14 -07:00
Salvador Martinez
6976ccecee Merge "Use enhanced estimate battery info when available" 2017-05-23 03:28:32 +00:00
Salvador Martinez
be6f07045a Use enhanced estimate battery info when available
This CL updates the battery page to get the updated strings and
other relevant battery info from directly from SettingsLib by
providing it an overrided drain time instead of manually changing
the value in the returned info. This will provide the added benefit
of using the new strings when appropriate that tell the user that
the estimate provided is based on their usage.

Test: robotests
Bug: 38399659
Change-Id: I0db572c2ea78910756314b6bf066d37e9f90a15c
2017-05-22 18:06:29 -07:00
Lei Yu
e1441c63ee Revert "Add animation for battery asyncLoader."
This reverts commit a3c528f64d.

Test: Build
Change-Id: Ib50221873e39dee40c5cf8e4b41dcf7aa13f6134
2017-05-22 14:33:24 -07:00
TreeHugger Robot
b287dc93d5 Merge "Skip cursor loader if not needed" 2017-05-18 20:28:52 +00:00
jackqdyulei
b5219ba29a Merge "Add screen usage string for battery settings" into oc-dev am: 28cf04d994
am: 3ab2ca5cc9

Change-Id: Iaca27db0a637de88c09a45d88f35db258783fa16
2017-05-18 19:35:27 +00:00
TreeHugger Robot
28cf04d994 Merge "Add screen usage string for battery settings" into oc-dev 2017-05-18 19:10:16 +00:00
Salvador Martinez
44b9a4072c Skip cursor loader if not needed
The cursor loader was being started when the battery prediction
feature was not enabled. This could lead to null pointers because
it was not possible to provide it with a valid URI which would
make the CursorLoader unhappy. This CL makes it so we just skip
the CursorLoader initialization entirely when we know the feature
is disabled so we don't have this issue. It also includes a test
to make sure this does not regress.

Test: Robotests
Bug: 38371686
Change-Id: I4f6f6278bbc16668bca0b51fcc7e30f27a9e216f
2017-05-18 11:10:18 -07:00
Lei Yu
9a4be81e5c Merge changes I573e4fb9,I8e7baadc into oc-dev am: 67e38774ce
am: d85bdebe0e

Change-Id: I865f41eae196aee32edd60169dacbc5dca772439
2017-05-18 17:12:34 +00:00
jackqdyulei
2b923ce44f Smear screen power usage based on activity time.
Bug: 38328636
Test: RunSettingsRoboTests
Change-Id: I8e7baadcd88a8e9d674f5bc8d8e42e0f3953c98a
2017-05-17 18:06:47 -07:00
jackqdyulei
7548f1fa77 Add screen usage string for battery settings
In advanced battery page we still use "Used for"

Bug: 38328647
Test: Build & Screenshot
Change-Id: Ic194bfed45a76c811c431a13b5554f5bc978bca5
2017-05-17 13:14:45 -07:00
TreeHugger Robot
b823fcc431 Merge "Add animation for battery asyncLoader." 2017-05-11 23:07:00 +00:00
jackqdyulei
a3c528f64d Add animation for battery asyncLoader.
When battery asyncLoader is loading batterystats, show a battery
placeholder(critical level) and animate to real status once data is
loaded.

Bug: 35917699
Test: RunSettingsRoboTests
Change-Id: Ie4ff73ff2cc0b9e17b4541e3284bf2ac34da42c4
Merged-In: Ie4ff73ff2cc0b9e17b4541e3284bf2ac34da42c4
2017-05-11 15:27:23 -07:00
jackqdyulei
14dcca0e91 Add animation for battery asyncLoader.
Fix merge conflict from oc-dev

When battery asyncLoader is loading batterystats, show a battery
placeholder(critical level) and animate to real status once data is
loaded.

Bug: 35917699
Test: RunSettingsRoboTests
Change-Id: Ie4ff73ff2cc0b9e17b4541e3284bf2ac34da42c4
2017-05-11 10:05:33 -07:00
Salvador Martinez
52aa68f704 Fix null pointer error && add settings side guard
The null check for the cursor happens in the try block
which causes a null pointer error in the finally block
even though we avoid executing the other code because
we still try to close the cursor. This change moves
that outside of the try block to avoid that. Also added
a test to verify that a no-op occurs in the method that
uses the enhanced prediction that would have caught this.

Additionally, the method for checking if the enhanced
prediction was available was not being called in Settings.
This CL adds that check and a relevant tests to ensure it
is respected.

Test: Robotests
Bug: 38031439
Change-Id: I6924acb5552baf09a9ff0cdef8e30881115aa1ca
2017-05-08 16:39:38 -07:00
Salvador Martinez
126c032afa Add ability to speak to provider for enhanced estimate
Added code that checks if the provider for the enhanced battery
drain estimate is available. If it is available we use that
value instead of the one computed by BatteryStats.

Test: Robotests
Bug: 37753227
Change-Id: I7eae01b56f85d33eafc42ee0f18bb752779581b2
2017-05-04 20:05:53 -07:00
jackqdyulei
3dbd77e5ae Add control for the anomaly detection
Bug: 36924669
Test: RunSettingsRoboTests
Change-Id: Id71b1324f567e7aa9b51dc25247fff9151d4e108
2017-05-04 10:11:54 -07:00
jackqdyulei
4cb19e74b3 Add anomaly icon for PowerGaugePreference
When the app contains anomaly, we should show anomaly icon(triangle
alert).

This cl also extracts a new method refreshAppListGroup from refreshUi.
New method is used to only refresh appListGroup. Reason for this action:

1. Improve performance(partial refresh)
2. We init AnomalyLoader in refreshUi, invoke refreshUi in
onLoadFinish will create infinite loop.

Bug: 36924669
Test: RunSettingsRoboTests
Change-Id: If54c89349e21763ca714123ac6ae884bd0f6a377
2017-05-03 16:01:55 -07:00
jackqdyulei
106dc459e0 Move battery stats loading to AsyncLoader.
It takes 3-4 seconds to load the battery settings page in Ryu. Main
reason is that it takes too long to init BatteryStatsHelper.

This cl moves loading code to AsyncLoader, and we will refresh ui once
the loading part is finished.

Following cl will add animation for the battery header to make it not
so janky

Bug: 37196170
Test: RunSettingsRoboTest
Change-Id: I40dfdde4a072e28a56c8fdf0ec6d671b5109fc6d
2017-04-25 13:26:17 -07:00
Lei Yu
8f9f25c541 Merge "Add TtsSpan for formatted time." into oc-dev 2017-04-24 17:01:59 +00:00
jackqdyulei
f4c1cef322 Add TtsSpan for formatted time.
Talk back will read "Used for 3m" as "Used for 3 meters", but
it will read "Used for 3h 3m" correctly.

This cl add specific Ttsspan if the time only contains "minute"

Bug: 36379530
Test: Run SettingsRoboTests

Change-Id: I033575938cce24221980dddd9d66be4e18804541
2017-04-21 14:42:42 -07:00
Matthew Fritze
3266e3d712 Remove duplicates between battery and display settings
Change preference keys of duplicate settings between
display and battery to avoid duplication in search.

Bug: 33701673
Test: make RunSettingsRoboTests
Change-Id: Iaad52f16ce33c478c64bcec656cc8edbe0c97283
Merged-In: I56c82e9e7f163d345065ca478849de9b14c173fe
2017-04-20 11:11:20 -07:00
Lei Yu
c4f08120b1 Merge "Revamp battery Ui in low battery mode" into oc-dev 2017-04-13 21:43:38 +00:00
jackqdyulei
f8e6f43425 Revamp battery Ui in low battery mode
This cl refine battery icon ui in low battery mode:
1. Should show indicator(fixed in ag/2035178)
2. Show bolt icon when charging
3. When battery is low, set battery background as red and indicator
as white.

This cl also includes the field updates for battery.

Bug: 36862496
Test: RunSettingsRoboTests
Change-Id: Ifb2ed339742119bbff78712df09288b895756b1f
2017-04-12 12:47:52 -07:00
jackqdyulei
7f4c5fc1f4 Move bunch of battery methods to BatteryUtils.java
This cl moves following methods to BatteryUtils:
1. shouldHideSipper
2. removeHiddenBatterySippers
3. calculateBatteryPercent

As a result, we could use these methods in battery page as well
as app info page.

This cl also move bunch of tests to new file and add test for
method calculateBatteryPercent

Bug: 36816681
Test: RunSettingsRoboTests
Change-Id: Ic32700fe9741fbb96363db4af2d4fccb3ee8e317
2017-04-12 10:10:51 -07:00
jackqdyulei
ab5ca9f5cd Remove misc data in battery main page.
The removed types are:
1. DrainType.UNACCOUNTED
2. DrainType.OVERCOUNTED

This cl removes the above types in PowerUsageSummary and
PowerUsageAdvanced

Bug: 36874846
Test: RunSettingsRoboTests
Change-Id: I1807c44a2c0a9c2fa124cdef962a6411ae6830ca
2017-04-06 15:09:57 -07:00
jackqdyulei
273ad50a3a Ui changes in battery main page
1. Refine the battery header view
2. Move stats section to the place above power management
3. Add last full charge battery stat
4. Add the disclaimer as a footer

Also update the method name in test file, and this ui changes
also fix the header flash problem.

Bug: 36576021
Bug: 36494178
Test: RunSettingsRoboTests
Change-Id: I9784dbbbe16e61da7287f300183347dd4eee6a2b
(cherry picked from commit edfd09d590)
2017-04-04 10:06:35 -07:00
jackqdyulei
c577ef0a75 Hide Wifi and Systemui in settings main page
Also move the systemui to category system

Fix: 36644740
Fix: 36645264
Test: RunSettingsRoboTests

Change-Id: I6b64a7dca58091f3a1d8b7d99c8bae7ddf9169f9
(cherry picked from commit 1e95b74f77)
2017-03-29 20:23:50 +00:00
jackqdyulei
b0b45c3225 Add metric enums for menu in battery settings page.
Bug: 35063415
Test: RunSettingsRoboTests
Change-Id: I23f58a73f7e17da56796687209610165dd688aa6
2017-03-02 11:24:17 -08:00
jackqdyulei
44e8968662 Hide bluetooth and media in battery settings page.
Media is a bundled process which contains the following packages:

com.android.providers.downloads
com.android.mtp
com.android.providers.media
com.android.providers.downloads.ui

This cl moves them to advanced battery page.
1. Bluetooth lives in category bluetooth
2. Media lives in category system

Bug: 35811926
Test: RunSettingsRoboTests
Change-Id: Ie229fa15e2e62b67d571988f7f4e7788a665bcdd
2017-03-01 13:22:12 -08:00
jackqdyulei
238c1c000b Add batterysipper type check in PowerUsageFeatureProvider
This cl adds isTypeSystem to PowerUsageFeatureProvider and
changes isTypeService. After this cl, the following items will
be moved to advanced battery page:
1. Calendar Storage(Move to System)
2. MediaServer(Move to System)

Create this check in FeatureProvider to make sure this check
is flexible in different cases. Also refactor the PowerUsageSummary
to use same test fragment

Bug: 35629871
Bug: 35628690
Bug: 35317876
Test: RunSettingsRoboTest
Change-Id: I8c083cb2557a7e900aea01e682c13a000bacb7a9
2017-02-27 19:42:22 -08:00
Lei Yu
0497ee9731 Merge "Add NPE check for battery header update." 2017-02-27 17:56:24 +00:00
jackqdyulei
166d25abb1 Add NPE check for battery header update.
Battery header uses AsyncTask to update the label. So if user
press back button before the update completes, the "getContext()"
in AsyncTask callback will return null, which causes the crash.

It seems there is no good way to fix it expect adding a NPE check.

Bug: 35650224
Test: RunSettingsRoboTests
Change-Id: I7bd9fd87caa13614fe1896cf72557a09744691c1
2017-02-24 14:17:58 -08:00
jackqdyulei
906055e383 Add NPE check for screen and cellular update.
When battery is full of charge, usageList in BatteryStatsHelper
will be empty. As a result, we cannot find BatterySipper with
type screen and cell, which creates the null pointer error.

In this cl, I add NPE check for sipper. When sipper is null, all
data will be set to default value. I also add check for totalPower
so we won't have divided by zero error.

Bug: 35757789
Test: RunSettingsRoboTests
Change-Id: I80f3c0c542e0a50868e7c314a8d9b3c17999d8c6
2017-02-24 13:47:14 -08:00
TreeHugger Robot
82c108ab32 Merge "Remove refresh menu icon in battery settings" 2017-02-23 02:37:51 +00:00
jackqdyulei
3934722439 Add battery stats perference in battery settings page.
Add a preferenceGroup at the bottom of the page, which contains
Screen and Cell usage data.

Bug: 35305983
Test: RunSettingsRoboTests & Screenshot
Change-Id: Ida6e92ddbd7155ec974a2f04c6d6d02ab9dab210
2017-02-21 20:47:40 -08:00
jackqdyulei
9d5412f9ea Remove refresh menu icon in battery settings
Bug: 35645326
Test: RunSettingsRoboTests
Change-Id: I87f7da93cfb7a5ca46718de4acd33422fe42b9bf
2017-02-21 19:02:33 -08:00
jackqdyulei
5115265a50 Add toggle in menu to show/hide hidden apps
In the previous cl we hide unrelated apps and distribute hidden
battery usage among other apps. Now we add a toggle in menu to
show old power accounting as well.

Bug: 35366708
Test: RunSettingsRoboTests
Change-Id: I6918b7095cf84d9756ad3972ff50a62aeae1de0e
2017-02-21 16:00:20 -08:00
jackqdyulei
e2fbdfefef Refine battery text in battery header
1. When there exists estimate time, show it, otherwise
show battery status label.
2. Change the summary based on whether it is charging.
(Estimated time left vs Time to full charge)

Bug: 35328749
Test: RunSettingsRoboTests
Change-Id: I64ee8acd248062b4effcfc58ed908be7d89621a3
2017-02-17 13:57:43 -08:00
TreeHugger Robot
85de8ad126 Merge "Add BatteryMeterView in Settings" 2017-02-13 20:45:17 +00:00
jackqdyulei
51967c0e6a Add BatteryMeterView in Settings
1. Show gauge icon at the top of battery main page instead of
battery usage graph.
2. Move the click action from battery usage graph to gauge icon.

Bug: 34387464
Test: RunSettingsRoboTest

Change-Id: Ib182619d6805b401cde03a50e2ae907cf4df7b94
2017-02-13 11:03:07 -08:00
jackqdyulei
ef48c131c7 Distribute all the hidden items to apps
1. Add screen check in the shouldHideSipper()
2. remove all the battery usage for hiddenSipper from
percentage calculation, in this way we can distribute
hidden sippers to all the apps

Bug: 35153599
Test: RunSettingsRoboTests
Change-Id: I82673b282c14c92269d7f8bc71e07de90a37720c
2017-02-09 09:43:43 -08:00
jackqdyulei
3ee22131a4 Add summary for items in App Usage List in Battery page
This summary shows the active time of the app. For example
"Used for 27m".

Bug: 34467139
Test: RunSettingsRoboTests & Take screenshots
Change-Id: I0ef48427ad21be4dacd290fffb2c5d519ef58506
2017-01-27 14:15:38 -08:00
jackqdyulei
aedeb71d84 Distribute battery cost of screen to all the other apps.
It doesn't make sense to show battery cost of "SCREEN". In this cl, I
attribute this cost to all the other apps/services.

Bug: 34390125
Test: RunSettingsRoboTests
Change-Id: Ia6ff39d5fa21eacf1ff97a28e2ff59d1cf169885
2017-01-20 18:42:26 -08:00
jackqdyulei
51db61dcd5 Remove OS items in battery main page.
We want to hide the OS items from battery usage page and let users
focus on the items that they can control.

Currently the hidden items are:
Android OS, Android System, Phone idle, Cell Standby

Bug: 34274844
Test: RunSettingsRoboTests & screenshots
Change-Id: I75165376d5038b6ec17a7b73ae3c5fcd24753fa9
2017-01-19 13:49:26 -08:00
jackqdyulei
717838d3b0 Add the key extraction method in PowerUsageSummary
This cl is to fix the preference flicker issue. The main reason is
that we cannot find cached preference because of the inconsistent
search key. The search key is calculated without considering
uidObj, but the key in preference(aka changed preference) maybe
changed later based on the existence of uidObj. So when we search
the changed preference using the wrong key, we won't get it even
though it exists in the cache.

In my cl, I group two parts(search key calc + considering uidObj)
together in a method to extract the key.

Bug: 33663705
Test: make RunSettingsRoboTests
Change-Id: I2ca0c558ffc0d49ed9576321ecbc02542b568d65
2016-12-22 09:43:34 -08:00
Jaewoong Jung
6a43a06cac Implements additional battery info menu behavior.
Bug: 33352540
Test: Updated existing tests.
Change-Id: I990029d2ea9032301362d614959259965b8ecb10
2016-12-20 19:17:16 -08:00
Jaewoong Jung
1e0f8ff5e5 Adds a menu item for additional battery info to battery settings.
Bug: 33352540
Test: No additional test failures.

Change-Id: Ibfc1a9463c93d3c087ed712fe45d3d0717472c6a
2016-12-16 12:25:32 -08:00