Commit Graph

86 Commits

Author SHA1 Message Date
Jason Chiu
20df25e6b9 Reduce the flickering of injected items when package is changed
Root cause:
Settings listens to four package-related broadcasts in order to refresh
injected items because UI data may change. However, when the system is
updating apps on the first boot, it triggers a burst of broadcasts. For
each broadcast Settings will reload and then redraw all injected items,
which leads to the flickering.

Solution:
1. When Settings recieves a broadcast, check if there are already two
reloading tasks to avoid redundant updates.
2. In the reloading task, check if any injected item is changed, added,
or removed to notify categories changed.
3. Only refresh the UI when any of the changed items belongs to the
current page.

Bug: 166785977
Bug: 168309941
Test: manual, robotest
Change-Id: I77745b60f84510554bff1870a5bb7a8013eab528
2020-10-02 17:13:16 +08:00
govenliu
b70ddb9df7 [Wi-Fi] WiFi Settings inclusive language fix plan phase 1
Replace WiFi related terms which contain Master wording.
Goal: Create a fixit for Android Platform to reduce the use of non-inclusive language for all code.

Bug: 161425297
Test: make RunSettingsRoboTests -j or
make RunSettingsRoboTests ROBOTEST_FILTER=DashboardFragmentTest
make RunSettingsRoboTests ROBOTEST_FILTER=WirelessDebuggingPreferenceControllerTest
make RunSettingsRoboTests ROBOTEST_FILTER=AutomaticStorageManagementSwitchPreferenceControllerTest
make RunSettingsRoboTests ROBOTEST_FILTER=AllInOneTetherPreferenceControllerTest
make RunSettingsRoboTests ROBOTEST_FILTER=TopLevelNetworkEntryPreferenceControllerTest
make RunSettingsRoboTests ROBOTEST_FILTER=PrimarySwitchPreferenceTest
make RunSettingsRoboTests ROBOTEST_FILTER=WifiPrimarySwitchPreferenceControllerTest
make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherPreferenceControllerTest

Change-Id: I9395c50e092e124016609f88f7c8151554a0d874
2020-07-21 20:56:22 +08:00
Bonian Chen
048d9fe19e [Settings] Code Refactor
Code refactor to provide the capability of method override

Bug: 141833767
Test: manual
Change-Id: I79647a7ff79f1f722bcfdf8190590df61bb3510a
2020-04-23 04:11:55 +00:00
Jason Chiu
b12e3b96c9 Support click metrics logs in several pages
- Assign metrics category to perferences at an earlier stage in
  DashboardFragment for better usability.

Bug: 137559984
Test: robotest
Change-Id: Icd4185efa0e655be20c4b673a1380fa42140923f
2020-04-07 16:44:53 +08:00
Jason Chiu
819abf7f87 Refine metrics log in infrastructure
- Add interfaces to set/get metrics category in BasePreferenceController
  for descendants having a chance to get it.
- Set metrics category in DashboardFragment
- Automatically log metrics in onPreferenceChange of
  TogglePreferenceController
- Add support for TwoStateButtonPreference in TogglePreferenceController
  to make the preference generic

Bug: 137559984
Test: robotest
Change-Id: Ia7e0d24a3db1991b18e0286d9894570fa71247a3
2020-04-07 14:08:39 +08:00
Bonian Chen
1b9bda3b05 [Settings] Avoid rendering hidden preferences
Under dashboards with expand button, preferences are renderred even
not been expanded.
Avoid from rendering un-expanded preference can improve the performance
of dashboard display.

Bug: 141833767
Test: manual
Change-Id: I00c6f827a0b7b7cec6a6fd8c809b94ca1dce88bb
2020-02-11 20:52:31 +08:00
Jason Chiu
1281e595e4 [Settings] Add preference click metric log
- Move the log point of onPreferenceTreeClick from DashboardFragment to
  it's super class InstrumentedPreferenceFragment for better coverage.
- Write the preference click metric log in PreferenceController handling
  case in DashboardFragment which will skip super class's log point.

