Commit Graph

53 Commits

Author SHA1 Message Date
Edgar Wang
a8742aa7ab Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Test: robotest & manual
Change-Id: Ia8625091a107fc3fb652d3ba3f75ea3cc1a8d9f5
2020-08-12 11:29:07 +08:00
Edgar Wang
c2e4513fb6 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Test: robotest & manual
Change-Id: I36829e0055437dab79d9e5339ac002a87a4b874f
2020-08-04 18:12:48 +08:00
Jason Chiu
98a8640de2 Fix failed test cases
Test: robotest
Fixes: 159688624
Change-Id: I28d53e38000d2dfb00bde900647eb38eda279c9a
2020-06-24 10:55:31 +08:00
Jason Chiu
8ac1e4d49d Update icon tint color when the user toggles Dark theme
- Reload theme in slice provider when Dark theme mode changes for slices
- Reload theme in onCreate of Panel activity for its non-slice header
- Remove applyTheme from individual slices

Test: robotest
Fixes: 153700819
Change-Id: I40a7d2817c4b9100d7b2f2962a69c8a9ce6f7906
2020-05-12 10:58:54 +08:00
Tsung-Mao Fang
2fc9fed89c Fix pendingIntent in SettingsSliceProvider could be Hijacked
A malicious app is able to obtain this pending intent.
It can then mutate all fields except for the action and
launch the intent. This can be used to launch any activity
with the ACTION_SETTINGS action.

So, we enfore assign the package name for this intent,
it only can launch the settings app.

Fix: 147355897
Test: a) Install the new settings apk, and it won't launch other screen.
(See details in bug)
b) Start the settings search, slice search results work as normal.

Change-Id: Ie954d8a4b7153d6a4cac40621f363b45185990f2
(cherry picked from commit b3c0a2a6c1)
Merged-In: Ie954d8a4b7153d6a4cac40621f363b45185990f2
2020-03-05 05:38:55 +00:00
Yi-Ling Chuang
d57e5a5d1a Add the impl for the ability to query non-public Slices
Apps get Settings Slices through onGetSliceDescendants(), so adding some
codes here to make us be capable returning non-public Slices. As these
SliceData come from slice_index.db, where SliceDatabaseAccessor is the
middleman for us to access those data, so adding a parameter in
getSliceUris() to determine what data should be returned.

Bug: 141088937
Test: robotests
Change-Id: I411eb1ff194b7c8915b9e7309c684046dbde29fb
2019-11-26 17:06:15 +08:00
Raff Tsai
85e1218b31 Add wifi calling slice to settings search and AGSA
Fixes: 121041498
Test: test if wifi calling slice is appeared in Settings Search
Change-Id: I4892da6e7d396f28bb232f8e520a8c946f35570d
2019-07-12 23:40:27 +08:00
Fan Zhang
d71835125a Clean up ShadowTheadUtils.
Individual tests don't need to specify it in their own @Config

Bug: 135698296
Test: robotests
Change-Id: I66dc0bfdaec9c6cac9b48f3e7906f71dfb3a6b28
2019-06-20 15:17:42 -07:00
Fan Zhang
13cf250be5 Remove "platform_slice" attribute from Settings.
Bug: 126222433
Test: robo
Change-Id: I05beec7d3e3ec713c40740a1adbcacaee88237b5
2019-06-10 14:05:43 -07:00
Fan Zhang
aa08a2cc0e Use slice uri from slice index db directly.
During SettingsSliceProvider#onGetSliceDescendants, use the uris from
database directly instead of getting the key and construct the uris
manually.

Bug: 126222433
Test: robotest
Change-Id: Iad4e9fc28ec4442b6bb323878503d743582b35ac
2019-05-31 16:03:33 -07:00
Fan Zhang
f36ca50ec7 Add slice uri to slice index db
And slightly refactored the SliceDataConverter to remove 1 reflection.

