Add pseudo-filtering on authenticated views.
When the autofill UI is shown for an authenticated FillResponse or Dataset and the user types something, it should be filtered as if the matched failed. Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases Fixes: 65415443 Change-Id: I6a6b5af369e4e5a9cea49ae124dc517dbe5c70be
This commit is contained in:
@@ -229,6 +229,13 @@ final class FillUi {
|
||||
public void setFilterText(@Nullable String filterText) {
|
||||
throwIfDestroyed();
|
||||
if (mAdapter == null) {
|
||||
// ViewState doesn't not support filtering - typically when it's for an authenticated
|
||||
// FillResponse.
|
||||
if (TextUtils.isEmpty(filterText)) {
|
||||
mCallback.requestShowFillUi(mContentWidth, mContentHeight, mWindowPresenter);
|
||||
} else {
|
||||
mCallback.requestHideFillUi();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -510,8 +517,9 @@ final class FillUi {
|
||||
final ViewItem item = mAllItems.get(i);
|
||||
final String value = item.getValue();
|
||||
// No value, i.e. null, matches any filter
|
||||
if (value == null
|
||||
|| value.toLowerCase().startsWith(constraintLowerCase)) {
|
||||
if ((value == null && item.mDataset.getAuthentication() == null)
|
||||
|| (value != null
|
||||
&& value.toLowerCase().startsWith(constraintLowerCase))) {
|
||||
filteredItems.add(item);
|
||||
}
|
||||
}
|
||||
@@ -525,9 +533,11 @@ final class FillUi {
|
||||
final boolean resultCountChanged;
|
||||
final int oldItemCount = mFilteredItems.size();
|
||||
mFilteredItems.clear();
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<ViewItem> items = (List<ViewItem>) results.values;
|
||||
mFilteredItems.addAll(items);
|
||||
if (results.count > 0) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<ViewItem> items = (List<ViewItem>) results.values;
|
||||
mFilteredItems.addAll(items);
|
||||
}
|
||||
resultCountChanged = (oldItemCount != mFilteredItems.size());
|
||||
if (resultCountChanged) {
|
||||
announceSearchResultIfNeeded();
|
||||
|
||||
Reference in New Issue
Block a user