Bug: 137559984
Test: robotest
Change-Id: I67178f613c74f755e20fc9dc41319974cb02e83c
2019-12-16 10:57:09 +08:00
Raff Tsai
f71db73025 Implement work-profile infra in BasePreferenceController
- Add settings:forWork in xml
- Set mIsForWork based on xml attribute
- Delete WorkProfilePreferenceController and move its function to
BasePreferenceController

Fixes: 123376083
Test: Add work profile, go to Settings->System->Language&input,
UI should show work profile related items
Change-Id: Id2dcbb0e158c117cdfd363466a275f4e133c345e
2019-12-10 09:32:37 +08:00
Sunny Shao
e5e82400ac Add page creation latency for updatePreferenceStates
- The updatePreferenceStates is called in the onResume. Here creates a new enum to
  record the elapsed time.

Bug: 137558156
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.dashboard
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.core
Change-Id: I02bdbeecd61fbc0082eea19ea64cbfe7541a6970
2019-11-28 17:00:31 +08:00
Sunny Shao
3351c78b74 Add FutureTask approach in DashboardFragment
- Use the multiple tasks to enhance the controllers loading.

Bug: 137558156
Test: make RunSettingsRoboTests ROBOTEST_FILTER=com.android.settings.dashboard
Change-Id: I629ff5dc81347cddf9762a87015b9b86b6a46e50
2019-11-26 11:27:03 +08:00
Jason Chiu
10e675d6b5 [Settings] Support master switch of inline toggle of Settings Injection v2
Allow developers to inject MasterSwitchPreference, a switch
preference with two tap targets, to Settings page.

Developers should declare keyhint and switch_uri for the activity
in AndroidManifest,and then implement a SwitchesProvider.

Bug: 132808482
Test: robotest
Change-Id: I64cdf18268be0cfcd38aab2c059144536dd79b32
2019-11-22 04:04:04 +00:00
Jason Chiu
bac5987c8e [Settings] Support pure switch of inline toggle of Settings Injection v2
Bug: 132808482
Test: robotest
Change-Id: Ib24614fb46fe990925edad721e3b7d5d032854fc
2019-11-19 18:24:13 +08:00
Jason Chiu
1a1f9314b6 Refactor Settings for injection v2 inline toggle
Bug: 132808482
Test: robotest
Change-Id: I0b74e05bc26b97259a15859c669060ce3da7972a
2019-10-04 18:32:11 +08:00
Raff Tsai
6db277ebb7 Remove summary provider
- use SummaryProvider to provide the summary of UserSettings
- use WifiDisplayPreferenceController to replace the summary loader
in WifiDisplaySettings
- use ConfigureNotificationPreferernceController to replace the
sumary load in ConfigureNotificationSettings

Fixes: 141653158
Test: robolectric
Change-Id: Id5f5ed645707caa0b25ecae5252174cbf017651c
2019-10-03 15:04:36 +08:00
TreeHugger Robot
d48189c564 Merge "Use SettingsLib Indexable" 2019-09-26 06:51:17 +00:00
Raff Tsai
966fa01423 Use SettingsLib Indexable
- Use SettingsLib Indexable
- Directly use resource id in getPreferenceScreenResId

Bug: 135053028
Test: roboletric
Change-Id: I05f493b55e8b6e2091301e9231ba5615215618e6
2019-09-25 18:24:56 +08:00
hughchen
d49de61f96 Do not block UI when this page didn't have slice
This CL before, if controller have UIBlocker interface
will going to blocker condition to make whole page
invisible for a certain time until slice is fully loaded.

This CL add the check condition that if the controller
have UIBlocker inferface but didn't have slice uri will
not go to blocker condition.

Bug: 141292712
Test: make -j42 RunSettingsRoboTests ROBOTEST_FILTER=DashboardFragmentTest
Change-Id: I79daae131654f8fd823a9c8f1be46ad6c7921908
2019-09-24 10:30:49 +08:00
Yanting Yang
4e56cb2917 Add a way to suppress injected tiles for OEMs
Create a config resource for OEMs to add suppressed tile's key, then
DashboardFragment will filter related tiles out from Settings.

