Commit Graph

133 Commits

Author SHA1 Message Date
Yiling Chuang
419a6a9079 FRP bypass defense in App battery usage page
Before the setup flow completion, don't allow the app info page in App battery usage to be launched.

Bug: 327748846
Test: atest SettingsRoboTests + manual test
- factory reset + launch app battery usage app info via ADB during Setup -> verify app closes
Flag : EXEMPT bugfix

Change-Id: I486820ca2afecc02729a56a3c531fb931c1907d0
2024-07-09 08:13:49 +00:00
mxyyiyi
8eaf8edf7e Add AppOptimizationModeEventsUtils to save & update app optimization mode expiration events.
- [Update] Save app optimizaiton mode set & expire events from turbo.
- [Reset ] Restore optimization mode for expired events in Periodic job.
- [Delete] Cancel expiration event if user updates mode in app usage page.

Bug: 338965652
Test: atest + manual
Change-Id: I3fb7311207da1bdb1146ea1ff041aca6adb66052
2024-06-03 19:42:26 +08:00
Jacky Wang
ef8a51fac8 Reset app preferences does not trigger backup for App battery usages
Bug: 328712606
Fix: 328712606
Test: UT && Verify logcat when change/reset App battery usages
Change-Id: Ia3917c8dc2654185f5f048c048362fd47379b7d1
2024-03-11 13:41:03 +08:00
Jacky Wang
006bf17c4f [DataStore] Migrate BatteryBackupHelper to BackupRestoreStorage
Bug: 325144964
Test: Manual tests
Change-Id: I19f7c78969d70648d1e45f1627827d98b1fdd1e0
2024-03-03 22:42:00 +08:00
mxyyiyi
f33597b41d Update log metrics in battery usage.
- Remove redundant logs
- Update action id

Bug: 323495266
Test: manual
Change-Id: I3146405912f3df152c7a0d525ba06ba76e2e02df
2024-02-18 16:00:43 +08:00
mxyyiyi
06fa244255 Update action log metircs of app optimize mode.
Bug: 317329360
Test: manual
Change-Id: Id4cd610a5bcc7988ecbd4545f5ef77a5253aac33
2023-12-27 14:13:25 +08:00
mxyyiyi
a919306d75 Provide foreground_service usage time in BatteryDiffEntry.
- Fetch foreground service info through new api from UidBatteryConsumer.
- Record fgs & bg usage time separately, combine them till ui display.

Bug: 315255868
Test: make RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.fuelgauge.*"
Change-Id: Ic19844db7908a6ae6522c7a72972f44f94dcfca4
2023-12-11 15:57:10 +08:00
Jun Lan
cca804e1ed Format battery java code
After this CL, we can follow Guideline:go/hc-mainline-dev#format-code to keep java format consistent.

Test: manual
Bug: 304439460
Change-Id: I5bb77f81b0bd9be618e34942eaaee8296bc42796
2023-11-06 13:55:48 +08:00
mxyyiyi
81e028931a Refactor background optimization mode in Power Usage Detail page.
[Screenshot]:
before: https://screenshot.googleplex.com/6m5jYWHofY2pFov

after:
[App battery usage]
- [normal] https://screenshot.googleplex.com/7aurWk7cHKaWds7
- [always unrestried/optimized] https://screenshot.googleplex.com/3rGAh4ccUYTKBAr

[Allow Background usage]
- [Restricted]: https://screenshot.googleplex.com/MPXjQe5kPWw2nhr
- [Optimized]: https://screenshot.googleplex.com/6w4zTT6r34APnGc
- [Unrestricted]: https://screenshot.googleplex.com/97FgvHWMrwASqYH

Bug: 302063050
Bug: 306295660
Bug: 308359833
Test: manual
Change-Id: I3237d015549fe26e62d6d68c13403cc2cbdf0017
2023-11-01 11:17:30 +08:00
mxyyiyi
1b9eb170dd Refactor Power Usage Time Page.
- Show use time category

Screenshot:
[Screen time with hint] https://screenshot.googleplex.com/3cRLrwevzw4iytb
[Background time with hint] https://screenshot.googleplex.com/zEf8PcWopCVCRZR
[without hint] https://screenshot.googleplex.com/9bao9sVd8s7VRwM
[enter from app info (without category)] https://screenshot.googleplex.com/8sozxMrq8ojadiF

Bug: 302063050
Test: Manual
Change-Id: Ic967d05a173afa76c2a958e1332dedd9f83cd687
2023-10-02 02:34:35 +08:00
Chaohui Wang
cc2133ba8e Clean up unused fields from EntityHeaderController
Bug: 295260929
Test: manual - on pages with header
Test: robo test
Change-Id: Icebd63dbb5d3d44b4b46d3bececb8b65b30b4883
2023-08-21 13:58:07 +08:00
Zaiyue Xue
aa37dd953e Merge "Battery usage page latency improvement (1-8)" into udc-qpr-dev am: 1dad0bf856 am: d1a0370ddb
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24211971

Change-Id: I2e0c1388e423cc18db20bbbb1f14b73d9667199f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-18 02:47:49 +00:00
Zaiyue Xue
50da7feeb9 Battery usage page latency improvement (1-8)
Save battery slot diff data into database in hourly job. Then read the
saved diff data and only calculate the remaining data. This could speed
up the battery usage loading.

Bug: 261163071
Fix: 261163071
Test: manual
Change-Id: Icd4868ca9326b64b17ddbccdb0311e755dc68026
2023-08-16 15:12:04 +08:00
Chaohui Wang
8e2ae547d6 Clean up FeatureFactory.getFeature()
Bug: 286764889
Test: m Settings
Change-Id: I7e472e6b0ca6b7a735c1b92742ddf06c545176fc
2023-08-08 08:41:48 +00:00
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