Commit Graph

119 Commits

Author SHA1 Message Date
ykhung
ef66549e64 Add a mechanism to log battery usage periodic job events
Example history log:
      	Jul 07, 2023, 15:28:51 SCHEDULE_JOB triggerTime=Jul 07, 2023, 16:00:00
      	Jul 07, 2023, 15:32:16 FETCH_USAGE_DATA
      	Jul 07, 2023, 15:32:17 INSERT_USAGE_DATA size=37
      	Jul 07, 2023, 15:43:45 FETCH_USAGE_DATA
      	Jul 07, 2023, 15:43:48 INSERT_USAGE_DATA size=47
      	Jul 07, 2023, 15:43:49 SCHEDULE_JOB triggerTime=Jul 07, 2023, 16:00:00

Bug: 284893240
Test: make test RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.fuelgauge
Change-Id: I45a1ce0ce9b70f095702727e53d7b7ce8824abdb
2023-07-07 17:47:19 +08:00
ykhung
5cd3a7298e Disable the optimization mode preference if the app is not settable
https://screenshot.googleplex.com/BbQyEv6YCjPVwUF (allowlist)
https://screenshot.googleplex.com/3hTb8TQwGMQqcwS
https://screenshot.googleplex.com/6hdTAT2yNFucD9N (system app)
https://screenshot.googleplex.com/77T5JyAD5nZJpDT (normal app)

Fix: 281566984
Test: make test RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.fuelgauge.*
Change-Id: If7aa4b61bc806daa570187da24b7f454cd069dec
2023-05-15 09:32:09 +00:00
Wesley Wang
1f78ebd8aa Refine optimize page log pattern
- Add timestamp and prefix string
 - Chagne Action.MANUAL to LEAVE for better readability
 screenshot: https://screenshot.googleplex.com/ALTvMaPWVEq8y7c.png

Bug: 192523697
Test: make SettingsRoboTests
Change-Id: I69d1beceb98444d823f6ffc3a015cf61a7d7a66d
2023-05-10 10:11:28 +00:00
Zaiyue Xue
65cfcbe486 Only log the names of the app packages which are installed from Google Play Store in battery usage app optimization page
This is to meet the Guidelines for Logging Package Names: go/package-name-logging-guidance

Bug: 267430574
Fix: 267430574
Test: presubmit
Change-Id: Icf10000f5dcf87e45175d4005af8365191ad444d
2023-02-02 16:51:13 +08:00
Kuan Wang
96aee4896b Not show time information in battery optimization page when opened from
Settings -> Apps

Test: make RunSettingsRoboTests + manual
Bug: 265130434
Change-Id: Ie7ae6a97041f490e81adbe8e0c530799e09a7c66
2023-01-16 12:07:07 +08:00
Zaiyue Xue
0639abfcca [Battery usage U] [UI] Show screen time in the battery detail usage page
screen record: https://drive.google.com/file/d/1TUbcysrVoj10iUhoMIT0wuCDJY8EMpy7/view?resourcekey=0-lS9d0aIQqrgJ7CpOlsOlYw

Bug: 258125117
Fix: 258125117
Test: manual
Change-Id: I31fbc7c45473ded254ebf1b1e82e09dbc88480cf
2023-01-12 15:45:51 +08:00
Zaiyue Xue
a500e4f739 Clean up always false parameter isValidToShowSummary.
So the next cl (new summary for battery detail page) doesn't need to
deal with isValidToShowSummary=true case.

Bug: 262802531
Test: presubmit
Change-Id: I88528caedb29d61a05b40d3ca435fc007bf3f54c
2023-01-11 21:03:42 +08:00
Zaiyue Xue
cad4c069bd Clean up unused code in AdvancedPowerUsageDetail class
Bug: 262802531
Test: presubmit
Change-Id: Ide91bd5312296945effb5a54422bda2c9623341d
2023-01-11 14:27:53 +08:00
Wesley Wang
7423f4390c Move setup optimization mode to main thread
- Due to unclear root cause of optimization mode being reset after
   reboot, update the setup logic from deferred background thread to
   main thread, to avoid any possible background task unexecuted case.

