Commit Graph

84 Commits

Author SHA1 Message Date
Chaohui Wang
07335514c4 Create AppDataUsageSummaryController
Content description for usage will be added later.

Bug: 318780411
Test: manual - on AppDataUsage
Test: unit test
Change-Id: I3990218395dfd7553554346ea8ef00368ba57589
2024-04-22 04:58:49 +00:00
Zhen Zhang
22632be393 Rename method name
Renamed checkIfMeteredDataRestricted() to
checkIfMeteredDataUsageUserControllerDisabled() to relect its actual
usage.

Test: built successfully
Bug: 317265503
Change-Id: I76189da1da510067d5a715c5a34b6a18e53544fc
2024-01-04 10:33:52 -06:00
Wesley Wang
f0b67ef0f9 Apply dynamic deny list into data usage state
- Initiate and sync existing network policy when creating the instance
 - Imple a method to suggest list of packages to set as POLICY_REJECT
 - Reset/clear the policy settings once clear storage or reset
   preference

Bug: 306329984
Test: make SettingsRoboTests
Change-Id: I10ba28fee08c29bc2092820fbc8d8ac0e61d30e7
2023-11-15 18:25:19 +08:00
Chaohui Wang
d9a372204b Refresh the DataUsageList when resume
Like when back from AppDataUsage page.

Bug: 295260929
Test: manual - on DataUsageList
Change-Id: I0b1698e47f06cbe731794a2a6b04e9c9ac9450d8
2023-10-14 19:34:09 +08:00
Chaohui Wang
252450b5fc Improve the performance of AppDataUsagePreference
We only need aggregated summary, but NetworkCycleDataForUidLoader loads
usage for all cycles.

Create AppDataUsageSummaryRepository to reduce the system api call to
only once.

Fix: 304421722
Test: manual - on AppInfoSettings
Test: unit test
Change-Id: I115dfb51dbf77ed3fdde985aa1a968ff7462bebc
2023-10-10 15:51:40 +08:00
Chaohui Wang
6395cf8d30 Unify the default template and title
On AppDataUsage page, using single source of truth to calculate the
default template, and set title base on the current template.

Fix: 213266028
Fix: 234104784
Test: visual - on AppDataUsage
Test: unit test
Change-Id: I80facca0b000964e901905af51a344a4bc9f498b
2023-10-09 18:40:03 +08:00
Chaohui Wang
741979bc02 Create AppDataUsageCycleController
To improve performance and better organization and testings.

Fix: 240931350
Test: manual - on AppDataUsage
Test: unit test
Change-Id: I277133b55378a3445aceb826d771b14c0fc91e4a
2023-10-09 16:19:08 +08:00
Chaohui Wang
08e24272e4 Create AppDataUsageAppSettingsController
For better organization and testings.

Bug: 240931350
Test: manual - on AppDataUsage
Test: unit test
Change-Id: Ie3d35f5d112cf06cca585c9859624d705fbe2655
2023-10-08 17:03:48 +08:00
Chaohui Wang
b19eb9a4c2 Create AppDataUsageListController
For better organization and testings.

Bug: 240931350
Test: manual - on AppDataUsage
Test: unit test
Change-Id: I77ceeccc7055fcd948fe40d5dfb9cc4a9b9ad2ee
2023-10-07 15:03:27 +08:00
Chaohui Wang
2205762482 Improve the latency of DataUsageList
Up to 30x faster.

Currently it load the usage detail for every day at the beginning, so
it's quite slow.

To fix,
- Not load the usage detail for every day at the beginning
- Load only the cycles first
- And only load the daily detail for the selected month

Fix: 290856342
Test: manual - on DataUsageList (cell & wifi)
Test: unit tests
Change-Id: Ie18fa68f801743389bd6b6a28e236dcf1fea00e4
2023-09-27 08:05:02 +00:00
Chaohui Wang
5ed30f4672 New DataUsageListHeaderController
Move spinner and config button to DataUsageListHeaderController.

