Commit Graph

599 Commits

Author SHA1 Message Date
Chaohui Wang
e9cf4bf65c Merge "Convert DataUsageLib to Kotlin" into main 2023-08-08 05:05:01 +00:00
Chaohui Wang
3cd47c1448 Clean up unused operator_warning
Usage is removed in Change I9781af3a53fe7050b414f0574abb7618f8d71707.

Bug: 285231003
Test: m Settings
Change-Id: I89fb8630cc6bea4828b14936d5e2234de9f232ea
2023-08-07 10:46:01 +08:00
Chaohui Wang
d01245e75b Convert DataUsageLib to Kotlin
For better null safe.

Also add unit tests.

Fix: 290698845
Fix: 290684887
Test: unit test
Test: manual - on Mobile Settings page
Change-Id: I9c9edb9b7cbf7d688a885e5c36b61bd6dc526add
2023-07-31 01:22:58 +00:00
Chaohui Wang
77fd6aa117 Use DataUsageLib in DataUsagePreferenceController
DataUsagePreferenceController use DataUsageLib before, and DataUsageLib
and com.android.settingslib.net.DataUsageUtils has same functionality.

com.android.settingslib.net.DataUsageUtils will be clean up, so use
DataUsageLib again.

Bug: 286082055
Test: m Settings
Change-Id: I6227f973ec38e5b0520f54a41ac2ede2929a1bcc
2023-07-04 19:08:46 +08:00
Chaohui Wang
5d847e0207 Merge "Call onViewCreated in DashboardFragment" into udc-qpr-dev am: 8617f63823
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23659924

Change-Id: I71e428a2a332e4ed6f3d4719c28cb5408aeaeb51
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15 03:59:56 +00:00
SongFerng Wang
143d1f50ee Merge "Remove the owner" am: 286344d539 am: 448c8b61a8 am: 61ef9024c8 am: 7f29649aa9 am: 2a6553b122
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/23688861

Change-Id: Ib77854f005228a2193682cc3e55406e0ef60e651
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14 19:10:07 +00:00
SongFerng Wang
7f29649aa9 Merge "Remove the owner" am: 286344d539 am: 448c8b61a8 am: 61ef9024c8
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2623772

Change-Id: I278260f1a36ed24fd1ca2d53ffc7ff2431fd1005
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14 07:54:48 +00:00
SongFerng Wang
448c8b61a8 Merge "Remove the owner" am: 286344d539
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2623772

Change-Id: Iad21da9fbcd8d9279c27beb7a7c0761644d8f2b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14 05:36:47 +00:00
Chaohui Wang
eb4fea1a36 Call onViewCreated in DashboardFragment
To let fragment's view lifecycle owner passed in to controllers.

For UI usage, view lifecycle owner is the best choice, controller could
use this lifecycle owner to observe events and do UI related works.

Usage DataSaverController as first example.

Bug: 287005021
Test: Manually for DataSaverController
Change-Id: Id965ea3a24d61f4d0ec6735632944f41f72ba06a
2023-06-14 12:22:12 +08:00
SongFerngWang
f405dadcf2 Remove the owner
Bug: 286964921
Test: build pass
Change-Id: I4daf629e8cb994753dca36a811f0d25685df6928
2023-06-13 15:10:46 +08:00
Chaohui Wang
3e35cff7ba Move unrestricted data summary to DataSaverController
DataSaverController currently used in 2 pages,
- Network & internet > Data Saver
- Apps > Special app access

This helps unify the logic, and instead of showing on "Special app
access", this summary shows on "Unrestricted data" is make more sense.

Bug: 280280596
Test: Manually on above pages
Test: Unit test
Change-Id: Ia151ed8179a250f8f20cc5041f9383fffebdab10
2023-05-26 13:05:48 +08:00
Chaohui Wang
b04b977cac Merge "Improve the loading time of DataSaverSummary" into udc-qpr-dev 2023-05-25 09:38:35 +00:00
Chaohui Wang
cb9374e294 Improve the loading time of DataSaverSummary
Use AppListRepository instead of ApplicationsState can achieve better
performance.

Fix: 280280596
Test: Manually on Data Saver page
Test: Unit test
Change-Id: I98cbae50500b90e7e7f6101fb064003339b082c1
2023-05-24 17:23:24 +08:00
Chaohui Wang
a95d62a4a8 Fix the bytes displayed unit
This used to by MByte and GByte, not used in other places in Settings,
and not align with the data summary on the same page.

