Commit Graph

47 Commits

Author SHA1 Message Date
Lei Yu
06efc034e6 Don't check battery usage in excessive bg anomaly
We don't need it anymore because we don't auto restrict this
anomaly.

Bug: 79210436
Test: robo test still pass
Change-Id: I186213a57f9bf54a0e19985f2c92169c6dc0571c
2018-05-08 16:29:25 -07:00
Lei Yu
98eb902ead update checkbox based on FAS API
Before this CL, we assumed all the apps in this page were restricted and
didn't consider that user may uncheck one and rotate the screen.

In this CL, when we create checkbox, we will update the state through
FAS API to make sure checkbox is up-to-date.

Change-Id: I4e89908591f0688b4170806db4b6631bf921f2e9
Fixes: 78161466
Test: RunSettingsRoboTests
2018-04-18 10:58:06 -07:00
Lei Yu
7d09e2ea68 Add method to check if app has launcher activity
This method should only used for system apps.

Change-Id: Id4109d8e223933269b8dae3aaa91b8a9186c527c
Fixes: 77477987
Test: RunSettingsRoboTests
2018-04-12 10:01:42 -07:00
Lei Yu
6c4c7ba0fe Add system app check for anomaly detection.
In this CL, don't blame system app in anomaly detection and also
add log for it.

Following CL will update it to also check whether this system app
has launch entry.

Bug: 77477987
Test: RunSettingsRoboTests
Change-Id: I97490b32bc42ec2f8e03ec2d82f7c8bf89f9c66f
2018-04-11 18:02:50 -07:00
Lei Yu
c5f5b18b22 Add NullPtrCheck when smearing in settings
This only happens in new device with broken power_profile.xml, in
which it doesn't have screen power model.

This CL catches the null pointer crash and log it.

Change-Id: Iac23e3a8fc51385bdb22979c4b59000319f6fd49
Fixes: 74617269
Test: RunSettingsRoboTests
2018-04-06 15:57:44 -07:00
hughchen
18ce28ed33 Change BatteryUtils.isLegacyApp() to isPreOApp()
Bug: 73792442
Test: RunSettingsRoboTests
      make -j40 RunSettingsRoboTests
Change-Id: I770030a8f38ec6156aa2a40f4c88ac9e0673751d
2018-03-20 01:44:43 +00:00
James Lemieux
22a39c2b93 Use external/robolectric-shadows/run_robotests.mk
This allows Settings to test against the latest framework changes.

Also replaced TestConfig with traditional robolectric.properties.

Bug: 73173204
Bug: 73892008
Test: make -j56 RunSettingsRoboTests
Change-Id: I3135b4fa5f095ba79b282a76f45dd9baa2584bc7
2018-03-04 03:50:08 -08:00
jackqdyulei
457fb842eb Add special check for excessive bg anomaly
To check whether this app has battery usage more than x%

Bug: 72385333
Test: RunSettingsRoboTests
Change-Id: I87e6b01c866a053658f84ce3486120ae82963fd9
2018-02-23 10:12:05 -08:00
jackqdyulei
99a2de41ef Add restrict and unrestrict dialog
Add a fake unrestrict tip so we could reuse the BatteryTipDialogFragment
to build the unrestrict dialog.

After this cl, restrict dialog has two types:
1. dialog to only restrict one app
2. dialog to restrict more than one app

Will add dialog to restrict more than 5 apps when strings are finalized.

Bug: 72385333
Bug: 72227981
Test: RunSettingsRoboTests
Change-Id: Ib0328f0386efad525b331fd713dd15d060a1a649
2018-02-05 19:37:03 -08:00
jackqdyulei
0fb2d68f97 Add restrict app detail page
1. Move force standby action to BatteryUtils
2. Add click action for restricted preference(go to detail page)
3. Build app list in detail page using packageOps list