OEMs can use this way to suppress security patch injected tile if they
don't use Google OTA.

Fixes: 130734771
Test: visual, robotests
Change-Id: I4cab79c8672048fa543d39b2a8f38ffe338189c8
2019-04-20 01:31:07 +08:00
lindatseng
2e7af2f023 Fix tinting on injected pref icon
We used to tint the injected pref icon when refreshing Tile. However,
when we are going to render the icon, we used Tile.getIcon which uses
the icon resource id to get the original version of icon directly.

Do a little refactor here to move the tinting logic inside Tile.getIcon.

Test: Manual/Visual inspection
Fixes: 129010399
Change-Id: I6f187b12cb6d91b54dcfe43e0ff34add55fd7b07
2019-04-02 13:35:17 -07: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
jackqdyulei
a5f1b5c629 Fix crash for UiBlockerController
1. Don't create UiBlockerController if there is no related controller
2. Don't update visibility if UiBlockerController is null
3. Use findPreference() from DashboardFragment, which already has null
check.

Change-Id: Iee24c64317fb9d5a1cf2076d25728af485d390c5
Fixes: 122807414
Fixes: 122805831
Test: RunSettingsRoboTests
2019-01-15 03:58:14 +00:00
jackqdyulei
22904a05b7 Add UiBlocker for DashboardFragment
If DashboardFragment detects blocker controllers, it won't display
until:
1. All blocking controllers finish bg works.
2. Timeout

This CL adds UiBlockerController to control this behavior and
BlockingSlicePreferenceController as an example.

Bug: 120803703
Test: atest SettingsUnitTests
Change-Id: I66fc194776d46ee49b3ec7685f3167834e673ba2
2019-01-10 14:25:43 -08:00
Jason Chiu
a42a93bbfe Fix some pages crash after importing AndroidX from build 5175906
- Settings crash while entering Storage, Privacy, and Accounts page,
  because PreferenceGroup changed the API use from String#equals to
  String#contentEquals which doesn't support null keys.
- add a null check before calling findPreference

Test: robotest
Change-Id: I121cd9e4249fbdafbc67be65a09d770603e01044
Fixes: 121116425
2018-12-18 18:27:50 +08:00
Fan Zhang
ff47b303c4 Remove call to actionWithSource.
Switch to generic action logging call.

Bug: 117860032
Test: robotests
Change-Id: Ibd7c59ac0ec8a9fa1b368b40f0453a1b42071377
2018-11-12 05:32:13 +00:00
Fan Zhang
293883b2fe Report fully drawn when all settings are loaded.
We do not want to wait for contextual cards in app start
instrumentation, as user can already do everything in settings without
them.

Change-Id: I57d59aa3d623bf6911972ec310d558c25e44bf14
Fixes: 117494071
Fixes: 118495692
Test: perftest
2018-10-28 15:59:24 -07:00
Doris Ling
8741c04821 Add log when the advanced button is clicked.
- register the advanced button expand listener and add the metrics log
when it is clicked.

Fixes: 70930626
Test: make RunSettingsRoboTests

Change-Id: Ife4af4bd4a0a8534cf9ba63949660a810b09446a
2018-08-27 14:23:13 -07:00
Fan Zhang
64951163b8 Use getSummary() to get tile summary text.
Bug: 77600770
Test: robotests
Change-Id: Iecef09853bb49bc259502494912ed81d52e2d7ce
2018-08-20 14:13:14 -07:00
Fan Zhang
54cfb64987 Use tile.getTitle(context) to get tile title.
And switch to getId() instead of title when comparing 2 tiles. This is
more accurate and more efficient.

Bug: 77600770
Test: robotests
Change-Id: I587d90702d98956bf7b420529ac3280351ca4a10
2018-08-20 12:50:06 -07:00
Fan Zhang
7d5a9eebb8 Add a config to force rounded icon for DashboardFragment.
And each page has ability to turn on/off rounded icons. This CL only
adds the flag, it doesn't actually change icon shape yet.

- Boolean config in xml
- New protected method for each DashboardFragment to load config
- Plumb the boolean into DashboardFeatureProvider for future use.
- Remove some unused APIs from DashboardFeatureProvider