Bug: 126222433
Test: robotest
Change-Id: Ic5782bdd71f5c9cb77879a35de81dc61c01d1912
2019-05-30 16:47:31 -07:00
Matthew Fritze
2bdea1d922 Prevent bad apps from getting Setting Slices
SettingsSliceProvider no longer allows apps to request permission
from the user for Settings Slices. Instead, the PrimaryAction on the
permission slice will be an intent into Settings.

This is because the dialog for granting apps Settings Slices would act
as a replacement for regular permission dialogs, which we want to avoid.

Fixes: 130795282
Test: robolectrico
Change-Id: I6848215bab2bf10ee5e53814b765d04f04f53f4e
2019-04-18 08:51:17 -07:00
Jason Chiu
53d147dd5c Refactor WifiScanWorker
Extracted WifiScanWorker from WifiSlice

Bug: 128056349
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.wifi
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.slices
Change-Id: I9b3c809ee6c2b7466c959631840b257b91b49d88
2019-04-01 16:40:59 +08:00
Fan Zhang
a8291be3a9 Clean up the hard cache in SettingSliceProvider.
It doesn't need to be a map.

Bug: 129002750
Test: manual
Change-Id: If784dfe4fb497414a04dc5fa8c8374731539d8ed
2019-03-21 14:12:38 -07:00
Fan Zhang
4cb2727989 Tie ContextualWifiSlice to UI instead of garbage collector
- Introduce a static long in SliceFeatureProvider that updates once
  every "session". A session is when user is in an UI (screen rotation,
  going to subpage, etc does not break the continuation of session).

- Use session token in ContextualWifiSlice to determine when to refresh,
  instead of relying on WeakHashMap from CustomSliceManager.
  WeakHashMap can be cleaned up at any time by gc so it doesn't match
  what we want on the UI.

- Also as a side fix, merged CustomSliceManager into
  SliceFeatureProvider.

Fixes: 123937830
Test: robo
Change-Id: I199bceceb208b99a32f3f08e624787b5a03e73a9
2019-03-14 14:45:59 -07:00
Matthew Fritze
9e50419c75 Remove NFC Slice jank
The NFC Slice would jank on enable and disable, because of the
intent filter it registered with SysUI. The intent filter would
broadcast an update for four states:
1) On
2) Off
3) Turning On
4) Turning off

The first two caused no problems. The third and fourth caused jank,
since when clicked, the switch in the NFC slice would turn on / off
asynchronously - that is, it turned on or off based on the previous
state of the switch, rather than on the actual value of NFC. It does
this to feel fluid in the app in which it is rendered.

From the off state, the order of events is:
1.  Switch clicked
2.  Switch animates on
2.  Background intent is fired to settings to turn on Nfc (happens at
       the same time as animation)
3.  Settings calls the NFC enable API
4.  A broadcast for Turning On is sent
5.  The receiver in SysUI gets the broadcast and forwards it to settings
6.  Settings tells the Slice to make sure it is up to date
7.  The Slice checks for the current value - IMPORTANTLY - which is
        currently off, it is only in the process of being enabled.
8.  The Slice flips back off
9.  Nfc finishes getting enabled in the background
10. The framework pushes the NFC ON broadcast
11. SysUI gets the broadcast, and forwards it to settings
12. Settings tells the slice to update
13. The slice checks again and finds that NFC is on, flipping on.

This CL creates a new background slice worker for NFC and registers
the intent filter there, rather than in SysUI. When the background
worker gets the broadcast, it checks if it is in state 3/4, and if so,
it drops the update silently.

Fixes: 115737701
Test: robotests
Change-Id: I17043828ad3a67a2a5acdf5c75d9cc51ff7e91d0
2019-02-26 08:20:38 -08:00
TreeHugger Robot
d611df7c48 Merge "Misc ui tweaks." 2019-02-13 02:15:54 +00:00
Fan Zhang
07207c0113 Misc ui tweaks.
- Update conditional card layout
  - move action button from right side to bottom.
  - Get rid of the forking between small/big screens.

- Update a few icons

Fixes: 121189136
Fixes: 124315564
Fixes: 124316920