Bug: 71502850
Test: RunSettingsRoboTests
Change-Id: I1e6733e5402e7a854b07a8bbb43a86255276bfaa
2018-01-19 09:59:53 -08:00
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
jeffreyhuang
cbfb099a40 Rename SDK_VERSION_O to SDK_VERSION
Test: make RunSettingsRoboTests -j40
Change-Id: I6715062d8addadda441e32809db1af55f15e3a90
2017-12-05 16:43:54 -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
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
jackqdyulei
bfc2b11b93 Update Anomaly detection framework
This cl make it could have multiple actions for each anomaly type.

This includes:
1. Add field "targetSdkVersion", "bgRestrictionEnabled" in Anomaly
2. Add new action which includes "force stop" and "background check"
3. Add "sdkVersion" and "bgRestrictionEnabled" method in BatteryUtils
4. Update BackgroundCheckAction to check sdkVersion first
5. Update serveral tests and add new test

Bug: 63037765
Test: RunSettingsRoboTests
Change-Id: Iea7a131ee57d501f7737ae4a3ba672d948d05cd8
2017-07-06 15:53:28 -07:00
TreeHugger Robot
55ad60d1ff Merge "Add util method to get battery stats" into oc-dr1-dev 2017-07-06 21:58:33 +00:00
Matthew Fritze
bfe82cab89 Add util method to get battery stats
Bug:62271803
Test: make RunSettingsRoboTests
Change-Id: I91089c24c7cd5f7329be052c50859e049e70e9b1
2017-07-05 14:54:20 -07:00
jackqdyulei
43cbee6914 Update the method about foreground time.
For now it uses MIN(STATE_TOP_TIME, FOREGROUND_ACTIVITY_TIME) and this
method is used in both display and screen smearing.

Bug: 63080621
Test: RunSettingsRoboTests
Change-Id: I2ca3109697aa66fae67d8b2f4f10c4d08bb99d59
2017-06-30 16:18:29 -07:00
TreeHugger Robot
33c9b7a111 Merge "Fix the getForegroundActivityTotalTimeMs" into oc-dr1-dev 2017-06-29 00:43:09 +00:00
TreeHugger Robot
9a30ceab83 Merge "Hide the IDLE in "app list"" into oc-dr1-dev 2017-06-28 19:38:20 +00:00
jackqdyulei
85e25e34fd Fix the getForegroundActivityTotalTimeMs
The parameter in timer should be microseconds, not milliseconds

Bug: 63073847
Test: RunSettingsRoboTests
Change-Id: I5e451aee9eb30815fbefe12c0bfdc85dff884b8e
2017-06-28 12:33:20 -07:00
jackqdyulei
10fa63e62c Hide the IDLE in "app list"
Also don't smear it.

Bug: 62423075
Test: RunSettingsRoboTests
Change-Id: I74072f9dde0dcf7b9a4abb05b86fe2102b618d6a
2017-06-27 17:31:09 -07:00
jackqdyulei
118e2baabe Fix the getForegroundActivityTotalTimeMs
It should return milliseconds, not microseconds time

Bug: 63073847
Test: RunSettingsRoboTests
Change-Id: Ib7ddb947646062fc50a40d300829389e0ac401ee
2017-06-27 16:49:14 -07:00
jackqdyulei
3d93fc16f4 Change the method to get foreground time.
This cl changes it to:
foregroundTime = MIN(topTime, foregroundActivityTime);

Bug: 62884954
Test: RunSettingsRoboTests
Change-Id: I236c18b19c4f06c5a6d018bc06ffb9862af51de2
2017-06-23 11:02:54 -07:00
jackqdyulei
9d0d6e4fcc Merge "Hide wifi and bt in battery settings" into oc-dev
am: 05777a7918

Change-Id: If676ec0119bebed800727f618225fd355e9da74f
2017-06-20 22:55:47 +00:00
jackqdyulei
d10608dfbb Hide wifi and bt in battery settings
Hide them in app usage list but don't smear them

