Commit Graph

37 Commits

Author SHA1 Message Date
Fan Zhang
a6c7db1888 Update logging: switch a bunch of action() logging calls.
Use generic action(int, int, int, String, int) instead of
action(Context, int, string, Pair...) when possible.

Bug: 117860032
Test: robotests
Change-Id: I5213b52b2b10d80a3c488c37718df81b3b0a428f
2018-11-13 21:50:34 -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
Fan Zhang
f535055e2e Use safe icon when building unavailable slices.
And move ic_a11y_generic from mipmap to drawable. IconCompat doesn't
support mipmap.

Bug: 118691898
Test: robotests
Change-Id: I6799f3d31d2c5654319e5a97bf8ca14992e785a7
2018-10-30 14:48:47 -07:00
Mill Chen
2559f02d68 Clean up unnecessary spy context statements
Remove spy context syntax because we do not need to
mock context anymore in the test cases.

Bug: 117644158
Test: robotests
Change-Id: I222eec4fbc1994d7bb79adead40b76ac0a000bdc
2018-10-12 21:54:02 +08:00
Mill Chen
fdf06e242a Remove mocked resources from slice test cases
Clean up some resources which are useless for the moment.

Bug: 117485451
Test: robotests
Change-Id: Id3591178791cc6c9f628a99a8916e9007a399728
2018-10-09 23:25:44 +08:00
tmfang
8eb46b717e A new attribute which can show the dynamic summary
For now, slice view shows screen title by default,
but it isn't approprate for some simple cases.
ie, device model, phone number, android version etc.

So, We create a new attribue which let BasePreferenceController
be more flxible. User can choose what they want to show
in summary text.

Fixes: 74900516
Test: make RunSettingsRoboTests

Change-Id: I2788c6edfaf8e656170a507607f22513841a3e0a
2018-09-26 17:48:12 +08: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
Jason Monk
fee23c456a Follow slice API finalization
Test: build
Change-Id: I5671b180a949d5038f9a73caf84a6d266ef90cfa
2018-08-09 17:03:33 -07:00
Matthew Fritze
c38f7e1d0a Add a back-up icon resource to icon-less Slices
Currently, when a Settings Slice dosen't have an icon, we add an IconCompat
object with the resource 0x0 - which gives an empty icon. This is from the UX
direction that we should only have icons for Settings Slices when the
corresponding Settings have icons in the Settings UI.

However, this causes an issue with a recent change to SliceView, which crashes
the UI when a Slice is rendered without an icon. Previously, the icon code path
was only exercised when the Slice Shortcut view was being used, but after the
change, the icon path is always used and thus crashes when trying to fetch a
resource with id 0x0 from Settings or another provider.

About 2/3rds of Settings Slices do not have icons.

This change adds the Settings App icon as the back-up icon for any Slice which
would otherwise not have an icon.

The impact of missing this change is:
- Settings Slices cannot be shown in launcher spaces until a post-P update comes
from the support library.
- If Settings launches with the bug, Slices cannot patch the API which would require
all Slices to have a non empty icon (b/111438616)

Bug: 111082093
Test: Robotests, Settings Search UI testing, Slice browser testing
Change-Id: I6f326b6b41bf59011a211c6340dd639f68e754e1
2018-07-16 15:34:24 -07:00
Fan Zhang
c7162cd24d Reorder and clean up imports.
Test: rebuild
Change-Id: I178485c84ae7146f991fd77b6d7504b029942a68
2018-06-18 15:45:09 -07:00
Matthew Fritze
417693021e Return null when setting can't be changed.
If a Slice cannot be changed, return null instead of
an error slice.

Bug: 80155832
Test: robotestst
Change-Id: Ib94136c449c6d9c1911f89833bba62fd2263daa4
2018-05-22 20:17:10 -07:00
Matthew Fritze
f9c13fc305 Set slice summary text to screentitle first
To improve context on search surfaces where the
setting may be ambiguous, we set the screentitle
as the summary text as the top priority. If there is
no screentitle or the it matches the title, then we
try to use the controller summary. If the controller
summary is not valid, then we show nothing.

Bug: 79780762
Test: robotests
Change-Id: If4f7f8d4a072125604ede14e3df2afd667fa24b7
2018-05-16 08:13:22 -07:00
Matthew Fritze
bd376296cd Establish permanently unavailable settings
Distinguish between settings which are permanently unavailable on
the device, and temporarily unavailable. This enables us to restrict
which setting slices are exposed in onSliceGetDescendants.

The primary changes in this CL are renaming:
"DISABLED_UNSUPPORTED" -> "UNSUPPORTED_ON_DEVICE"
to be more clear the the setting will cannot be accessed on the device, and,
adding a new enum to encapsulate settings which are currently unavailable, but
could be enabled in the future.

Also remove UNAVAILABLE_UNKNOWN. Devs should never need this enum.

Bug: 78910582
Fixes: 79245656
Test: robotests
Change-Id: I42c2cedab66be2d76999795f46470a079cc1ec71
Merged-In: I58821a6cfd6134b3b351657b6edf5f74ead00643
2018-05-09 10:03:40 -07:00
Matthew Fritze
c301964167 Prevent crashes on null intent in Slice Builder
Change-Id: Ia429dd00fce785bc9d23ac8cf15f6855d7fca7c2
Fixes: 79147458
Test: Robotests
2018-05-08 15:37:42 -07:00
Matthew Fritze
47a44e8fa4 Add keywords to Slices
Attach the keywords used for Settings search to Slices.
Their primary use is helping match synonyms for presenters
which display slices without explicit Uri requests, like a launcher.

This changes:
- Updates database scheme
- Adds to SliceData object
- Grab keywords in the SliceDataConverter
- Set keywords on all slices