Bug: 290856342
Test: manual - on DataUsageList and AppDataUsage
Test: unit test
Change-Id: I655bd3441b2305708c0052f1203538bb07eef2af
2023-09-25 00:28:31 +08:00
Chaohui Wang
6ef678f19d Add some null annotation for data usage code
Also do some clean up.

Bug: 296357959
Test: manual - on DataUsageList page
Change-Id: Id7548e1d58d946810c844b9559bb00d65306f441
2023-08-28 17:47:06 +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
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
Chaohui Wang
c2dacf1b75 Fix flicker for AppDataUsage when zero usage
When the page is entered from the AppInfoDashboardFragment, there is no
way to know whether the cycle data is available before finished the
async loading. If it's zero usage, the cycle spinner will be removed,
which cause a flicker.

Temporarily disable the preference list's animator before initial
page updates can solve this issue.

This also fix another flicker on this page when the background data is
off.

Fix: 233963355
Test: manual visual test
Change-Id: I795ed95e15bb3216fa17adfd4f57faf5fd92fa00
2022-05-27 10:21:17 +08:00
Martijn Coenen
63db54c290 Merge "Add SDK sandbox network usage to corresponding apps." into tm-dev 2022-05-10 09:18:52 +00:00
Martijn Coenen
bc9856104d Add SDK sandbox network usage to corresponding apps.
SDK sandboxes run in a separate UID range. Their network usage should be
attributed to the corresponding app.

Make sure we collapse the usage collection of sandboxes to the
corresponding app UID in DataUsageList.

For AppDataUsage, make sure we add in the sandbox UID when being asked
to calculate data usage for a regular app UID. Invoke
DataUsageCycleLoader with all UIDs in AppItem, because there can now be
multiple UIDs associated with a regular app, too. Also make sure that
all new instances of AppItem for regular applications have their own
application UID.

Bug: 225319220
Test: manual
Change-Id: Id101a96ee4e3ba02376fa2ac64a9f9c2581acb61
2022-04-29 13:35:17 +00:00
Chaohui Wang
ddedb31f6e Fix flicker for Mobile data & Wi-Fi page
Both "Mobile data usage" & "Non-carrier data usage".

By,
1. Add header in onCreate() instead of onViewCreated()
2. Keep the space for Spinner, and preload initial cycles
3. Keep the space for 3 usage summaries

Bug: 191730864
Test: manual
Change-Id: I8c309c5f51ce6290383a2d10f75e41d0f207d61a
2022-04-28 23:00:57 +08:00
Yi-Ling Chuang
357b08a63e Revert "Disable RecyclerView animation to fix the broken UI"
This reverts commit 5b219a34ab.

Reason for revert: <b/191335572>

Bug: 191335572
Change-Id: I47ceb8d043e3b02a59e43a1ae021c3c7855cbe57
2021-06-18 10:45:13 +00:00
Yi-Ling Chuang
5b219a34ab Disable RecyclerView animation to fix the broken UI
RecyclerView has item animation by default. In this bug, RV animation
seems to be interrupted by the page transitions(Shared Axis), and so
items could not finish sliding to its position.

Hence, disable RV animation to fix it.

Fixes: 189720797
Test: Navigate to Mobile & Wifi usage page and see the normal UI.
Change-Id: I52920715ae4b63ef78a73fcb9c76c6d20f80e012
2021-06-03 18:12:07 +08:00
Bonian Chen
a5f08854e3 [Settings] Inclusive language for Data Usage
Change wordings in data usage part into inclusive language.

Bug: 160707804
Test: make RunSettingsRoboTests
Change-Id: I713e52df8201413b884257a51bc1f71a0d43179d
2020-07-15 02:52:32 +00:00
Lei Yu
22a9f539e9 Use NetworkTemplate to query data
So virtual carrier can get correct data with merged subscriberIds