Unify to MB and GB to align with other places in Settings and the data
summary on the same page.

Fix: 277900792
Test: Visual
Test: Unit test
Change-Id: I9f8ceac470aede135b7921c391c063ba87da661e
2023-05-23 14:21:03 +08:00
Weng Su
f65c4530e4 Hide carrier service package in Wi-Fi data usage settings
- When there is no specified SubscriptionInfo, Wi-Fi data usage will be displayed. In this case, the carrier service package also needs to be hidden.

- Fix failing test cases in DataUsageListTest

Bug: 273167633
Bug: 280021214
Test: manual test

Change-Id: I66ff8a28d9e7f7db77c8a210cb36676a07fc2c7d
2023-05-10 17:30:01 +08:00
Chaohui Wang
68d638707b Fix Data Saver page crashed when rotate
This is because before fix mLoadAppRunnable is async run. And the
getContext() within it will return null when the Fragment in some not
ready lifecycle.

Use viewLifecycleOwner.lifecycleScope.launch to ensure the async
function will only be run when the view is ready, and automatically
canceled when out of scope.

Since this requires Kotlin Coroutine so migrate DataSaverSummary to
Kotlin, other functionality are keep no change.

Fix: 279863347
Test: Manual
Change-Id: I2e97a071c103e63b3306b801fc38f4704e3be0d2
2023-04-27 20:08:19 +08:00
Chaohui Wang
8397287f87 Fix flicker for Data Usage page
Both "Mobile data usage" & "Non-carrier data usage".

By,
1. Use summary placeholder for usage amount to avoid shift
2. Before fix CycleListener's onItemSelected() is called multiple times,
   cause the app list to flash, let DataUsageList to handle the dedup
   logic to better handling.
3. Before fix if return from App Usage page, no loading view is
   displayed (only first enter has it), move this to onResume() to fix.
4. Before fix the cycles passed to App Usage page is cached (even when
   the cycles are changed), clear the cache when onResume() to fix.
5. Listener in SpinnerPreference could be null, add safety guard to it.

Cherry-pick from Change-Id: I95e544c46333496f4f30ed77dafa4779b4d66019

Fix: 277162513
Test: manual visual test
Test: Unit test
Change-Id: I50fb79aa3c888651a79fd1d030da554bebb6a660
2023-04-22 08:47:22 +08:00
Chaohui Wang
f46b33bbc4 Revert "[DataUsage] Adjusting the control of display sequence"
This reverts commit b8491032d7.

Bug: 277162513
Test: Manual
Test: Unit test
Change-Id: I5a84a9b1a99b1da4c18d786a6dff062b53cd46c6
2023-04-22 08:47:21 +08:00
Chaohui Wang
52b723beef Revert "[Settings] Adjusting the control of display sequence (part 2)"
This reverts commit 6b379cd7cf.

Bug: 277162513
Test: Manual
Change-Id: Iea61c06d328626a96c13c4c9f8a11f8329401b35
2023-04-22 08:47:20 +08:00
TreeHugger Robot
3771564adc Merge "[Settings] User with restriction should avoid from having entries through Settings search" into tm-qpr-dev am: 0362083f3a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21367719

Change-Id: I54ad21af66956d5711a72f587d9af4c8389a185f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-31 01:23:13 +00:00
TreeHugger Robot
0362083f3a Merge "[Settings] User with restriction should avoid from having entries through Settings search" into tm-qpr-dev 2023-03-31 00:20:15 +00:00
TreeHugger Robot
17e504f6a8 Merge "Restrict DataUsageList for guest user" into tm-qpr-dev am: 5bde972e4e am: f02d69dd4f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22323478

Change-Id: Ibfe01c87ea15467a736ccaf7d812c8eaffaefa76
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-30 20:39:38 +00:00
TreeHugger Robot
f02d69dd4f Merge "Restrict DataUsageList for guest user" into tm-qpr-dev am: 5bde972e4e
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22323478

Change-Id: I6fcc26d5db647b9c36b743592a8b58dda52b1847
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-30 20:04:20 +00:00
TreeHugger Robot
5bde972e4e Merge "Restrict DataUsageList for guest user" into tm-qpr-dev 2023-03-30 19:08:44 +00:00
TreeHugger Robot
5d0b8031fd Merge "Restrict DataUsageSummary for guest user" into tm-qpr-dev am: b6399c95b3 am: 64aa2889d1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22323468

