Commit Graph

88 Commits

Author SHA1 Message Date
jackqdyulei
ca102facf0 Add high usage battery tip
1. Add both model and detector
2. Move the screen usage method to BatteryUtils
so we could reuse it.
3. Add and update the tests

Bug: 70570352
Test: RunSettingsRoboTests

Change-Id: I6a7248d9d48ee8cb6fc2c18c8c225210d49b6bc9
2018-01-09 15:00:41 -08:00
jackqdyulei
fde63fc351 Add infra for battery tip
This cl adds the basic structure for battery tip:
1. BaseBatteryTip: Model class to represent the tip and build
preference and dialog
2. SummaryTip: Display a general battery summary(i.e. your battery
is good..)
3. BatteryTipLoader: AsyncLoader to load the battery tips.
4. BatteryTipPreferenceController: preference controller for
preference group to display battery tips

This cl also:
1. Remove the anomaly code in PowerUsageSummary and we will add it
to app restriction in future.
2. Add preference_category_no_title.xml to avoid the extra 32dp
blank at the top.

Bug: 70570352
Test: RunSettingsRoboTests
Change-Id: If91a553888e2eb91d55fb1d0d7bbea69652f144c
2017-12-19 13:27:33 -08:00
jackqdyulei
8f73968308 Add feature flag to control battery app list.
If feature flag is on, then display the app list. Otherwise disable
it.

Bug: 70234293
Test: RunSettingsRoboTests
Change-Id: I1663f925abf95e0e4c1a46d98ca165303a76e979
2017-12-08 13:02:13 -08:00
jackqdyulei
1240549591 Move AppListGroup to PreferenceController
Move the app list in battery settings to PreferenceController. So that
we can:
1. Clean the code in PowerUsageSummary
2. Make it easy to add/move the app list to other place in furture.

This cl:
1. Move and make it invisible since in P we don't show app list in
battery main page.
2. Move related test to BatteryAppListPreferenceControllerTest

Bug: 70234293
Test: RunSettingsRoboTests
Change-Id: Ice7a42394916ff5e71305bfe22f5c35868d87fc7
2017-12-08 10:21:54 -08:00
jackqdyulei
166102c3c0 Add feature flag for battery settings page.
Create PowerUsageSummaryLegacy and power_usage_summary_legacy, which
contains the old implementaion.

Bug: 69797586
Test: RunSettingsRoboTests
Change-Id: Icb9c25f06889462a6eedea48ae166043a6636848
2017-12-05 13:15:13 -08:00
Fan Zhang
dff6dd687e Move away from deprecated FakeFeatureFactory.setupForTest()
Test: rerun
Change-Id: I896ba414315ddb1664c0499264f4992f0554ef98
2017-12-05 10:12:10 -08:00
jeffreyhuang
a79417487c Move fuelgauge test package to sdk 26
Test: make RunSettingsRoboTests -j40
Change-Id: I8122a41132821a42c4ec8c5995a1a11833b686cd
2017-11-29 10:57:54 -08:00
Maurice Lam
e18902ec67 Update Robolectric to 3.4.2
Bug: 66693279
Test: m RunSettingsRoboTests
      m RunSettingsRoboTests-jacoco
Change-Id: I9df619c3d68f0af2ee2ae944a15998275129f7c2
2017-09-22 18:34:00 +00:00
Salvador Martinez
42f7dcc0fb remove old anomaly code
This is dead code that should no longer be around. Note: we can't
remove the metrics constant from the proto because then someone
might try reusing it.

Test: Robotests Pass
Bug: 65599785
Change-Id: Idda679eeca739e34c2371b7aafec23a3339b7f1a
2017-09-13 20:43:20 +00:00
Roozbeh Pournader
4de9df2943 Define Utils.formatRelativeTime() and use it
Previously, relative times were formatted using formatElapsedTime()
(appending translations of "ago" to them), sometimes resulting in
grammatically hard-to-understand or unnatural localizations. Now we
use ICU's RelativeDateTimeFormatter, which uses grammatically correct
and natural localizations from CLDR data.

