Commit Graph

157 Commits

Author SHA1 Message Date
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
59bc0cc7e7 Add title and summary for "High usage" pref.
The logic for this pref lives in AnomalyPreferenceController.

Bug: 36924669
Test: RunSettingsRoboTest
Change-Id: Ib88d8e76e1af8a2270fcb671baf55e9f6564b96e
2017-05-03 10:48:13 -07:00
jackqdyulei
55a97a9ad4 Add abnormal app page for battery settings
1. Add abnormal app page
2. Add strings for abnormal app page
3. Change AnomalyPreferenceController to open abnormal app page,
when there are more than one anomaly.
4. Add AnomalyPreference, who stores a reference of anomaly.

Also rename AnomalyPreferenceController to
AnomalySummaryPreferenceController because this controller is not
used to handle AnomalyPreference.

Following cls will add summary and icon for each abnormal app.

Bug: 37681665
Test: RunSettingsRoboTests
Change-Id: I4266f906476ff8daccd962572c8cfa99f948080a
2017-05-02 15:59:22 -07:00
jackqdyulei
df6dd14799 Framework for the anomaly detection.
This cl adds the following components for anomaly dection:
1. AnomalyLoader: run all the anomaly checks in the background
2. Anomaly: Data class to represent what anomaly it is
3. Detector: Different kinds of anomaly detector with common interface
4. Action:  Suggestions when facing anomaly(Force stop, uninstall)
5. AnomalyDialogFragment: show the confirm dialog for action
6. AnomalyPreferenceController: handle update and click for
anomalyPreference, since it will be used in multiple fragments.
7. AnomalyUtils: utility class for anomaly

This cl also adds skeleton for the wakelock check and action. Following
cls will add real implementation about it.

Bug: 36924669
Test: RunSettingsRoboTests
Change-Id: I89fc4b6963757869b93791b4275ca53c04ab9604
2017-05-01 16:03:09 -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
jackqdyulei
6246fad7ff Make battery status refresh in SettingsActivity
Before this cl, the battery text in SettingsActivity is one time
update, won't refresh based on real battery status.

This cl elicits BatteryBroadcastReceiver from PowerUsageBase and
make it reusable in both SettingsActivity and battery page.

BatteryBroadcastReceiver will invoke callback if:
1. Battery level changed on integer level(100->99)
2. Battery status has changed(i.e. charging)

Bug: 29346753
Test: RunSettingsRoboTests

Change-Id: If522d15a700ccbc8bae24f5712e05ec27ea4cbfa
2017-04-14 15:08:57 -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
Lei Yu
27dc9b69ac Merge "Add log for BatteryUtils" into oc-dev 2017-04-10 17:06:45 +00:00
jackqdyulei
5d2918a675 Add log for BatteryUtils
This cl add logs to get more data for app usage time.

Also refactor BatteryUtils to singleton pattern because we need
to extract package name from uid.

Bug: 36909166
Test: RunSettingsRoboTests
Change-Id: I6ede354035c46e46cb856b7cf57bd1b7ccbd6d4f
2017-04-07 11:18:39 -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
Lei Yu
ae179f182f Merge "Hide Wifi and Systemui in settings main page" into oc-dev 2017-03-30 01:14:36 +00: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
f094b87661 Add summary for categories in battery advanced page
If the category only contains one app, show usage time, otherwise
show app with maximum usage.

Also add usage time for apps in battery settings page.

Bug: 35396770
Test: RunSettingsRoboTests
Change-Id: I43fe9c2289535be2c1b95ffded6b52b0ff099589
(cherry picked from commit 3bbaca9c7c)
2017-03-29 20:23:22 +00:00
jackqdyulei
ddba966700 Revamp the battery usage details page.
This cl adds AdvancedPowerUsageDetail to show the usage details page.
The AdvancedPowerUsageDetail contains all the needed ui components:
1. App Header
2. Two buttons
3. Usage breakdown preference category
4. Power management preference category

This cl also adds preference controller for two buttons but the
detail implementation will be added in the following cl.

Following cl will also remove previous detail page.