Change-Id: I7a12612e6aef131353d1dfbe2c8f4dd86d7b5b1c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-30 17:28:36 +00:00
TreeHugger Robot
64aa2889d1 Merge "Restrict DataUsageSummary for guest user" into tm-qpr-dev am: b6399c95b3
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22323468

Change-Id: I5565f72a9d96e5212b2db3b57d9978648596fba3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-30 16:30:30 +00:00
Weng Su
6e79778d3c Restrict DataUsageList for guest user
- Don't show DataUsageList if the user is a guest

Bug: 262741858
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=DataUsageListTest

Change-Id: Id877c2235c6a65683f2d0a0ba381dffba4dd95b8
2023-03-29 21:44:55 +08:00
Weng Su
3abf4d9d5f Restrict DataUsageSummary for guest user
- Don't show DataUsageSummary if the user is a guest

Bug: 262243574
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=DataUsageSummaryTest

Change-Id: I94d0fd18a81dc0f0adba544340e648d58c5d3358
2023-03-29 18:12:44 +08:00
Bonian Chen
55f1970181 [Settings] User with restriction should avoid from having entries
through Settings search

1. Avoid from generating search report when user been restricted.
2. Guest user should have this restriction but not available, add
   additional rule as a conpensation from UI's perspective.

Bug: 260860114
Bug: 235822222
Test: local

Change-Id: I63ba7f3b10fc812dd1498f17826a15e822879613
(cherry picked from commit 5e1c4d15a9)
Merged-In: I63ba7f3b10fc812dd1498f17826a15e822879613
2023-03-28 06:21:27 +00:00
Zoey Chen
7beb190e9c [Settings] Hide package name if needed
Bug: 273167633
Test: local test
Change-Id: I237d8f5821080283465a6cf72ad7505a55a6bb81
2023-03-24 14:00:31 +00:00
Lifu Tang
caa1b51ef2 Revert "Remove duplicate strings."
Revert submission 19748582-settings_yesno

Reason for revert: Common strings in English could be translated into different strings in other languages.

Reverted changes: /q/submissionid:19748582-settings_yesno

Bug: 272603842
Test: build and open Settings app
Test: atest SettingsRoboTests
Change-Id: Iaad301c5513478fb95e40987ea3ccb4f923d71fa
2023-03-15 22:39:24 +00:00
Junyu Lai
3eb30fb31c Merge "Do not crash when duplication found in merged imsi list" am: ae267bae74 am: 0da4abe1db am: 4beef2e82e
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2479336

Change-Id: I7323a6fbd1e8f7595fdb7c29e7520cff5ac12a00
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-10 10:48:49 +00:00
Junyu Lai
0da4abe1db Merge "Do not crash when duplication found in merged imsi list" am: ae267bae74
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2479336

Change-Id: I3e55fc5496918d8e2d0c230df74b62e1e6847fb6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-03-10 09:37:20 +00:00
Junyu Lai
8005bc8f5b Do not crash when duplication found in merged imsi list
For some unknown reason, the merged imsi list might contain
duplicated items. Deduplication for better error handling.

Test: make RunSettingsRoboTests
Fix: 271298466
Change-Id: I3cbe8f9441769963a16720fc5128db173fa0868b
2023-03-09 16:55:35 +08:00
Bonian Chen
c9cca5940b [Settings] Re-enable previous work on data saver
Previous work on data saver performance got disabled, this is a change to re-enable it.

Bug: 249502488
Test: build pass

Change-Id: I7264b1e8c21a789db358e0aae70a2cf0ce09ebba
(cherry picked from commit 2115d0e495)
2023-02-24 06:27:18 +00:00
Arc Wang
5cb2a1fa8d Put mobile NetworkTemplate in Intent for SearchResultTeampoline
BillingCycleSettings and Settings.ACTION_MOBILE_DATA_USAGE needs
mobile NetworkTemplate to work correctly.

Bug: 268411305
Test: manual
Change-Id: I7e2eafff39f1bffeb8adbe4d7c3567b7a4ea7dda
2023-02-20 15:04:26 +08:00
Bonian Chen
131ca6ca75 Merge "[Settings] Close UI when accessed from guest user" 2023-02-11 00:55:08 +00:00
Bonian Chen
76cd5d3c27 [Settings] Close UI when accessed from guest user
Avoid from guest user access.

Bug: 262242953
Test: local