Bug: 64507689
Bug: 64605781
Bug: 64556849
Bug: 64550172
Test: make -j RunSettingsRoboTests
Change-Id: Ia2d098b190ab99e7748ef6f03b919f5c6174ba7d
2017-09-12 20:48:00 +00:00
jackqdyulei
44dc63ec7b Add userId to key when type is USER
Before this cl, the app list couldn't distinguish different users
because all of them have the same key: USER.

This cl adds userId into key, to make sure the preference key
is unique.

Bug: 64605854
Test: RunSettingsRoboTests
Change-Id: Ia4de2ff85b214465a35f1983ca69a9280d053154
2017-08-14 18:36:31 +00:00
Fan Zhang
e3535d9998 Delete DynamicindexableContentMonitor & all refs to it
Convert input device search into a search query loader

And remove old logic from DynamicIndexableContentMonitor

Change-Id: If652b1ea7c8add9185bbd025055e14925d3a8eec
Bug: 64310452
Bug: 63831980
Test: robotests
2017-08-09 17:27:02 -07:00
jackqdyulei
8541d8905a Merge "Don't update the header when toggle menu" into oc-dr1-dev
am: 4ab4966e7a

Change-Id: I3a814981c648d9b777d2fbf5a2d243864aaaee3c
2017-07-27 18:21:16 +00:00
jackqdyulei
bc86e4747f Don't update the header when toggle menu
If we only toggle the app type in battery settings, don't update
the header. Then it won't have flicker in battery header.

Bug: 64065456
Test: RunSettingsRoboTest
Change-Id: If1cfa745f723f808ad9c5fd921be797acd3199ba
2017-07-26 15:28:59 -07:00
Michael Wachenschwanz
a47a3f58bf Merge "Add Foreground Service time to battery usage" into oc-mr1-dev 2017-07-24 19:02:12 +00:00
Michael Wachenschwanz
987711712c Add Foreground Service time to battery usage
Add foreground service time to foreground usage time of apps. This will
account for app usage that user is aware of but is not being displayed
on screen, such as playing music while screen is locked.

Change-Id: Ica9fe0819e46b50299eb2eab7f0483ea01441fb0
Fixes: 38313557
Test: RunSettingsRoboTests
2017-07-21 17:37:00 -07:00
Lei Yu
ab7a4db9df Merge "Make anomaly item refresh in battery" into oc-dr1-dev
am: 0ec3e4e626

Change-Id: Ie3e4b7ead145b22c44383443229043722b9e86d9
2017-07-22 00:32:21 +00:00
jackqdyulei
88b27fdeac Make anomaly item refresh in battery
Bug: 63908155
Test: RunSettingsRoboTest
Change-Id: I3e220001ca989020447403641360fade4d09e969
2017-07-21 10:37:14 -07:00
Alex Kulesza
2f0e60ccda Make time remaining estimate debug mode more reliable.
Previously, the long click handler was unregistered on first use and
never re-registered. This meant that, e.g., on plugging and unplugging
the phone, debug mode stopped working. This change moves long click
activation into restartBatteryInfoLoader().

Bug: 63133793
Test: make RunSettingsRoboTests
Merged-In: I4c25a1f05ab3718bf06faf455cf670b5460a7306
Change-Id: I4c25a1f05ab3718bf06faf455cf670b5460a7306
2017-07-19 01:04:08 +00:00
Alex Kulesza
120e7a71c6 Make time remaining estimate debug mode more reliable.
Previously, the long click handler was unregistered on first use and
never re-registered. This meant that, e.g., on plugging and unplugging
the phone, debug mode stopped working. This change moves long click
activation into restartBatteryInfoLoader().