Bug: 62787787
Test: RunSettingsRoboTests
Change-Id: I43c15ea8a2b32f293eb859f3fead8666e45674ef
2017-06-20 13:44:52 -07:00
jackqdyulei
72c3275a66 Refine Anomaly detail page
1. Fix the layout issue(title not vertical horizontal)
2. Add subtitle for anomaly

Bug: 36924669
Test: RunSettingsRoboTests
Change-Id: I9b3627f09bbe37b104644d203ff8924f0faaea47
2017-06-20 11:37:55 -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
jackqdyulei
de3bb7194d Add method to calculate last full charge time
Bug: 38481300
Test: RunSettingsRoboTests
Change-Id: Icd551921f263352eb01d0c6ada62d277c8699507
2017-05-30 15:51:29 -07:00
jackqdyulei
03539a07e4 Add method to calculate last full charge time
Bug: 38481300
Test: RunSettingsRoboTests
Change-Id: Icd551921f263352eb01d0c6ada62d277c8699507
2017-05-26 13:21:42 -07:00
jackqdyulei
f984b1e1ae Sort app list after smeared on screen
Then we could make sure the app list is sorted

Bug: 62035385
Test: RunSettingsRoboTests
Change-Id: I3fa3d6ffc5930cf011e382632143e459fdbc4369
Merged-In: I3fa3d6ffc5930cf011e382632143e459fdbc4369
2017-05-25 10:09:05 -07:00
jackqdyulei
7932484fa9 Sort app list after smeared on screen
Then we could make sure the app list is sorted

Bug: 62035385
Test: RunSettingsRoboTests
Change-Id: I3fa3d6ffc5930cf011e382632143e459fdbc4369
2017-05-23 17:36:47 -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
TreeHugger Robot
21d2403c67 Merge "Show wifi and bluetooth item in battery settings" into oc-dev 2017-05-18 19:13:35 +00:00
jackqdyulei
7d7080ab64 Drop the misc and not smear it.
Bug: 38347725
Test: RunSettingsRoboTests
Change-Id: I573e4fb945bc212505c9211d9b92f77a6a9a2739
2017-05-17 18:12:03 -07: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
6c9dc0b1ca Show wifi and bluetooth item in battery settings
Change-Id: Icc1824758908b14ad895dcc28a63a5d9c685b490
Fix: 38328856
Fix: 38328641
Test: RunSettingsRoboTests
2017-05-17 10:29:55 -07:00
TreeHugger Robot
651261c7dd Merge "Only use PROCESS_STATE_TOP as foreground time." into oc-dev 2017-05-05 18:55:29 +00:00
jackqdyulei
01e690e377 Only use PROCESS_STATE_TOP as foreground time.
There are some miscalculations in state FOREGROUND_SERVICE and
FOREGROUND, so we move them out of the foreground time for now.

We will fix it after O and may add them back later.

Bug: 37000096
Test: RunSettingsRoboTests
Change-Id: Ic3f2f7fa69e8a213895c601630d1cca94fd32220
2017-05-05 10:23:09 -07:00
jackqdyulei
a245188a65 Distribute the misc among all the apps
Distribute it in:
1. Battery main page(PowerUsageSummary)
2. Advanced battery page(PowerUsageAdvanced)

Bug: 37487061
Test: RunSettingsRoboTests
Change-Id: Id1810b81a6b380d908bcdc18421530e938578c37
2017-04-25 11:48:24 -07:00
TreeHugger Robot
e5fa4cd4b5 Merge "Remove STATE_TOP_SLEEPING from foreground time" into oc-dev 2017-04-25 18:36:01 +00:00
jackqdyulei
7c6e6e9254 Remove STATE_TOP_SLEEPING from foreground time
That state means the time when app is on top while screen is off,
we should not count it as foreground usage time.

Bug: 37547898
Test: RunSettingsRoboTests
Change-Id: I67e0c135d0c4b71cd667037b0d5dc7673b53607e
2017-04-24 11:37:00 -07: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
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
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
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