Test: visual
Change-Id: I205d9995a2d7ed06ad9d32f3cea74f2840a28aed
2019-02-12 16:14:21 -08:00
Matthew Fritze
1138218abe Create special case mobile data slice
Build the special case mobile data slice for general use,
and for the Internet Connectivity Panel. The Slice controls
the default data subscription, and links to the subscriptions
page.

Bug: 117804089
Fixse: 119411534
Test: robotests & test app.

Change-Id: I31b524a8fe3182a244d940848090e97250632f39
2019-02-08 13:13:28 -08:00
Fan Zhang
0db4ead2b3 Hide wifi card sometimes.
When there is a connected wifi, we now hide the wifi slice card.

However, if we initially shows this card but later wifi is connected
while the card is visible, we keep showing this card to avoid janky
animation. The card will be gone if user nagivates to a different UI and
comes back.

- Create a new slice ContextualWifiSlice for homepage use case, all
  special logic for homepage are added here.
- Change reference for WIFI_SLICE to CONTEXTUAL_WIFI_SLICE where make
  sense.

Change-Id: Ibd87f88058f357aabef0f7d68a5bf48350d75b06
Fixes: 121040746
Test: robotests
2018-12-18 10:18:08 -08:00
James Lemieux
f1dade40d2 Use binary resource support in robolectric
The resources available to tests are now exactly the merged resources
located in the APK under test.

Bug: 74359828
Test: make -j56 RunSettingsRoboTests
Change-Id: I050db81a92decefea23314b5ec7a62f77ff4bb2b
2018-12-12 19:53:49 -08:00
Fan Zhang
53f75f0df9 Move all custom slice uris to a registry class.
Change-Id: I192320f95ac81d14c8891ce2531d603912e59f56
Fixes: 119776308
Test: robotests
2018-11-29 16:41:21 -08:00
Jason Chiu
a68f81540e Enforce all the SliceBackgroundWorkers being singletons at syntax level
- Create workers via reflection in SliceBackgroundWorker
- Store the workers in a static container and release then at shutdown()

Fixes: 118228009
Test: robolectric
Change-Id: I564277d3a12b2d7d3b50cef091bdfedb3397c145
2018-11-05 21:41:30 +00:00
Fan Zhang
cdf284b732 Make Settings robotest work with tot Robolectric
Bug: 116278591
Test: make -j RunSettingsRoboTests
Change-Id: I32cb2fcf6094675f79d2fc24702ef6298a9691e4
2018-10-31 17:59:17 -07:00
Jason Chiu
89b15785c7 Fix crash on Wi-Fi Slice when it's continuously pinned and unpinned
It's because WifiTracker's initialization and onStop is on different
thread. Fine tune the thread logic in SliceBackgroundWorker.

Fixes: 118165942
Test: manual
Change-Id: Icc86b5df7ec3c6fd0e4a79a62ea0c84465e9528d
2018-10-26 18:47:51 +08:00
Jason Chiu
f17233ba7d Slice background worker with Wi-Fi Slice
Test: manual

Change-Id: Ic4fdc5713f511ff80f03728c99c68fda3d0cab02
2018-10-18 18:00:11 +08:00
Fan Zhang
d480c0e41a Grant permission on slice uris based on whitelist
Bug: 112587202
Test: robotests
Change-Id: I4e12a73f0acd848153f32c2569358dd55bed3f92
2018-08-28 18:13:25 -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
Matthew Fritze
7f0a30226a Refactor WifiSlice to CustomSliceManager
Modify the WifiSliceCode to follow the pattern for
Slices that do not match existing UI components.

Test: robotests
Bug: 80263568
Change-Id: Id69e019608777282f4b64ff945e8c30c97aaf577
2018-08-20 08:03:34 -07:00
Jason Monk
fee23c456a Follow slice API finalization
Test: build
Change-Id: I5671b180a949d5038f9a73caf84a6d266ef90cfa
2018-08-09 17:03:33 -07:00
Matthew Fritze
56b2bad05e Handle special case slices
Create a handler for any slice that doesn't include anything
from a PreferenceController.