Bug: 120566366
Test: RunSettingsLibRoboTests
Change-Id: I02abed77dffb55ef49fe0c4142f6f5b4a42ebe52
2019-05-13 13:04:46 -07:00
Doris Ling
3d238da4b5 Show app usage data for the correct cycle.
- when launching the app data usage from the data usage list, pass the
info about the current cycle that the user is looking at, and select
the same cycle by default when the page is first launched to match the
data on the previous page.

Change-Id: Ic91bd8ee78db4d76551dff4b132c1b74d4b3c19d
Fixes: 123192721
Test: make RunSettingsRoboTests
2019-02-12 16:53:35 -08:00
Andrew Sapperstein
5efb70ac18 Separate OTA data usage from SYSTEM_UID.
Prior to this CL, Process.OTA_UPDATE_UID was included with SYSTEM_UID
for the purposes of per-app data usage in the DataUsageList. With this
change, it is now separated into its own category.

This change also deletes the duplicate ic_system_update* icons and
moves the one implementation into SettingsLib.

Fixes: 70640191
Test: manually verified locally that there is an item in the list
with the proper title. Required setting up a custom OTA for my
test device.

Change-Id: Iecc45648f68a12c9f8e2370577ab017863e7fcb2
2019-02-08 10:39:46 -08:00
Doris Ling
dddeb5f25e Use correct default subscription id to get default network template.
- when launching the app info page and no network template is defined in
the launch arguments, use the correct default data subscription id to
check whether mobile network template should be used or not.

Change-Id: If9341abf3416c775a2b7407c1d6d0b33f4aad67f
Fixes: 120098637
Test: make RunSettingsRoboTests
2019-02-07 14:41:45 -08:00
Doris Ling
97866f0b50 Use correct uid when querying usage data for specific user.
- the data usage list shows usage data for each app, and also the
aggregated data for work apps and other user. When user clicks on the
app item, we will shows the detail usage data for that item using the
app item key. However, if the app item is not for app but for user, the
key will not be the app uid, but a key built from the user id. So,
querying using the key will not get any data.
- for app item corresponding for user, need to sum up all usage data
for the uids associated with the user.

Change-Id: I1a185ee6b4d59e477f3a03cade97d85d6982e416
Fixes: 122200400
Test: make RunSettingsRoboTests
2019-01-30 13:51:28 -08:00
Fan Zhang
31b210017b Migrate all MetricsProto enums to SettingsEnums
Bug: 122855168
Test: rebuild
Change-Id: I962d9a71179f86b7cae9dc5e9a00e0aa1557dc76
2019-01-17 14:55:42 -08:00
Doris Ling
282a0d9222 Remove "v2" from the data usage version 2 code.
Change-Id: I8ede82029194d1a9a43d00a3de7ec1a8dd77d978
Fixes: 117420679
Test: make RunSettingsRoboTests
2018-12-04 18:24:37 +00:00
Doris Ling
c11666cc00 Remove data usage v1 code.
- remove all v1 code and the corresponding feature flag switch.

Bug: 117420679
Test: make RunSettingsRoboTests
Change-Id: Ib062c03c671b0f860698f5e5e153ab46d963175a
2018-12-03 11:12:50 -08:00
Raff Tsai
1d88f4c61b Fix Settings crash on changing device orientation
- AppDataUsage assign preferences to Applist in loaderCallback.
When device rotate we will assign preference to Applist second
time which throw IllegalStateException Exception. We will use
restartLoader which create new loader rather than use existed
loader.

Change-Id: I540d645e930a29f989c4fe374e2103ca201da198
Fixes: 118195540
Test: manual
2018-10-30 09:57:53 +08:00
tmfang
6e16b69887 Sync style of filter component in data usage
Settings have new filter component with settings style.
This CL replaced Spinner to SettingsSpinner in data usage page.