Bug: 110405144
Fixes: 79748104
Test: robotests
Change-Id: Id34782e75aa7289967e4dd1f4fe2978688092702
2018-08-10 10:57:18 -07:00
Fan Zhang
60243e6873 Remove custom tintable check.
Make a bunch keys private in tile and DashboardCategory
Bug: 77600770
Test: robotests
Change-Id: I4693e6bb71bd50cc664f578c7f8e25e67da20b67
2018-08-03 16:38:36 -07:00
Fan Zhang
9a1928ea36 Move profile selector dialog to Settings
Bug: 77600770
Test: robotest
Change-Id: I601dabfd925a1990b7bd9115ef579bff9039a7c0
2018-08-02 13:35:08 -07:00
Fan Zhang
1c61a58f0d Pass in context when loading icons from Tile
Bug: 111860183
Test: robotests
Change-Id: I836ad66eb420f4e0bd0bbded541f4dfe947c9b18
2018-07-26 13:09:25 -07:00
Fan Zhang
701b65eccc Use Tile.getIcon() to avoid caching issue
Bug: 77600770
Test: robotests
Change-Id: Icb21f5da9b542abc239b04b71813290ad3104ffb
2018-07-25 12:06:10 -07: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
d97fba5f0f Fork SettingsDrawerActivity in Settings.
Settings app uses fragment classes from android framework,
which is deprecated as of P.
We need to switch to use fragment and associated classes to androidx.

Because Settings didn't support drawer feature since Android O,
we rename SettingsDrawerActivity to SettingsBaseActivity.

Before we migrate to fragment of androix,
we need to let SettingsBaseActivity extend FragmentActivity.

Test: make RunSettingsRoboTests
Bug: 110259478
Change-Id: Ifbf53f75f042da1618da16cf7837b70d298a9a14
2018-06-28 13:38:16 +08:00
Fan Zhang
c7162cd24d Reorder and clean up imports.
Test: rebuild
Change-Id: I178485c84ae7146f991fd77b6d7504b029942a68
2018-06-18 15:45:09 -07: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
f7843adabd More renaming in DashboardFragment
getPreferenceControllers() -> createPreferenceControllers() for the same
reason as in ag/3647936

Bug: 73668763
Test: robotests
Change-Id: I97670a91a2a38d1c844d1b9d37f4222c5e6f45a0
2018-02-23 16:56:30 -08:00
Fan Zhang
917f101899 Instantiate pref controllers from xml if it's defined.
- If a <preference> tag also defines a controller, we will try to
  instantiate it before displaying the UI. The same logic is shared by
  BaseSearchIndexProvider so it also drives search suppression.

- If user also defines a list of controllers programatically, the
  programatically created ones takes precedence.

Bug: 73668763
Test: WIP
Change-Id: I7aecec270bcd3af261e012ef1f6995d2a523cfa1
2018-02-23 14:08:51 -08:00
Fan Zhang
b297abc1fe Minor cleanup in DashboardFragment: remove unused code
Bug: 73668763
Test: n/a
Change-Id: I95afbcf03987123e4ed8b76efbed299a7beb4448
2018-02-21 09:48:50 -08:00
Ben Lin
9275177002 Change underlying preferenceControllers to an ArrayMap of Lists.
Previously, DashboardFragment stores preference controllers in an
ArrayMap of <Class, AbstractPreferenceController>. Thus when there are
multiple controllers of same class (ie. multiple
PreferenceCategoryControllers), they cannot be stored simultaneously.
This changes the value to a List so we can store multiple controllers of
the same Class without extraneous sub-classing.

Bug: 70949662
Test: All existing tests still pass.
Added
DashboardFragmentTest#testPreferenceControllerSetter_shouldAddAndNotReplace
and DashboardFragmentTest#updateState_doesNotSkipControllersOfSameClass.
Change-Id: I397e8c91977ea1180d48a3af75dd4058bf1175c0
2018-01-03 17:03:59 -08:00
Doris Ling
bcb76351b3 Fix ConcurrentModificationException in SummaryLoader.
When the dashboard summary is being initialized, it will rebuild the UI
while the summary loader tries to to go through the tiles to update the
summary. Both is being done on a separate backgroud thread, and it will
run into concurrent modification issue if the thread is being swapped
while one is looping through the list.

