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:
@@ -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);
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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,
|
||||
|
@@ -23,6 +23,7 @@ import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
import com.android.settings.applications.GameSettingsFeatureProvider;
|
||||
@@ -174,6 +175,11 @@ public abstract class FeatureFactory {
|
||||
*/
|
||||
public abstract GameSettingsFeatureProvider getGameSettingsFeatureProvider();
|
||||
|
||||
/**
|
||||
* Retrieve implementation for Accessibility search index feature.
|
||||
*/
|
||||
public abstract AccessibilitySearchFeatureProvider getAccessibilitySearchFeatureProvider();
|
||||
|
||||
public static final class FactoryNotFoundException extends RuntimeException {
|
||||
public FactoryNotFoundException(Throwable throwable) {
|
||||
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
|
||||
|
@@ -25,6 +25,8 @@ import android.os.UserManager;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
|
||||
import com.android.settings.accessibility.AccessibilitySearchFeatureProviderImpl;
|
||||
import com.android.settings.accounts.AccountFeatureProvider;
|
||||
import com.android.settings.accounts.AccountFeatureProviderImpl;
|
||||
import com.android.settings.applications.ApplicationFeatureProvider;
|
||||
@@ -106,6 +108,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
private ExtraAppInfoFeatureProvider mExtraAppInfoFeatureProvider;
|
||||
private SecuritySettingsFeatureProvider mSecuritySettingsFeatureProvider;
|
||||
private GameSettingsFeatureProvider mGameSettingsFeatureProvider;
|
||||
private AccessibilitySearchFeatureProvider mAccessibilitySearchFeatureProvider;
|
||||
|
||||
@Override
|
||||
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
||||
@@ -335,4 +338,12 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
}
|
||||
return mGameSettingsFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibilitySearchFeatureProvider getAccessibilitySearchFeatureProvider() {
|
||||
if (mAccessibilitySearchFeatureProvider == null) {
|
||||
mAccessibilitySearchFeatureProvider = new AccessibilitySearchFeatureProviderImpl();
|
||||
}
|
||||
return mAccessibilitySearchFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user