Bug: 35810915
Test: RunSettingsRoboTests
Change-Id: I17f95d1288762094671c0f148fa73367e51f175e
2017-03-24 20:58:44 -07:00
Evan Laird
3822f122a7 Add battery percentage switch to display settings
Test: mmma packages/apps/Settings/tests/robotests
Bug:32539932
Change-Id: I08c1d0f3b6cb8be7d1456268498356f7ed833e5c
2017-03-10 14:35:40 -05:00
Doris Ling
f2cf2aea37 Remove code that check for dashboard feature.
- remove DashboardFeatureProvider.isEnabled() and all relating code
and tests.

Bug: 35764802
Test: make RunSettingsRoboTests
Change-Id: If7796677abc8904b7436525836d50cdef38e37a4
2017-03-07 11:15:03 -08: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
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
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
Lei Yu
aba2c95ae0 Merge "Refine battery text in battery header" 2017-02-21 18:40:53 +00: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
Fan Zhang
c6ca314c0b Log source with visibility change
- Add a method in VisibilityLoggerMixin to log visible event using
  LogMaker, which allows logging additional FIELD_CONTEXT field.
- In Utils.startFragment, add current page's metricsCategory as an extra
  to next page.
- In next page's onResume(), extract the previous page's metricsCategory
  and send it to VisibilityLoggerMixin.visible()
- Update all caller with additional paramters

Change-Id: I8e1f2597fa465b7d3aa16fa1d21c052a3219694a
Fix: 35359289
Test: RunSettingsRoboTests
2017-02-15 17:17:19 -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
a224b010b9 Create Advanced battery page
The advanced page shows two major parts, one is the battery usage
graph and the other is battery usage list. In usage list, each item
shows basic info of battery usage of one type(e.g. Apps, System)

Bug: 34385770
Test: RunSettingsRoboTests

Change-Id: I22475a489285787afa775af8d5ae3340eff1eed9
2017-02-06 13:44:59 -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
TreeHugger Robot
a40d72b9e9 Merge "Making "Battery Saver" use MasterSwitchPreference." 2017-01-25 19:31:29 +00:00
jackqdyulei
66cce1f9e9 Making "Battery Saver" use MasterSwitchPreference.
By using MasterSwitchPreference, we make "battery saver" to have
two parts: left part is the clickable summary jumping to other
fragment while right part is a switch toggle.

Also remove the previous battery saver preference.

Bug: 34279051
Test: RunSettingsRoboTests

Change-Id: If36fa9741e413a9bbdd57fa67a2c15b6e457afd7
2017-01-24 17:34:14 -08:00
Fan Zhang
7e6df837ee Remove getCategoryKey() from DashboardFragment children.
Use the centralized registry to look up category key instead.

Bug: 32936784
Test: make RunSettingsRoboTests -j40
Change-Id: I0b8c72d70f93e4b5c58871ac90de41f69ad15653
2017-01-24 14:51:15 -08:00
TreeHugger Robot
6a03a92e42 Merge "Add power management settings into Settings->Battery" 2017-01-23 21:07:30 +00:00
jackqdyulei
722fc818c7 Add power management settings into Settings->Battery
The items been added to group are: Adaptive brightness, Sleep.
Battery saver has been moved into this group as well.

Also refactor the code a little bit to make it fit the
preferenceController. Whole refactor of PowerUsageSummary and
PowerUsageDetail will be tracked in b/34386721

Bug: 34279051
Test: runSettingsRoboTests & Screenshot
Change-Id: I702d8479d1b80f7e9cf1a46752c75bf5d189e0f6
2017-01-23 10:20:07 -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
Tamas Berghammer
265d3c2a0c Update package names to work with the proto3 compiler
Bug: b/28974522
Change-Id: I5f3adf4946ee4ba1e09e4f40afe83c151405972a
2016-11-08 14:06:17 +00:00
Fan Zhang
6507613ebc Log visibility change for all fragments.
Bug: 30681771
Test: SettingsUnitTests

Refactor visibility logging from InstrumentedFragment into a mixin. And
apply mixin in remaining fragments.

Change-Id: Ibbb59904336254a3e4bb9e8c7d0b36e5a6bc2622
2016-08-18 14:04:13 -07:00