Change-Id: I212b6b6ed203f8bffd094c0180873060b93c39cb
Fixes: 117568930
Test: robotests, visual
2018-10-17 05:14:46 +08:00
Philip P. Moltmann
8a33bd5947 Merge "RestrictedLockUtils was split into ...Internal" 2018-08-31 04:47:28 +00:00
Doris Ling
22c078c8de Remove the deprecated class DataUsageBase.
- and update all its subclass to extend DataUsageBaseFragment instead.

Bug: 111751694
Test: make RunSettingsRoboTests
Change-Id: Ic5720af43082d8b39642b6a539515f3f20d32694
2018-08-30 14:16:13 -07:00
Philip P. Moltmann
e3f721132a RestrictedLockUtils was split into ...Internal
This means that in some cases RestrictedLockUtils has to be used and in
some RestrictedLockUtilsInternal.

This causes a lot of trivial code changes.

I also updated the ordering of the imports in all affected files.

Bug: 110953302
Test: Built
      make -j RunSettingsRoboTests
Change-Id: I9bdf8b89134f853bae4f38c81af436715c73e924
2018-08-30 08:11:39 -07:00
Fan Zhang
23f8d59d02 Sort imports
Having consistent import order will reduce chance of merge
conflict between internal and external master

Test: rebuild
Change-Id: I0b1a170967ddcce7f388603fd521f6ed1eeba30b
2018-08-28 22:13:15 +00:00
tmfang
27c84de325 Settings Fragment Migration (Build pass app)
This patch focused on fixing compile errors and some runtime errors.

Test: We can't test it now. But we will have an integration test later.
Bug: 110259478
Change-Id: I16c471ddcd0fa1460c665b7f74d86fcace5ee67b
2018-07-11 18:24:51 -07:00
tmfang
99cc23d0da Settings Fragment Migration (Change imports)
This commit *only* changes imports and optimize imports.
We don't do anything else.

This patch can't compile pass and run test case.
We will update other patches to fix these problem.

Change list.

1. import android.app.Fragment; ->
   import androidx.fragment.app.Fragment;
2. import android.app.DialogFragment; ->
   import androidx.fragment.app.DialogFragment;
3. import android.app.ListFragment; ->
   import androidx.fragment.app.ListFragment;
4. import android.app.LoaderManager; ->
   import androidx.loader.app.LoaderManager;
5. import android.content.AsyncTaskLoader; ->
   import androidx.loader.content.AsyncTaskLoader;
6. import android.content.Loader; ->
   import androidx.loader.content.Loader;
7. import android.app.FragmentTransaction; ->
   import androidx.fragment.app.FragmentTransaction;
8. import android.app.FragmentManager; ->
   import androidx.fragment.app.FragmentManager;
9. import android.app.LoaderManager.LoaderCallbacks; ->
    import androidx.loader.app.LoaderManager.LoaderCallbacks;

Bug: 110259478
Test: Can't test it.
Change-Id: I0a3f98fff34a3494a839c3c42aeabcec3df2c8b3
2018-07-11 18:23:51 -07:00
Fan Zhang
c7162cd24d Reorder and clean up imports.
Test: rebuild
Change-Id: I178485c84ae7146f991fd77b6d7504b029942a68
2018-06-18 15:45:09 -07:00
HJ ChangLiao
5693be2863 Replace PackageManagerWrapper with PackageManager
Replace all SettingsLib/PackageManagerWrapper in Settings,
by PackageManager,
Remove ShadowPackageManagerWrapper.

Bug: 62067063
Test: make RunSettingsRoboTests
Change-Id: I6d1af55c13d80c1907b98b21e0207cc903cd9b1f
2018-04-24 15:12:31 +08:00
Aurimas Liutikas
e0069d332d Migrate Settings to androidx.
Test: make Settings
Bug: 76692459
Change-Id: I941dea40562170649bf056e675cc32e5163c0e39
2018-04-20 12:52:29 -07:00
Fan Zhang
289677f97f Switch from SI to IEC unit when formatting data usage bytes
- Created a new helper method DataUsageUtils.formatDataUsage() to
  format data usage bytes using IEC formatting.