Bug: 241735485
Test: make SettingsRoboTests
Change-Id: I2de2181321712f89fadc04bf5000aea91a01485a
2022-12-13 11:12:00 +00:00
Wesley Wang
5664ebc351 Merge "Add BatteryHistoricalLogUtil class" 2022-11-07 03:08:17 +00:00
Wesley Wang
d90026d184 Add BatteryHistoricalLogUtil class
- Impl optimize mode log mechanism to record optimize setup flow
 - Log optimize action with MANUAL, APPLY, RESET and RESTORE
 - Use proto file to serialize logs
 sample result: https://screenshot.googleplex.com/5KPrHVGb4pMvS7V.png

Bug: 241735485
Test: make SettingsRoboTests
Change-Id: I879663de4cf45d0cfb9cd7eee957eeb65addfbe1
2022-11-04 18:09:11 +08:00
Wesley Wang
eda172ce2c Fix app battery usage list launch incorrect works app
- App usage page only use package name to launch the page, it can not
   identify the different userId between normal app and work profile
   app, add extra userId info into launch args
 - Remove no battery usage state/string if usage time is empty

Bug: 251471047
Test: make SettingsRoboTests
Change-Id: Id06ebb0f0fcd863e423acd7839f89bc0ae2444c1
2022-11-03 11:32:30 +00:00
Kuan Wang
628f12c1ad Remove isChartGraphEnabled() which should always return true after
migration.

Bug: 253395332
Test: make RunSettingsRoboTests + manually
Change-Id: I0c4a6e00a7a9fd66d4050e5ddcf87176462067cd
2022-11-01 07:58:57 +00:00
Chaohui Wang
dbead03b6a Add AppBatteryPreference for Spa
This is used in new App Info page.

To try:
1. adb shell am start -n com.android.settings/.spa.SpaActivity
2. Go to Apps -> All apps -> [One App] -> App battery usage

Bug: 236346018
Test: Unit test & Manual with Settings App
Change-Id: I4784e42f230534d8d843ec00de51032baffcb7e2
2022-10-28 11:18:21 +08:00
Kuan Wang
c7afa45eac Clean up unused function getHideApplicationSummary in
PowerUsageFeatureProvider.

Bug: 253395332
Bug: 254769892
Bug: 254769770
Test: make RunSettingsRoboTests
Change-Id: I6acf0cbdb7321934e85939e0acee567001107a17
2022-10-21 04:42:06 +00:00
Zaiyue Xue
693711469d Updates battery usage messages from last 24hr to last full charge. (Part2: non-V2 files)
Test: manual
Bug: 236101166
Change-Id: Id5ad3e859a01d3288a950bf6288eafc6144a23d6
2022-08-05 10:52:38 +08:00
Tiffany Nguyen
5ecb1a1d69 Add Apps > Battery optimization page implementation.
Moving the old restricted page to the new optimization page will happen
in a follow-up CL.

Test: Unit, manual
Bug: 238026672
Change-Id: I5fee9ebe03284a013da6bfca9ada8b166c6af91c
2022-08-02 18:43:53 +00:00
Zaiyue Xue
7e6aa69cca Merge "Move battery usage files to a separate folder." into tm-qpr-dev am: 3b7953eac2 am: 6470ada117
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/18797446

Change-Id: I3d6a155e80a5d54c309061c41d0b6436e61cc4cb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-20 09:42:01 +00:00
xuezaiyue
ac7318419a Move battery usage files to a separate folder.
Bug: 202118250
Test: presubmit
Change-Id: I21aa58ebc02327849ed2161dbbafcdc806c007f2
2022-06-19 05:59:35 +00:00
Kuan Wang
02b6451258 Clean up legacy "optimization mode" design.
We have two different "Optimization mode" page design in the android R to support bi-state for AOSP and tri-state for Pixel device. From android T, we always show tri-state for both AOSP and Pixel. So it's time to clean up the legacy design for bi-state.
This change doesn't include string resources cleanup, which will be
included in a separated cl.

