Improve search by adding the settings keywords for supported downloaded services

* Use FeatureFactory to improve the search only for google overlay

Bug: 184171842
Test: atest AccessibilitySettingsTest
Change-Id: I93ed52d2579b7da35dba59f9562b6715d13dd80d
This commit is contained in:
jasonwshsu
2021-04-24 16:00:09 +08:00
parent b4f59a75d5
commit 87b90dfc50
9 changed files with 134 additions and 13 deletions

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.accessibility;
import android.content.Context;
import com.android.settingslib.search.SearchIndexableRaw;
import java.util.List;
/**
* Provider for Accessibility Search related features.
*/
public interface AccessibilitySearchFeatureProvider {
/**
* Returns a list of raw data for indexing. See {@link SearchIndexableRaw}
*
* @param context a valid context {@link Context} instance
* @return a list of {@link SearchIndexableRaw} references. Can be null.
*/
List<SearchIndexableRaw> getSearchIndexableRawData(Context context);
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.accessibility;
import android.content.Context;
import com.android.settingslib.search.SearchIndexableRaw;
import java.util.List;
/**
* Provider implementation for Accessibility Search related features.
*/
public class AccessibilitySearchFeatureProviderImpl implements AccessibilitySearchFeatureProvider {
@Override
public List<SearchIndexableRaw> getSearchIndexableRawData(Context context) {
return null;
}
}

View File

@@ -50,12 +50,14 @@ import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList;
import java.util.Collection;
@@ -494,7 +496,15 @@ public class AccessibilitySettings extends DashboardFragment {
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_settings);
new BaseSearchIndexProvider(R.xml.accessibility_settings) {
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) {
return FeatureFactory.getFactory(context)
.getAccessibilitySearchFeatureProvider().getSearchIndexableRawData(
context);
}
};
/**
* This class helps setup RestrictedPreference.
@@ -559,7 +569,6 @@ public class AccessibilitySettings extends DashboardFragment {
setRestrictedPreferenceEnabled(preference, packageName, serviceAllowed,
serviceEnabled);
final String prefKey = preference.getKey();
final int imageRes = info.getAnimatedImageRes();
final CharSequence description = getServiceDescription(mContext, info,