Instead of letting clients access the list of tiles directly, add a
getter method in DashboardCategory to get a copy of the list of tiles
for all read-only operations.

Change-Id: I479669abd8d1d0a8ee9a4113d8ad2244da56f4d8
Fixes: 69677575
Test: make RunSettingsRoboTests
2017-11-28 16:43:07 -08:00
jeffreyhuang
bf234afbbb Speed up dev options
- Put memory updates on background thread
 - Prevent update state from being called twice

Bug: 69000975
Test: Manual
Change-Id: I186bc25f6b74a5098b1737891efee3a6855dc996
2017-11-14 17:05:25 -08:00
Fan Zhang
9679dba668 Convert EncryptionAndCredential into DashboardFragment
The logic still lives in fragment for now. They will be moved into
PrefControllers in follow-up changes.

Bug: 32953042
Test: RoboTests
Change-Id: I2b03d26b5f4e6bbb37b42f9dc83a9464eb169868
2017-10-31 14:39:52 -07:00
Doris Ling
8b14a1a7a6 Change to use the expand button in support lib.
- functionality for hiding portions of the preferences in the preference
screen is added to the support lib. So, changing the settings
implementation to use the feature from the support lib instead.
- remove ProgressiveDisclosureMixin and the related code

Fixes: 63985174
Test: make RunSettingsRoboTests
Change-Id: Ib1d39b2db93d78a56c7adf90abcae5226f9564c2
2017-10-27 13:16:38 -07:00
Doris Ling
ed4685fafb Update activity titles for fragments without preference screen.
1. Move getPreferenceScreenResId() from individual subclass to
InstrumentedPreferenceFragment.

2. Removed InstrumentedPreferenceFragment.getTitle() and let the
preference fragments that do not have preference screen set the activity
title directly instead.

3. Removed OptionsMenuFragment as all it does is call
setHasOptionMenu().
- changed subclasses of OptionsMenuFragment to extend from
InstrumentedPreferenceFragment directly.
- none of the exisitng subclasses actually implements the option menu
related methods to provide any option menu. So, the setHasOptionMenu()
call is not added to the subclasses.

4. Update Languages preference title.
- launch the fragment from the preference controller instead of from the
default handling, as we need the title res id at launch time to get it
work properly when retrieving the title from back stack.

Bug: 64564191
Test: blaze-bin/screenshots/android/i18nscreenshots/i18nscreenshots
Change-Id: Ibecdcab32cbaed8bf604ec5ebe0a926b4e489a7d
2017-10-26 12:01:06 -07:00
Fan Zhang
1f92faad27 Merge "Don't attempt to tint icon if icon is not available" into oc-mr1-dev am: 90f9398f4e
am: ed71e21541

Change-Id: Ic2f5d6c35ac8bb7a14d1949be53beb6b6bf4cd16
2017-09-08 22:23:19 +00:00
Fan Zhang
1ca6b25321 Don't attempt to tint icon if icon is not available
Change-Id: I0aa2a17d51d966dce182381c7bba8913ad997738
Fixes: 65460834
Test: robotests
2017-09-08 00:10:55 +00:00
Fan Zhang
26a1deffe6 Support dynamic summary and icon for injected tiles
Bug: 63758074
Test: robotests
Change-Id: I2fa27812800c12606a613896ea2aa69dda393944
2017-08-01 16:19:37 -07:00
Doris Ling
7087fd92a1 Check the tintable metadata before tinting tile icon.
When determining whether to tint the tile icon, first check whether the
tintable metadata set for the tile. If no metadata set, will then follow
the default logic that tint the tile icon if it is not coming from the
Settings package.

Change-Id: Idf0863e0c6ab063aeaa6d013fa620508ced31fdb
Fix: 62473193
Test: make RunSettingsRoboTests
2017-07-18 10:39:47 -07:00