Bug: 232037602
Test: make RunSettingsRoboTests
Change-Id: I5194201d0b11e2dcea958d49bf07ed837a386465
2022-06-06 02:11:09 +00:00
Edgar Wang
68d12953e7 Update learn more string of FooterPrefernce
Replace FooterPreference#SetLearnMoreContentDescription() with
FooterPreference#SetLearnMoreText().

This is a requirement: All links, controls, and buttons should
also have comprehensible text or tooltip text, so users can identify its
purpose, independent of context, such as when using the URL list from
TalkBack’s local context menu.

Bug: 215045903
Test: manual & robotest
Change-Id: Ib657ba336c5688c1434a58611dea3891001afe14
2022-05-13 08:13:36 +00:00
ykhung
7015cd0dd9 Hide running time for "Android System" in the optimization page
Hide the running time information for "Android System" entry, since this
entry will combine multiple system components together. It will provide
incorrect running time information. The getRealUid() method maps many
UIDs to Process.SYSTEM_UID(1000), which results in combining all of
those UIDs into one "Android System" entry. This is the expected behavior.

Bug: 220717612
Test: make RunSettingsRoboTests -j56 ROBOTEST_FILTER="com.android.settings.fuelgauge"
Change-Id: I9d44fe8490ad5c684419b8ebf8d7d5576a42788a
2022-05-10 18:47:44 +08:00
ykhung
b593e00af0 Format BatteryEntry and BatteryDiffEntry class
Bug: N/A
Test: make RunSettingsRoboTests
Change-Id: I14e2ef4c455209e58edc5ccdbe064f469815cccd
2022-04-17 06:23:47 +00:00
YUKAI HUNG
a7412b33b2 Merge "Fix incorrect usage for the logging method to cause no data in WW" into sc-v2-dev am: 6e12a31e5f am: a1d72c11c5
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16221114

Change-Id: I4c9d5265d8abd4a73a19df2afc5c718d8827ddab
2021-11-10 10:10:05 +00:00
ykhung
101dc6878a Fix incorrect usage for the logging method to cause no data in WW
Fix incorrect usage for the logging method to cause the schedule type
and percentage data is not logged  into the WW, since
MetricsFeatureProvider doesn't support log Pair.of() data into the
WestWorld or Clearcut directly, it is used for EventLogWriter only

Bug: 202906853
Test: make SettingsRoboTests
Change-Id: I9f1d157c77df9bd74f441105318790a2505a9c01
2021-11-10 15:39:30 +08:00
Wesley Wang
0f3a672a94 Merge "Move optimization mode backup timing into onPause" into sc-v2-dev am: bf9f91f0ad am: e67f12f9b7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16177444

Change-Id: I1f9c5dd515fa42c7a30f86f9c7b135b39ff67cc5
2021-11-03 07:06:04 +00:00
Wesley Wang
bf9f91f0ad Merge "Move optimization mode backup timing into onPause" into sc-v2-dev 2021-11-03 06:41:42 +00:00
TreeHugger Robot
6d2db7a8cf Merge "Adjust optimize page logging timing" into sc-v2-dev am: b4e13a7af0 am: 3be2b733f2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16170324