Bug: 63133793
Test: make RunSettingsRoboTests
Change-Id: I4c25a1f05ab3718bf06faf455cf670b5460a7306
2017-07-18 14:58:51 -04:00
jackqdyulei
d2d524d958 Merge "Update summary for "Voice Calls"" into oc-dr1-dev am: 69d6f2840f
am: d8b92b4d82

Change-Id: Ic8a6bc7312c1a464104867e87daecf72bdcffaa9
2017-07-07 23:59:46 +00:00
jackqdyulei
85e771da78 Update summary for "Voice Calls"
Change it from "Screen usage 2m" to "2m", since this is not a screen
usage. This cl has effect on all non-app batterySipper.

Bug: 63443732
Test: RunSettingsRoboTests
Change-Id: I027b3234bd7b56738ab31c5dfbc0d8bd7f19186e
2017-07-07 14:52:27 -07:00
jackqdyulei
8ce27bc37c resolve merge conflicts of 758b2d4ae6 to master
Test: I solemnly swear I tested this conflict resolution.
Change-Id: Ic82e244ad1485bdd1f73cff628e0e343bfdb1c53
2017-06-26 18:30:40 -07:00
TreeHugger Robot
da45ba8c9e Merge "Hide misc in battery settings" into oc-dr1-dev 2017-06-26 19:52:55 +00:00
Tony Mantler
1d583e125f Make PreferenceController a mixin
Bug: 62912136
Test: Existing tests in BaseSearchIndexProviderTest
Change-Id: Ieda359806c09a019840b2005446c7ec8b61fdb00
2017-06-26 10:58:36 -07:00
jackqdyulei
d856294bf1 Hide misc in battery settings
Hide it in any condition:
1. both in app usage list and device usage list
2. in all targets(i.e. user, userdebug..)

Bug: 62422405
Test: RunSettingsRoboTests
Change-Id: I36bd043942ce7e2353163868bf6d86f422f8e7ee
2017-06-26 10:36:05 -07:00
Andrew Sapperstein
466a3f6faa Remove PowerUsageFeatureProvider.isAnomalyDetectionEnabled
Instead, this decision is being handled via AnomalyDetectionPolicy.

Change-Id: I5b1831c78e31e3be984dda07bcea9f0b0a25d52f
Fixes: 62871629
Test: robotests
2017-06-23 14:32:22 -07:00
jackqdyulei
27792b2356 Only update anomaly icon in AnomalyLoader
Before this cl, it will re-calculate battery percentage once we get
anomaly data, which will add screen usage data twice. This cl make it
only update anomaly icon after the anomaly detection is done.

Bug: 62803379
Test: RunSettingsRoboTests
Change-Id: I2089646679e299fa948b1f3ed21f4a13a1317aa3
2017-06-20 13:53:46 -07:00
Andrew Sapperstein
9f1e911759 Refactor test runner to use static list of resource paths
Previously everything lived in an inner class method of
SettingsRobolectricTestRunner. That method has now been turned into
a static method so that it can be called by other runners.

Bug: 62460102
Test: robotests
Change-Id: I6612b1f26404587301c534c8ba60e39d59d6c840
2017-06-09 09:21:26 -07:00
TreeHugger Robot
4c4e780577 Merge "Make flag "showAllapps" persistent in PowerUsageSummary" into oc-dr1-dev 2017-06-09 04:39:41 +00:00
jackqdyulei
6525053801 Merge "Update subtitle for apps in battery settings" into oc-dev
am: 031b90541f

Change-Id: Ia0581b295824b73ef36f931066b883cff51fc0e9
2017-06-09 02:57:46 +00:00
jackqdyulei
f9a5c39c4c Make flag "showAllapps" persistent in PowerUsageSummary
This flag is used to decide whether to show all the apps
(including system app, service..) in battery settings

Handle it in onCreate() and onSaveInstanceState()