- Switch from Formatter.formatFileSize() to DataUsageUtils.formatDataUsage()
  everywhere in datausage package.

Change-Id: I9323beed8bf5126b153fc9a3cdd9591c97ca6fd2
Bug: 76159924
Test: robotests
2018-04-12 09:52:35 -07:00
Sudheer Shanka
b8b2e51e8d Add policy transparency for metered data related settings.
With API Dpm.setMeteredDataDisabled, admins can restrict some
packages from accessing metered data and when admin does restrict
packages, user settings to enable usage of mobile data in background or
allow unrestricted access during data saver mode are not relevant. Add
policy transparency to these settings so that user knows that admin
disabled them.

Bug: 63700027
Test: make RunSettingsRoboTests
Test: manual
Change-Id: I450f7a91356ed8fb33f464620c73fa9407a1ff83
2018-01-26 10:57:11 -08:00
Doris Ling
dee1a22c45 Consolidate all wrappers used for testing.
- Add the wrapper package and move all wrappers to the wrapper package.
- Get rid of some wrapper interface/impl implementation and have a
wrapper class directly.

Bug: 65634579
Test: make RunSettingsRoboTests
Change-Id: Ic757d8f7bacfa7a034c7e692205bc1dc4b0e1de1
2017-09-14 18:24:49 -07:00
Fan Zhang
816efc02fc Refresh preferences when background data switch is toggled
Change-Id: Id58f565645fc3c668b516dbd05049559afa9535e
Fixes: 64466310
Test: robotests
2017-08-08 17:38:28 -07:00
Rajeev Kumar
9664c1a55e Refactor few public static methods.
Move public static methods from DataUsageSummary to DataUsageBase.

Bug: 62349208
Test: make RunSettingsRoboTests -j40
Change-Id: I632f75f4c4f370fb225a9787267043fec20994e5
2017-07-14 14:01:02 -07:00
Fan Zhang
75bee9bf98 App header cleanup
- Refactor the entity header layout to use LinearLayout and add id to
  content area
- Remove now unused AppHeader class
- Make entire icon+text area clickable and link to app info page
  Refactor the binding logic from bindButton to its own method.
- Remove unused MultiLinePreference

Fix: 62705377
Test: make RunSettingsRoboTests

Change-Id: I6db554695410e71b669f6fdba29d98fedc3364b9
2017-07-06 13:23:38 -07:00
Fan Zhang
17d63964c7 Set correct uid when loading app icon in data usage UI.
work profile apps belongs to a different user. Set the correct uid when
loading the icon so the work profile badge is displayed.

Change-Id: I2ed27d6b83c1b42961500dc8d63475bf1f7eabcd
Fix: 38372681
Test: make RunSettingsRoboTests
2017-05-24 16:04:23 -07:00
Fan Zhang
841d1d5aab Show shadow when entity header starts scrolling.
- Add a controller to manage add/remove onScrollChangedListener to
  recyclerviews.
- When recyclerview on each screen is scrolled to top, set actionbar
  elevation to 0, otherwise set it to non-zero.
- When screen is moved to background, detach the listener.
- Use the controller in entity header.

Change-Id: Iecf194d885098c98c392810f62893ae9189f3936
Fix: 37670670
Test: make RunSettingsRoboTests
2017-05-22 17:16:24 -07:00
Fan Zhang
d7414259d0 Move entity header controller out of application package.
Bug: 37669238
Test: rerun robotests
Change-Id: I54eb30f28fa0a88a6f0b97b53f9f1408320b5ce0
2017-05-18 16:36:32 -07:00
Fan Zhang
f5bd885a1d Clean up settings_entity_header layout.
update layout view IDs, and controller variable names to be more
generic.

Fix: 36734470
Bug: 37669238
Test: make RunSettingsRoboTests
Change-Id: Ib80827ae3eae6d01a600068b4a8a44b239c32511
2017-05-18 16:35:27 -07:00