Commit Graph

108 Commits

Author SHA1 Message Date
Mill Chen
d4eecf6132 Guard slices from being requested by guest user
According to patch of A-231987122, AOSP restricts app to modify relevant
mobile settings when user is a guest. This change intends to prevent the
slices related to mobile settings from being requested by guest user.

Bug: 278616139
Bug: 277333776
Bug: 262244832
Bug: 278616520
Bug: 278615120
Test: robotests
Change-Id: I4dc4bbfdb5cf76e188e6f62ebfd74ef6fa2fe33b
2023-06-15 14:29:01 +08:00
Edgar Wang
fae664c79c Reducing slice requesting logging
Bug: 253684322
Test: rebuild
Change-Id: If0e884875e09bd43b88f6b5f205ad450de488552
2023-05-03 17:04:38 +08:00
Xuanang Zhao
cc64ca6606 Prevent the load of the slice again if it is already
in the cache.

loadSlice just fills Slice read from the DB into a
map, if there is already such slice in the map, we
could skip the async load process.

Change-Id: I6e96ef72a9dc5a833ae158492134f4a6c94a7465
Bug: 249101421
Test: robotest
2022-10-12 08:32:06 +00:00
Xuanang Zhao
b28a8a4634 Add HINT_PARTIAL to stub slice.
Change-Id: Idc0847828063afe708b69a5b0a1178b9729a5b5b
Bug: 249101421
2022-10-11 10:42:34 +00:00
Xuanang Zhao
98f7b2b227 Clean the slice in onUnpinned rather than onBinded.
Change-Id: Idda7cbedb0ce7b0ec83fc2f11a2505634d2b465c
Bug: 249101421
2022-10-11 10:35:31 +00:00
Chaohui Wang
6c9da58f4b Clean up unused Sliceable.copy()
Sliceable.isCopyableSlice() is not set to true for any controller, so this function is not used.

Usage is removed in Change: I81474aed994678c42d73cc59e169573880de1378

Bug: 227722942
Test: robotest & manual
Change-Id: I86e23aa8ad43f60b5017ff0a278e20e3f727706c
2022-04-02 19:16:22 +08:00
Jason Chiu
f0248e096e Add logs for tracking Slice provider startup
Bug: 191555397
Test: build, manual
Change-Id: Ic95fb0a7a8ba30f7802111a7a453fb73f4c918fe
2021-07-21 03:48:03 +00:00
Yi-Ling Chuang
843616eb69 Add the mutability flag for SettingsSliceProvider
Starting Android S, all PendingIntent should have the mutability flag
assigned to prevent from vulnerability.

Fixes: 172811605
Fixes: 172206649
Test: 1. Play on the slices in Settings search.
2. Make a permission request intent of Settings wifi slice in the
slice-viewer app, clicking on it and make sure it gets redirect to
Settings without crashes.

Change-Id: I86f915bc062a6e632b5ca9c74e232db1036f08de
2021-01-07 16:00:08 +08:00
Jason Chiu
2c7b77dad7 Fix the ANR in panel when changing volume continuously
When users open volume panel and keep on changing the volume slider for
a while, the panel starts to defer the slider updating, and finally gets
stuck and causes an ANR.

Root cause:
Volume panel has four volume adjusting slices. Each of them registers
a broadcast receiver to listen to the volume changed and muted events.
However, when the media volume changes, AudioManager will send four
broadcasts (music, assistant, accessibility, tts) to every receiver, and
each of them will reload slice four times. Thus, one media volume
changed event will lead to 16 (4*4) UI updates. Consequently, keeping on
sliding the volume bar will trigger hundreds of broadcasts and UI
updates, which makes the system busy and getting stuck.

Solution:
Introduce a VolumeSliceHelper to integrate the broadcasts of the volume
slices specifically.
1. Only register one broadcast receiver to reduce the broadcast loading
   since the four slices are listening to the same signal.
2. Filter the only one eligible broadcast among the multiple concurrent
   ones, and then relay it to the registered slice.
3. Listen to one more action STREAM_DEVICES_CHANGED_ACTION to update the
   volume panel when audio output device changes.

Test: robotest, visual
Bug: 144134209
Bug: 160489394
Change-Id: I780b9eee35802b19a5f0ab0a7d07bd3e081f5556
2020-09-03 14:12:10 +08:00
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
8829e515ca 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: Ibe64a68d7bddf84780dfac33555c097ff55c97a8
2020-07-30 12:54:27 +08:00
Jason Chiu
2e0758f7ae Decrease memory usage for sleep idle test
Postpone setTheme to decrease memory usage of Settings for the test
android.platform.test.scenario.sleep.Idle

Bug: 156631776
Test: forrest test
Change-Id: I4178eae0832e15c9d6da4a0f1f2898f5c797d388
2020-06-22 02:43:10 +00:00
Jason Chiu
0625bb4815 Fix the overlapping problem of the burst of slice updates
Implement a throttle in SliceBackgroundWorker to control slice updates.

Test: robotest
Fixes: 152366832
Change-Id: I8b65d1b57973e036b932172627aca506f4fae3a4
2020-06-18 02:18:38 +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
Julia Reynolds
aceccce75c Reorganize notification Settings classes
The notification package was getting too big.

Test: make -j64 RunSettingsRoboTests
Fixes: 145224451
Change-Id: I25ba82f42f7a137d8adcce72dcf8089d0e018bdc
2019-11-27 10:02:13 -05: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
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
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
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
Fan Zhang
2fe7e9fc45 Refactor CustomSliceManager.
- Make everything that can be static, static.
- Also removed a unused slice for battery info.

Next step - going to make CustomSliceManager into a regular class
instead of getting it from FeatureProvider. This way it's no longer an
application level singleton, then we can do things like attaching
lifecycle to it. It will be easier to deal with "session" based use case
after the refactor