Change-Id: I66ecbb8213e9fb6301d75cacb493813180df1e18
2021-11-03 05:41:03 +00:00
TreeHugger Robot
b4e13a7af0 Merge "Adjust optimize page logging timing" into sc-v2-dev 2021-11-03 05:17:40 +00:00
Wesley.CW Wang
9b6eac28f3 Move optimization mode backup timing into onPause
- Move to onPause to avoid some corner case (like kill apps from recent
 app won't trigger onDestroy)

Bug: 195306545
Test: make SettingsRoboTests
Change-Id: I89445a7138c30e6c869ce1c5c9a3f818997d99a7
2021-11-03 12:38:10 +08:00
Wesley.CW Wang
7fb4cbf005 Adjust optimize page logging timing
- Log the optimize mode only when leave this page and mode changed
 - Update mOptimizationMode at onResume to make sure the state is sync
 with framework

Bug: 195306545
Test: make SettingsRoboTests
Change-Id: Iab116220cd7d2b1bdb1c170c4b47016c763bf4fe
2021-11-03 12:05:15 +08:00
ykhung
e7d4fefde0 Fix NPE issue of usage detailed page learn more button click event am: 8f0291cd1a am: b85bf67314
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16174737

Change-Id: I210c941a06b9d905bb8b37500377ad088f1d3230
2021-11-02 18:25:27 +00:00
ykhung
8f0291cd1a Fix NPE issue of usage detailed page learn more button click event
root cause: some OEMs can not provide valid intent for help & feedback
solution: check the intent is vaild or not before show up the help content

Bug: 204844010
Test: make RunSettingsRoboTests
Change-Id: I4e7a7c926205be1179d55d33ada345024c8a44ab
2021-11-02 16:34:34 +00:00
TreeHugger Robot
9abf3e5e76 Merge "Optimize battery optimize page control flow" into sc-v2-dev am: c6a5bcc933 am: 137f9acac1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16138630

Change-Id: I53031d3f0c7abe2ac1a089534f0908c939ffb49c
2021-11-01 08:20:08 +00:00
Wesley.CW Wang
151b88f76f Optimize battery optimize page control flow
- Post the setup logic into background and setup once only when leaving
 this page, this can improve the performance since we won't setup
 every time when switching preference

Bug: 195306545
Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I1c3ee4673cf5cdba0abe39f208dfb1412082c579
2021-11-01 14:52:42 +08:00
YUKAI HUNG
265d683dc1 Merge "Update app usage page power summary" into sc-v2-dev am: 8e97bdd76c am: 054f3b5199
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16091765

Change-Id: Ic7bf43d79304b740b5b6cf2a148b317860ea4869
2021-10-21 11:08:48 +00:00
Wesley.CW Wang
23a5fb5e74 Update app usage page power summary
- Present empty string when this app consumed power but no usage time,
 usually they are some system components

Bug: 197749108
Test: make -j64 RunSettingsRoboTest
Change-Id: I1e88babb30c871748fa1f5fc23c7b4d834e384fd
2021-10-21 17:29:36 +08:00
Wesley.CW Wang
d11dec2f82 Revert "Add PowerSaveWhitelistExceptIdle as Optimizted modes condition"
- Reverts commit e7cca4cd81
 - Add try-catch to handle unexpected operate

Reason for revert: Previous fix will cause a side effect which makes app stuck at Optimize mode after switching state from Unrestricted to Optimize, add a try catch to handle previous issue first

BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy naming, not edit by this code change

Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I3b1850ab66bbf4cd605f14152a244a8ed7edd578
Merged-In: I3b1850ab66bbf4cd605f14152a244a8ed7edd578
2021-10-18 09:03:06 +00:00
Wesley.CW Wang
2146a873c2 Revert "Add PowerSaveWhitelistExceptIdle as Optimizted modes condition"
- Reverts commit e7cca4cd81
 - Add try-catch to handle unexpected operate

Reason for revert: Previous fix will cause a side effect which makes app stuck at Optimize mode after switching state from Unrestricted to Optimize, add a try catch to handle previous issue first

BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy naming, not edit by this code change

Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I3b1850ab66bbf4cd605f14152a244a8ed7edd578
2021-10-18 09:02:11 +00:00
Wesley Wang
b900e0e43b Revert "Add PowerSaveWhitelistExceptIdle as Optimizted modes condition"
This reverts commit 3f7839cad0.

Reason for revert: This fix will cause a side effect which makes app switch state from Unrestricted to Optimize then it will lock at Optimize mode only, will prepare other cl to fix the previous issue

Change-Id: Ic5232eb0099fa1591f15e72747eca4d08b9af9b9
2021-10-14 09:31:13 +00:00
Wesley.CW Wang
e7cca4cd81 Add PowerSaveWhitelistExceptIdle as Optimizted modes condition
- Check PowerSaveWhitelistExceptIdle list before update each apps
 optimizaton mode to avoid duplicate remove action
 - Make those apps which under PowerSaveWhitelistExceptIdle list keep at
 optimized mode only

BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy naming, not edit by this code change


Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I3cd10cf51b5132fc12a83e9554801ec4e8578cd1
Merged-In: I3cd10cf51b5132fc12a83e9554801ec4e8578cd1
2021-09-22 02:14:05 +00:00
Wesley.CW Wang
3f7839cad0 Add PowerSaveWhitelistExceptIdle as Optimizted modes condition
- Check PowerSaveWhitelistExceptIdle list before update each apps
 optimizaton mode to avoid duplicate remove action
 - Make those apps which under PowerSaveWhitelistExceptIdle list keep at
 optimized mode only

BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy naming, not edit by this code change


Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I3cd10cf51b5132fc12a83e9554801ec4e8578cd1
2021-09-17 18:38:01 +00:00
ykhung
87898aec66 [B&R] notify BackupManager when app optimization mode is changed am: 935a9321b5 am: 5f3bc01915
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15667992

Change-Id: I8e422e893bb80e202ed50550c05ea5484b1b2756
2021-08-25 03:55:48 +00:00
ykhung
935a9321b5 [B&R] notify BackupManager when app optimization mode is changed
Invoke BackupManager.dataChanged() when app optimization mode is changed
to notify BackupManager to execute Settings agent to backup data in the
next backup session, when performing the partial backup event.

Bug: 192523697
Bug: 197608038
Bug: 194633034
Test: make SettingsRoboTests
Change-Id: I456acc2594d22503763e4ce286435148ae0644a4
2021-08-25 02:21:16 +00:00
Yuri Lin
e9f13fbd5e Rename RadioButtonPreference -> SelectorWithWidgetPreference.
This change is to reduce ambiguity as we're adding the option to style the preference like a checkbox as well.

Bug: 190180868
Test: SelectorWithWidgetPreferenceTest, RunSettingsLibRoboTests
Change-Id: Ie414347bf67ed394ef495604890c5851fc42dbc7
2021-07-20 17:01:21 -04:00
Wesley.CW Wang
e1b1f67681 Make App info page support new battery entry
- Add new battery entry to app info battery preference, support both
 legacy and new args, controlled by P/H
 - Add a method to check is work profile app or not, use owner context to
 query correct context for feature provider
 - Add string for new args

Bug: 178197718
Test: make RunSettingsRoboTests
Change-Id: Ic93142a0c5e2851917cb3e224340a6e3e81fd801
2021-06-11 04:41:12 +08:00
Wesley.CW Wang
256636055b Add description to battery settings footer link (2/3)
- Update battery saver footer learn more link description
 - Update app usage footer learn more link description

Bug: 187812487
Bug: 187135286
Test: make RunSettingsRoboTests
Change-Id: Iee496cf615f2f9e0e61be69d6b3a1d6c1c859013
2021-05-28 17:40:04 +08:00
ykhung
646c1a2e5a Add usage percentage and battery level into app relative metric
Reference the table from PM requested:
https://docs.google.com/spreadsheets/d/1TC_6MLVMvOS0p1ic0wPfQ-19AOuY8Kc8FUJdqaQSM4I/edit?ts=6098b296#gid=0

Bug: 188505537
Test: make SettingsRoboTests
Change-Id: Ia31ada9438f120fe6f29b59b67dc4de6636c11e1
2021-05-20 20:03:22 +08:00
ykhung
a3d3c22a27 Add metric for new battery relative functions for S (1/2)
Reference the table from PM requested:
https://docs.google.com/spreadsheets/d/1TC_6MLVMvOS0p1ic0wPfQ-19AOuY8Kc8FUJdqaQSM4I/edit?ts=6098b296#gid=0

Bug: 188505537
Test: make SettingsRoboTests
Change-Id: I2a4df9ab900cbeaf9885bb2dbc21ea848920bc81
2021-05-19 12:22:20 +00:00
Wesley.CW Wang
100007e31b Update restriciton page to support legacy string
- Update active time string with "last full charge" when new graph disabled

Bug: 187666107
Test: make SettingsRoboTests
Change-Id: Ie790600dcbe8b845ad63edd46b4a95a317c623a3
2021-05-12 23:18:50 +08:00