Bug: 62422948
Test: RunSettingsRoboTests
Change-Id: I30c0d6e1e25902f1192fc2564aa09d635b5e0f4f
2017-06-08 19:20:05 -07:00
jackqdyulei
dcea4e894e Update subtitle for apps in battery settings
1. If it is a normal app, show "Screen usage TIME"
2. If it is a hidden app, show "TIME"

Note that in this case the item screen will show "TIME"

Bug: 62422404
Test: RunSettingsRoboTests
Change-Id: Ie8d6caf998d18994ac158f0217109c0e5e9f92ba
2017-06-08 12:52:48 -07:00
Salvador Martinez
f4727ea07f Add ability to see both battery estimates on long press
If the enhanced estimate is being used in battery settings
it is now possible to long press on the text to have it display
both instead of the string that is normally used.

Adds another loader to enable this since it needs both the old
and the new estimates simultaneously.

Feature is hidden behind a feature flag that only googlers will
have enabled.

Test: robotests
Bug: 38399275
Change-Id: I5caf26513baada27efd50ddb0e72d3868da47150
2017-06-05 16:26:32 -07:00
Salvador Martinez
9cfa7720f4 Make BatterySettings Asynchronous and use enhanced estimate
this CL changes BatteryInfo methods to all use the async style
callback approach it had for one of the methods. Non-async methods
are now annotated to only be used in worker threads. BatteryInfo
can now be obtained via callback by calling one of the async
methods. Alternatively if there is a worker thread available
the synchronous methods similar to the old ones can be used.

The callback methods have all been changed so that they cascade to a
async method that takes all the required info as paremeters. This
will minimize the amount of churn in files that currently use
BatteryInfo.

A new loader was created that can be used to get BatteryInfo in
places that wish to get it. This loader is used in
PowerUsageSummary to get the BatteryInfo.

Test: Robotests
Bug: 38399275
Bug: 38398949
Bug: 38399654
Change-Id: Ic5a82d8ca4c85fad1b883226327ec083badf861d
2017-06-01 18:03:53 -07:00
Salvador Martinez
0e8c88376c Move BatteryInfo to settings from settingslib
This CL simply moves BatteryInfo from settingslib to settings and
makes sure the tests still pass. No other changes are made other than
imports or minor changes needed to make sure existing code does not
break.

Test: Robotests still pass
Bug: 38399275
Bug: 38398949
Bug: 38399654
Change-Id: I59803348e2780b7676ccc6c43234a586c184d71f
2017-06-01 11:34:08 -07:00
jackqdyulei
4a7c8d7125 Split loading process for battery header
This cl creates BatteryHeaderPreferenceController, which will first
load the battery level in ui thread(in displayPreference()), then
display the remaining time once we get the battery stats.

This is the best we can do to avoid ui flashing while removing the
animation

Bug: 38349587
Test: RunSettingsRoboTests

Merged-In: Ic3622bb73562ba42e69b37e5674a724c03c45f12
Change-Id: Ic3622bb73562ba42e69b37e5674a724c03c45f12
2017-05-23 16:21:33 -07:00
jackqdyulei
605dbc66be Split loading process for battery header
This cl creates BatteryHeaderPreferenceController, which will first
load the battery level in ui thread(in displayPreference()), then
display the remaining time once we get the battery stats.

This is the best we can do to avoid ui flashing while removing the
animation

Bug: 38349587
Test: RunSettingsRoboTests

Change-Id: Ic3622bb73562ba42e69b37e5674a724c03c45f12
2017-05-23 13:22:42 -07:00
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
TreeHugger Robot
161571617b Merge "Revert "Add animation for battery asyncLoader."" into oc-dev 2017-05-23 01:49:23 +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
78684dc049 Revert "Add animation for battery asyncLoader."
This reverts commit a3c528f64d.

Test: Build
Change-Id: Ib50221873e39dee40c5cf8e4b41dcf7aa13f6134
Merged-In: Ib50221873e39dee40c5cf8e4b41dcf7aa13f6134
2017-05-22 16:49:55 -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