Change-Id: Ifdc6d7ea7f65a945b2111a391eb53de6c1a3f52b
2023-02-10 18:09:09 +00:00
Bonian Chen
5e1c4d15a9 [Settings] User with restriction should avoid from having entries
through Settings search

1. Avoid from generating search report when user been restricted.
2. Guest user should have this restriction but not available, add
   additional rule as a conpensation from UI's perspective.

Bug: 260860114
Test: local

Change-Id: I63ba7f3b10fc812dd1498f17826a15e822879613
2023-02-09 16:42:56 +00:00
Patrick Rohr
73d7224561 Merge "Enable ethernet data usage when FEATURE_USB_HOST is present" am: b0ddc1833d am: ac83ccd34f am: 05e4a2f56b
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2420579

Change-Id: I7d36d2dcd3a6d0a38c58c8e25cb34c89c45ab1dc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-03 20:07:29 +00:00
Patrick Rohr
ac83ccd34f Merge "Enable ethernet data usage when FEATURE_USB_HOST is present" am: b0ddc1833d
Original change: https://android-review.googlesource.com/c/platform/packages/apps/Settings/+/2420579

Change-Id: If7bf40d49a67c14a62e4db7994995dac9b86fb3b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-02-03 18:15:21 +00:00
Patrick Rohr
d2d340146e Enable ethernet data usage when FEATURE_USB_HOST is present
Ethernet is enabled when either FEATURE_ETHERNET *or* FEATURE_USB_HOST
is present. See ConnectivityService#deviceSupportsEthernet.

ConnectivityService#deviceSupportsEthernet should really be moved to
some commonly accessible location.

Test: TH
Change-Id: I497d99169248db7e5948b3a19134ab42e66d5b9b
2023-02-03 03:32:02 +00:00
xinghailu
b5293a2d1c Cleanup plurals in Settings, change <one> to <1> in string res file.
"One" and "1" are not same, such as "1st place" vs "a
place". Also in many languages, plurals expression is different with English, for more detail please check: go/android-i18n-plurals.
So in string res file, replace "one" with excat value "1" is a more
proper way.

Test: Existing unit tests still pass.
Bug: 199230342
Change-Id: I832abc38afc5d8816fa803865c25e6017cffa2c6
2022-12-13 18:31:08 +08:00
Bonian Chen
56e5d50ca7 Merge "[Settings] enhancing data saver config control" into tm-qpr-dev am: 106fd86520
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20419511

Change-Id: I5338c24812346b79068b1fee0c5ba98ff07eec33
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-11 10:23:48 +00:00
Bonian Chen
86e2948eb6 Merge "[Settings] Hide data usage when SIM support is turn OFF" into tm-qpr-dev am: a6824c9b34
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20419510

Change-Id: Ie433daffbe56a1a526880c2e254a13ff17aaa3c3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-11 10:23:44 +00:00
Bonian Chen
106fd86520 Merge "[Settings] enhancing data saver config control" into tm-qpr-dev 2022-11-11 09:35:21 +00:00
Bonian Chen
2a6792540b [Settings] enhancing data saver config control
Enhancing the control of R.bool.config_show_data_saver when false, which including:
1. Initial presentation is invisible
2. Leaving UI when triggered
3. Avoid from getting searched
4. Robolectric test case support

Bug: 243877672
Test: test cases and local testing
Merged-In: I909522c0244ebb012a27d6aff34120a4f90128c6
Change-Id: I909522c0244ebb012a27d6aff34120a4f90128c6
2022-11-10 11:23:20 +00:00
Bonian Chen
5a264f69f4 Merge "[Settings] Hide data usage when SIM support is turn OFF" 2022-11-10 11:21:20 +00:00
Bonian Chen
d3b35f24f0 [Settings] Hide data usage when SIM support is turn OFF
Enable the UI control through configuration.

Bug: 240515161
Test: local, auto test
Merged-In: I5e49a2b0f2b563b426354f4d2e6e650dcc02c98b
Merged-In: I4e0db5688dc1b074d43f9d77dd2f6d4cc53a353c
Change-Id: I4e0db5688dc1b074d43f9d77dd2f6d4cc53a353c
2022-11-09 10:52:35 +00:00
Bonian Chen
0952e39d7a [Settings] Hide data usage when SIM support is turn OFF
Enable the UI control through configuration.

Bug: 240515161
Test: local, auto test
Change-Id: I4e0db5688dc1b074d43f9d77dd2f6d4cc53a353c
2022-11-08 08:54:36 +00:00