Test: robotests
Change-Id: If23947152d61877537d0cac6240e96b9ab977bce
Bug: 80263568
2018-07-09 11:21:25 -07:00
Steven Wu
97915b15d9 Add a flashlight slice in settings.
- It retrieves the flashlight status from Settings.Secure.
- It uses the broadcast relay to update flashlight status
without action on the slice.

Test: robotests
Change-Id: Ib4d636541f5166b8634326cce76aed5665989b76
Fixes: 74913192
2018-06-06 02:59:37 +00:00
Fan Zhang
934de22622 2nd attempt to fix Slice strict mode.
1. Use real BluetoothAdapter instead of settingslib version. The
   settingslib version contains calls that violates strictmode rules.
2. Override StrictMode rules in SettingsSliceProvider when it's called
   in background thread. When in background, the enforcement from Slice
   framework (StrictMode#ThreadPolicy) is not useful and can be safely
   ignored.

Change-Id: I68523148f4c1dc88a54e207447d21ec439478cdf
Bug: 79985175
Test: robotests
2018-05-25 10:39:59 -07:00
TreeHugger Robot
a60ea38f67 Merge "Hook up blocked keys" into pi-dev 2018-05-23 20:41:22 +00:00
Matthew Fritze
4242ed2171 Hook up blocked keys
Block any slice in onBind that is the in the blacklist

Change-Id: I9687d07cbfef5fcb94842046bc5dc3296eed4252
Fixes: 80195653
Test: robotests
2018-05-23 12:25:23 -07:00
Matthew Fritze
e31e60ce94 Add Location Slice
Location is an intent-only Slice.

Test: Robotests
Change-Id: Ie9ed05be2224f2c4b393ed201d5f313f80183edc
Merged-In: I07e27683b46fe4ded8215009a983bb909555fb59
Fixes: 67997314
2018-05-23 08:09:07 -07:00
Matthew Fritze
25fc14c607 Add Bluetooth Slice
Bluetooth slice is added a special case, due to the migration of
bluetooth to a Switch Bar instead of a preference with a controller.

Change-Id: I8b70bb66c862255a4e8d2426ac09939ba6197624
Merged-In: Icfdcd77601ad1e64e0f6c352a8d691f0181515c8
Fixes: 67997327
Test: robotests
2018-05-22 06:59:49 -07:00
Matthew Fritze
4a6f058552 Add Intentfilter BasePreferenceController
For settings which can change in the framework, outside of
the settings app and a slice, a Slice needs to be able to
register a listener for these changes.

Adding a getter for an IntentFilter in BasePreferenceControllers
allows us to use the SliceBroadcastRelay in SysUi to listen for
these changes.

Test: robotests
Fixes: 78138654

Change-Id: I579375069ca98fd21b60cd3a69c1a122cabf96e2
Merged-In: Ifa05b651aaa3458c54866f71469964b1a070e458
2018-05-18 08:06:08 -07:00
Matthew Fritze
e8b62714af Add DnD as a special case Slice
Add DND Slice as a special case, since there is an existing
inheritance structures in the zen mode preference controllers which
would be too risky to change at this point in the release.

Change-Id: If4b7013be35c89695786af2dbbea2edcf7a189f3
Merged-In: Ice608b9a7bd6f38b73e581eb3723f0a2fae96f2b
Test: make RunSettingsRoboTests
Fixes: 67997377
2018-05-17 18:20:36 -07:00
Matthew Fritze
46aa586610 Add Wifi Slice
Add a custom Wifi Slice to the Settings Slice Provider.
It needs a custom Slice because of the complicated listener logic
in the MasterSwitchPreferenceController, which makes it hard to
work-in synchronous set/get logic.

The one-off Slice requires extra changes, including:
- Including it in getDescendants
- Handling changes to wifi by the framework

This is the first change that uses SettingsLib's broadcast relay,
which allows settings to (un)register IntentFilters to a Uri,
allowing Settings Slices affected by the framework (quicksettings,
connectivity related, volume, etc) to be updated without action
on the Slice.

Fixes: 70622039
Fixes: 67997332
Test: robotests
Change-Id: Ia76738dd6baacd5522d52df2c61ebad86a600282
Merged-In: Ibfe4736beecb833e3f6bb871b2eb5228a5fd3a34
2018-05-17 09:58:19 -07:00
Fan Zhang
4ca363470b Fix a strict mode violation in SystemUpdatePrefController
Change-Id: I4770b878b6f69318f08f8974c5c4d2690c5611d4
Merged-In: I4770b878b6f69318f08f8974c5c4d2690c5611d4
Fixes: 78626509
Test: robotests
2018-05-11 00:32:01 +00:00
Fan Zhang
66156d68e7 Fix a typo in AndroidManifest.xml
And some drive-by clean up.

Change-Id: Ic036f8f5bec8064a5d55e0e032ce45e483323b14
Fixes: 78889604
Test: atest
2018-05-09 18:06:27 -07:00
Jason Monk
4913183def Fix settings slice caching
Previously if there were multiple clients it would trigger an infinite
loop as the cache gits dropped after the first bind, and the second
client would trigger another load. Instead now cache as long as slices
are pinned since thats the intended behavior of caching.

Test: make RunSettingsRoboTests
Change-Id: I7d29fab87573120b34cd55e1696c4c5b70fc891c
Fixes: 78471335
2018-04-24 17:08:26 -04:00
Matthew Fritze
6730a061b1 Add getDescendants to Settings Slice Provider
getDescendants allows another app to collect a list
of all valid Uris for Settings Slices. Important for search,
assistant or launcher apps.

This means searching our database for all valid keys and building
a list of Uris for each of those keys.

Fixes: 77808328
Test: robotests
Change-Id: I3ae27e4661a7dcaab50b091ae2730013118af8a2
2018-04-17 10:48:53 -07:00
Matthew Fritze
79c6395295 Index SliceType and Official Platform flag
Extend slices_index.db to include SliceType and platform flag.
This will be used when we generate a list of all available slices
for different authorities & separated intent/action paths.

Bug: 62807132
Test: robotests
Change-Id: I1cce49d077c02ab79153db9bfdfc894dbab5e16a
2018-03-19 14:51:31 -07:00
Alan Viverette
4734b3448a Restore "Update for 1.0.0-beta1"
This reverts commit b4fe52343c.

Bug: 74950017
Test: manual
Change-Id: I9749b9ae8f2f75b1bbdf7c6686a036db1f6f8a74
2018-03-16 02:13:11 +00:00
Alan Viverette
b4fe52343c Revert "Update for 1.0.0-beta1"
This reverts commit 6b1fd5cfa9.

Reason for revert: broke Settings

Bug: 74950017
Test: revert only
Change-Id: If56a4dcac4671d8e2c5f2c0de30d13e3cf58666a
2018-03-15 18:48:00 +00:00
Alan Viverette
6b1fd5cfa9 Update for 1.0.0-beta1
Bug: 74449147
Test: make
Change-Id: I664b5f29efbb5d6c40420c0d8aaa8629ddfcd31b
2018-03-12 23:08:35 +00:00
Matthew Fritze
a4a3dfffa2 Declare official platform slice
Create the notion of an official platform slice.
This includes:
- Adding a second authority to the provider
- tagging slices in xml with a platform slice flag
- Including authority in the getUri method

Bug:73359139
Test: robotests
Change-Id: I5382be138a262dbc5a8324c34aab131c5d0d5516
Merged-In: I581ee6dfcdf935f452a15e89e5d055e375ff1877
2018-03-09 18:04:06 +00:00
James Lemieux
22a39c2b93 Use external/robolectric-shadows/run_robotests.mk
This allows Settings to test against the latest framework changes.

Also replaced TestConfig with traditional robolectric.properties.

Bug: 73173204
Bug: 73892008
Test: make -j56 RunSettingsRoboTests
Change-Id: I3135b4fa5f095ba79b282a76f45dd9baa2584bc7
2018-03-04 03:50:08 -08:00