Test: robotests
Change-Id: I16c40d2380ffddaf0a87fb1b9cd58e95573b308f
Fixes: 78306195
2018-04-20 14:50:55 -07:00
TreeHugger Robot
bc4c392ff4 Merge "Add A11y Slices" into pi-dev 2018-04-18 01:44:58 +00:00
TreeHugger Robot
1257466d0b Merge "Add getDescendants to Settings Slice Provider" into pi-dev 2018-04-17 19:21:20 +00: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
7acd13f3e4 Update a Slice Uri when unavailable
When a slice becomes unavailable, it should not update the
underlying data even if the view has not changed.

When we receive a change from an unavailable slice, notifychange
on the Uri and do not change the underlying data.

Change-Id: I91851ab668e4aece669fd65c14e0dc4ec2edefdf
Fixes: 77980406
Test: robotests
2018-04-17 10:43:26 -07:00
Matthew Fritze
a711ed8330 Add A11y Slices
Add AccessibilityPreferenceController, which wraps all a11y settings
since they are share common infrastructure for enabling, current value,
and availability.

We add an overlay for OEMs to declare their bundled a11y services.
This is the only list of services that will be possible to enabled via
Settings slices.

Accessibility Slices are built by getting a list of valid services,
and indexing the service names as a key in the Slices DB. When they are
built at runtime, they use the generic A11yPrefController to get the status
and enable/disable the service.

Bug: 67997836
Bug: 67997672
Test: robotests
Change-Id: I66f905bf1c55eecb937945c4675c12bcbc96d698
2018-04-17 10:27:02 -07:00
Matthew Fritze
59e2d1fff9 Uniquely identify Slice intents
PendingIntents were being cached because they had the same
targets and would not differentiate on extras - thus all Slice
intents would go to the same destination as the first intent fired.

Adding the data stops the system from caching the intents.

Change-Id: Ifccab72ed482e22750422c5c36aa6d205c20ae3d
Fixes: 77650727
Test: robotests
2018-04-11 17:54:41 -07:00
Matthew Fritze
dba7d1c4b3 Unavailable Slices includes DISABLED_DEPENDENT settings
In the change to mark disabled_dependent as available,
it did not change the check in SliceBuilderUtils for the
unavailable Slices. In the case of DISABLED_DEPENDENT, the
setting is available but the Slice is not.

Though it is a simple change, we can now properly test the contents
of Slices, so this change includes tests which should have been in
place earlier and would have caught this bug - duh.

Bug: 71640747
Test: Robotests
Change-Id: I8db5bc80edb337cbf907ce3669aa2bfd9c72f74a
2018-04-09 17:06:47 -07:00
Matthew Fritze
8db4358f76 Prioritize dynamic summaries
If both Xml and a controller provide a summary,
the controller's should be prioritized.

Change-Id: I030746b0f253ce4884a7868e385069b208f63082
Fixes: 77602860
Test: robotests
2018-04-06 14:11:50 -07:00
Fan Zhang
87b2634fc0 Log when settings slice is requested/updated.
Change-Id: Ie6b7000729b3a414a29e3dfc25a29e1f2f939ddd
Fixes: 71503986
Test: robotests
2018-04-03 10:15:56 -07:00
Matthew Fritze
fcdfc2d83f Return back-up slices for unavailable settings
When an inline slice is requested, and the setting is unavailable,
we should present more useful information to the user. This CL handles:
- Unsupported: return intent slice to Settings home page
- Disabled for user: intent to the setting page
- Unknown reason: intent to setting page
- Disabled dependency: Create intent-based Slice rather
than the requested inline slice.

Bug: 71640747
Test: robotests
Change-Id: I9c1a0ee36119d4f9f3b205e0824c251f4356db55
2018-03-23 12:47:36 -07:00
Matthew Fritze
ad6678f9fc Add Slider template for Slices
Add the Seekbar preference equivalent
to the TwoStatePreference (toggle) preference
controller abstract controller.

Change-Id: I6ff91f2f72a7f72c18ddbc27b2b1fda4b6ce6ca9
Fixes: 67996707
Test: Robotests
2018-03-22 11:46:47 -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
Fan Zhang
906572b127 Change PreferenceController#getSummary return type.
Return CharSequence instead of String.

All user visible string should be modeled as CharSequence.

Bug: 73950519
Test: robotest
Change-Id: I30befef0c33f94351d4a2774e283bd1ed804aa8b
2018-02-27 22:30:12 -08:00
Matthew Fritze
700c113218 Add Toggle Controllers to XML
Autobrightness preference controller was accidentally removed from
display_settings.xml. Given that no tests were broken and this would
be a disaster for phone buddy & inline actions, I have added another
test which keeps a list of valid controllers that should exist in xml.

When more inline controllers types are added, they will be included
in this test.

Fixes: 72564979
Test: robotests
Change-Id: I40fe18f9118af9cec1c201632742d2949ff64be5
2018-02-07 17:09:05 -08:00
Matthew Fritze
64aa50c006 Add bluetooth as a supported Slice
To add bluetooth as a valid slice requires adding
support for Context-only preference controller
constructors, which was already planned work.

Fixes: 67997327
Test: robotests
Change-Id: I7efd20a05d5796c3327a26b1fc535d5436d1070f
2018-01-23 16:16:28 -08:00
Matthew Fritze
82254b08fd Add dynamic summaries to Slices
Summary on slices will now determined by checking that
summaries in the following order are valid:
1) SliceData summary
2) Preference Controller summary
3) SliceData screen title

Valid is currently defined as:
- Not empty / null
- Not whitespace
- Not sumamry placeholder

Fixes: 71640678
Test: robotests
Change-Id: I5e699e8566ece80742d311617b7dc4e9a9bda8cf
2018-01-15 16:05:16 -08:00