Bug: 123937830
Test: manual
Change-Id: I384761a6894fa907f72a3610437835c4dd4d1944
2019-03-12 16:42:12 -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
Fan Zhang
45f961b624 Move some slice related api out of BasePreferenceController
And share with CustomSliceable.

Bug: 121150258
Test: rebuild
Change-Id: Ia5aed9c156fb168c1f001da6e37f7f12f191b385
2019-02-15 14:21:10 -08:00
Fan Zhang
1031901867 Move registered slice set from settings to settingslib.
Bug: 121150258
Test: robotests
Change-Id: I32263de9a755e8902c820fda36096b821a293bcb
2019-02-14 15:16:53 -08:00
TreeHugger Robot
dd1c68b12d Merge "Remove intent-filters from SettingsSliceProvider" 2019-02-12 00:43:03 +00:00
Fan Zhang
671a39f905 Remove intent-filters from SettingsSliceProvider
And remove unused methods from SliceDeepLinkSpringBoard.

This is part 1 of b/110156445

Bug: 110156445
Test: atest
Change-Id: Iab36a97332fd847ed911a9e34b505fd4a64522d3
2019-02-11 15:01:10 -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
d7fa2fa64e Make a few custom slices implement CustomSliceable.
Bug: 80263568
Test: robotests, slice-browser
Change-Id: Id809a347d77448917154c2d1144fd2517e70829a
2018-12-05 15:47:14 -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
Matt Fritze
90899e08f0 First commit for settings panels
Establish the Activity which hosts Settings panels through the
PanelFragment. The Activity's purpose is to validate the intent
data coming in, including:
- Called with startActivityForResult (so we can log who is calling)
- Intent has the proper intent extra to link to a Panel

The fragment takes the Panelable data and builds a Settings Panel.
Each panel will have:
- Title
- List of Slices
- Link to underlying content

The Panelable interface is created to provide all of those datums, and
the new FetureProvider provides the Panelables by linking them with
keys. The keys will eventually become public APIs with CTS tests.For
now, we store them locally.

I included an exmaple panel, the InternetConnectivityPanel which
currently shows Wifi and Airplane mode.

Screenshot: https://screenshot.googleplex.com/c6sv7ZzQ5OJ
Bug: 117804089
Test: make -j40 RunSettingsRobotest
Test: Manual app
Change-Id: I1932f7179cc32088acd6413a736901ddf9651892
2018-11-26 15:26:02 -08:00
Stanley Wang
5d2a3d23e7 Merge "Architecture review of Copyable Slice" 2018-11-06 05:00:05 +00:00
Stanley Wang
51c9404182 Architecture review of Copyable Slice
Design doc: https://drive.google.com/open?id=1NJPd_282H4195HUGJH5cGJO_Jrcz1Vl6AAw_VQOtGq0

Fixes: 	118398321
Test: manual
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.slice

Change-Id: Ic6762e58698a994d16a5de1778b4035ae430a256
2018-11-06 11:01:17 +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
TreeHugger Robot
19e640701e Merge changes Idbb63960,Id7889566
* changes:
  Delete some unused resources
  Move all contextual card related classes.
2018-10-26 19:18:19 +00:00
Fan Zhang
5e6e6a14f2 Move all contextual card related classes.
... from homepage to contextualcards.

Test: rebuild
Change-Id: Id7889566ce1e7257eb699d963ae996906fdb58ff
2018-10-26 10:02:04 -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
0accca2cb6 Merge "Slice background worker with Wi-Fi Slice" 2018-10-19 20:23:05 +00:00
Jason Chiu
f17233ba7d Slice background worker with Wi-Fi Slice
Test: manual

Change-Id: Ic4fdc5713f511ff80f03728c99c68fda3d0cab02
2018-10-18 18:00:11 +08:00
Sunny Shao
0057c4127c Added the EmergencyInfoSlice for ContextualHomepage
- Generated a simple EmergencyInfo slice with fixed string in title and summary.
- Moved hardcode string into strings.xml
- Modified the contentProviderCall_returnCorrectSize test case for general version

Bug: 114793520
Test: compile and manual test
Change-Id: Ia3444c61b0f7e4c04794fe3590dc0731885cf062
2018-10-18 14:10:13 +08:00
jackqdyulei
8eec6ff917 Change packagename to telephony
Also move it under package network, so all of them belong to
com.android.settings.network.telephony.

Bug: 114749736
Test: RunSettingsRoboTests
Change-Id: I35dbdcd5cc9dab939b0a3efccc8897b9a92338d1
2018-10-11 11:46:38 -07: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
Matthew Fritze
e8d66bb783 Hide SettingsSlice provider
Explicitly set the Settings SliceBroadcastReceiver to
be non-exported and remove the intent-filter.

Add a second provider: SliceRelayReceiver to receive
broadcasts from SysUI to alert Settings to potential
changes to bound Settings Slices. The new receiver is
exported, but only notifies changes to Settings, and
doesn't make any changes itself.

Change-Id: I80d070f7636614135ebe4f57a16f12a3eb6dee81
Fixes: 111330641
Test: boot, robolectric, Slicebrowser
2018-08-15 15:17:02 -07:00
tmfang
41ab6b4bf8 Migrate all AlertDialogs to AndroidX version
This CL only changed AlertDialog imports.
So, reviewer can review it easily.

Change-Id: I097bc44394195b14287f4f920c570ac8653f356a
Fixes: 111413092
Test: This CL can't pass Robo test.
2018-07-20 11:32:13 +08: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
Fan Zhang
c7162cd24d Reorder and clean up imports.
Test: rebuild
Change-Id: I178485c84ae7146f991fd77b6d7504b029942a68
2018-06-18 15:45:09 -07:00