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

@@ -5853,29 +5853,29 @@
<!-- List of synonyms used in the settings search bar to find the “Magnification”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Magnification”. [CHAR LIMIT=NONE] -->
<string name="keywords_magnification">Window Magnifier, Zoom, Magnification, Low vision, Enlarge, make bigger</string> <string name="keywords_magnification">Window Magnifier, Zoom, Magnification, Low vision, Enlarge, make bigger</string>
<!-- List of synonyms used in the settings search bar to find the “TalkBack”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “TalkBack”. [CHAR LIMIT=NONE] -->
<string name="keywords_talkback">Screen reader, Voice Over, VoiceOver, Voice Assistance, Blind, Low Vision, TTS, text to speech, spoken feedback</string> <string name="keywords_talkback"></string>
<!-- List of synonyms used in the settings search bar to find the “Live Caption”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Live Caption”. [CHAR LIMIT=NONE] -->
<string name="keywords_live_caption">Captions, closed captions, CC, Live Transcribe, hard of hearing, hearing loss, CART, speech to text, subtitle</string> <string name="keywords_live_caption">Captions, closed captions, CC, Live Transcribe, hard of hearing, hearing loss, CART, speech to text, subtitle</string>
<!-- List of synonyms used in the settings search bar to find the “Live Transcribe”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Live Transcribe”. [CHAR LIMIT=NONE] -->
<string name="keywords_live_transcribe">Captions, closed captions, CC, Live Caption, hard of hearing, hearing loss, CART, speech to text, subtitle</string> <string name="keywords_live_transcribe"></string>
<!-- List of synonyms used in the settings search bar to find the “Sound Notifications”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Sound Notifications”. [CHAR LIMIT=NONE] -->
<string name="keywords_sound_notifications">Notifications, hard of hearing, hearing loss, notify</string> <string name="keywords_sound_notifications"></string>
<!-- List of synonyms used in the settings search bar to find the “Sound Amplifier”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Sound Amplifier”. [CHAR LIMIT=NONE] -->
<string name="keywords_sound_amplifier">PSAP, amplify, sound amplification, hard of hearing, hearing loss, amplification</string> <string name="keywords_sound_amplifier"></string>
<!-- List of synonyms used in the settings search bar to find the “Display size”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Display size”. [CHAR LIMIT=NONE] -->
<string name="keywords_display_size">screen size, large screen</string> <string name="keywords_display_size">screen size, large screen</string>
<!-- List of synonyms used in the settings search bar to find the “Bold text”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Bold text”. [CHAR LIMIT=NONE] -->
<string name="keywords_bold_text">High contrast, low vision, bold font, bold face</string> <string name="keywords_bold_text">High contrast, low vision, bold font, bold face</string>
<!-- List of synonyms used in the settings search bar to find the “Select to Speak”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Select to Speak”. [CHAR LIMIT=NONE] -->
<string name="keywords_select_to_speak">Hear text, read aloud, speak screen, screen reader</string> <string name="keywords_select_to_speak"></string>
<!-- List of synonyms used in the settings search bar to find the “Color correction”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Color correction”. [CHAR LIMIT=NONE] -->
<string name="keywords_color_correction">adjust color </string> <string name="keywords_color_correction">adjust color </string>
<!-- List of synonyms used in the settings search bar to find the “Color inversion”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Color inversion”. [CHAR LIMIT=NONE] -->
<string name="keywords_color_inversion">turn screen dark, turn screen light</string> <string name="keywords_color_inversion">turn screen dark, turn screen light</string>
<!-- List of synonyms used in the settings search bar to find the “Accessibility Menu”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Accessibility Menu”. [CHAR LIMIT=NONE] -->
<string name="keywords_accessibility_menu">motor, quick menu, assistive menu, touch, dexterity</string> <string name="keywords_accessibility_menu"></string>
<!-- List of synonyms used in the settings search bar to find the “Switch Access”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Switch Access”. [CHAR LIMIT=NONE] -->
<string name="keywords_switch_access">motor, switch, hand, AT, assistive technology, paralysis, ALS, scanning, step scanning</string> <string name="keywords_switch_access"></string>
<!-- List of synonyms used in the settings search bar to find the “Autoclick(dwell timing)”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Autoclick(dwell timing)”. [CHAR LIMIT=NONE] -->
<string name="keywords_auto_click">motor, mouse</string> <string name="keywords_auto_click">motor, mouse</string>
<!-- List of synonyms used in the settings search bar to find the “Hearing aids”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Hearing aids”. [CHAR LIMIT=NONE] -->
@@ -5883,7 +5883,7 @@
<!-- List of synonyms used in the settings search bar to find the “Real-time text (RTT)”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Real-time text (RTT)”. [CHAR LIMIT=NONE] -->
<string name="keywords_rtt">hard of hearing, hearing loss, captions, Teletype, tty</string> <string name="keywords_rtt">hard of hearing, hearing loss, captions, Teletype, tty</string>
<!-- List of synonyms used in the settings search bar to find the “Voice Access”. [CHAR LIMIT=NONE] --> <!-- List of synonyms used in the settings search bar to find the “Voice Access”. [CHAR LIMIT=NONE] -->
<string name="keywords_voice_access">voice, voice control, motor, hand, mic, microphone, dictation, talk, control</string> <string name="keywords_voice_access"></string>
<!-- Printing settings --> <!-- Printing settings -->
<skip /> <skip />

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.Utils;
import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType; import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.RestrictedLockUtilsInternal;
import com.android.settingslib.RestrictedPreference; import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.accessibility.AccessibilityUtils; import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.settingslib.search.SearchIndexable; import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -494,7 +496,15 @@ public class AccessibilitySettings extends DashboardFragment {
} }
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 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. * This class helps setup RestrictedPreference.
@@ -559,7 +569,6 @@ public class AccessibilitySettings extends DashboardFragment {
setRestrictedPreferenceEnabled(preference, packageName, serviceAllowed, setRestrictedPreferenceEnabled(preference, packageName, serviceAllowed,
serviceEnabled); serviceEnabled);
final String prefKey = preference.getKey(); final String prefKey = preference.getKey();
final int imageRes = info.getAnimatedImageRes(); final int imageRes = info.getAnimatedImageRes();
final CharSequence description = getServiceDescription(mContext, info, final CharSequence description = getServiceDescription(mContext, info,

View File

@@ -23,6 +23,7 @@ import android.util.Log;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
import com.android.settings.accounts.AccountFeatureProvider; import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.applications.GameSettingsFeatureProvider; import com.android.settings.applications.GameSettingsFeatureProvider;
@@ -174,6 +175,11 @@ public abstract class FeatureFactory {
*/ */
public abstract GameSettingsFeatureProvider getGameSettingsFeatureProvider(); public abstract GameSettingsFeatureProvider getGameSettingsFeatureProvider();
/**
* Retrieve implementation for Accessibility search index feature.
*/
public abstract AccessibilitySearchFeatureProvider getAccessibilitySearchFeatureProvider();
public static final class FactoryNotFoundException extends RuntimeException { public static final class FactoryNotFoundException extends RuntimeException {
public FactoryNotFoundException(Throwable throwable) { public FactoryNotFoundException(Throwable throwable) {
super("Unable to create factory. Did you misconfigure Proguard?", throwable); super("Unable to create factory. Did you misconfigure Proguard?", throwable);

View File

@@ -25,6 +25,8 @@ import android.os.UserManager;
import androidx.annotation.Keep; 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.AccountFeatureProvider;
import com.android.settings.accounts.AccountFeatureProviderImpl; import com.android.settings.accounts.AccountFeatureProviderImpl;
import com.android.settings.applications.ApplicationFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider;
@@ -106,6 +108,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
private ExtraAppInfoFeatureProvider mExtraAppInfoFeatureProvider; private ExtraAppInfoFeatureProvider mExtraAppInfoFeatureProvider;
private SecuritySettingsFeatureProvider mSecuritySettingsFeatureProvider; private SecuritySettingsFeatureProvider mSecuritySettingsFeatureProvider;
private GameSettingsFeatureProvider mGameSettingsFeatureProvider; private GameSettingsFeatureProvider mGameSettingsFeatureProvider;
private AccessibilitySearchFeatureProvider mAccessibilitySearchFeatureProvider;
@Override @Override
public SupportFeatureProvider getSupportFeatureProvider(Context context) { public SupportFeatureProvider getSupportFeatureProvider(Context context) {
@@ -335,4 +338,12 @@ public class FeatureFactoryImpl extends FeatureFactory {
} }
return mGameSettingsFeatureProvider; return mGameSettingsFeatureProvider;
} }
@Override
public AccessibilitySearchFeatureProvider getAccessibilitySearchFeatureProvider() {
if (mAccessibilitySearchFeatureProvider == null) {
mAccessibilitySearchFeatureProvider = new AccessibilitySearchFeatureProviderImpl();
}
return mAccessibilitySearchFeatureProvider;
}
} }

View File

@@ -56,6 +56,7 @@ import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowFragment; import com.android.settings.testutils.shadow.ShadowFragment;
import com.android.settings.testutils.shadow.ShadowUserManager; import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedPreference; import com.android.settingslib.RestrictedPreference;
import com.android.settingslib.search.SearchIndexableRaw;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@@ -77,12 +78,12 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** Test for {@link AccessibilitySettings}. */
@RunWith(RobolectricTestRunner.class) @RunWith(RobolectricTestRunner.class)
public class AccessibilitySettingsTest { public class AccessibilitySettingsTest {
private static final String PACKAGE_NAME = "com.android.test"; private static final String PACKAGE_NAME = "com.android.test";
private static final String CLASS_NAME = PACKAGE_NAME + ".test_a11y_service"; private static final String CLASS_NAME = PACKAGE_NAME + ".test_a11y_service";
private static final ComponentName COMPONENT_NAME = new ComponentName(PACKAGE_NAME, private static final ComponentName COMPONENT_NAME = new ComponentName(PACKAGE_NAME, CLASS_NAME);
CLASS_NAME);
private static final int ON = 1; private static final int ON = 1;
private static final int OFF = 0; private static final int OFF = 0;
private static final String EMPTY_STRING = ""; private static final String EMPTY_STRING = "";
@@ -132,6 +133,14 @@ public class AccessibilitySettingsTest {
assertThat(keys).containsAtLeastElementsIn(niks); assertThat(keys).containsAtLeastElementsIn(niks);
} }
@Test
public void getRawDataToIndex_isNull() {
final List<SearchIndexableRaw> indexableRawList =
AccessibilitySettings.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true);
assertThat(indexableRawList).isNull();
}
@Test @Test
@Config(shadows = {ShadowDeviceConfig.class}) @Config(shadows = {ShadowDeviceConfig.class})
public void isRampingRingerEnabled_settingsFlagOn_Enabled() { public void isRampingRingerEnabled_settingsFlagOn_Enabled() {
@@ -362,7 +371,7 @@ public class AccessibilitySettingsTest {
try { try {
final AccessibilityServiceInfo info = new AccessibilityServiceInfo(resolveInfo, final AccessibilityServiceInfo info = new AccessibilityServiceInfo(resolveInfo,
mContext); mContext);
info.setComponentName(new ComponentName(PACKAGE_NAME, CLASS_NAME)); info.setComponentName(new ComponentName(packageName, className));
return info; return info;
} catch (XmlPullParserException | IOException e) { } catch (XmlPullParserException | IOException e) {
// Do nothing // Do nothing

View File

@@ -21,6 +21,7 @@ import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
import com.android.settings.accounts.AccountFeatureProvider; import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.applications.GameSettingsFeatureProvider; import com.android.settings.applications.GameSettingsFeatureProvider;
@@ -87,6 +88,7 @@ public class FakeFeatureFactory extends FeatureFactory {
public ExtraAppInfoFeatureProvider extraAppInfoFeatureProvider; public ExtraAppInfoFeatureProvider extraAppInfoFeatureProvider;
public SecuritySettingsFeatureProvider securitySettingsFeatureProvider; public SecuritySettingsFeatureProvider securitySettingsFeatureProvider;
public GameSettingsFeatureProvider gameSettingsFeatureProvider; public GameSettingsFeatureProvider gameSettingsFeatureProvider;
public AccessibilitySearchFeatureProvider mAccessibilitySearchFeatureProvider;
/** /**
* Call this in {@code @Before} method of the test class to use fake factory. * Call this in {@code @Before} method of the test class to use fake factory.
@@ -136,6 +138,7 @@ public class FakeFeatureFactory extends FeatureFactory {
extraAppInfoFeatureProvider = mock(ExtraAppInfoFeatureProvider.class); extraAppInfoFeatureProvider = mock(ExtraAppInfoFeatureProvider.class);
securitySettingsFeatureProvider = mock(SecuritySettingsFeatureProvider.class); securitySettingsFeatureProvider = mock(SecuritySettingsFeatureProvider.class);
gameSettingsFeatureProvider = mock(GameSettingsFeatureProvider.class); gameSettingsFeatureProvider = mock(GameSettingsFeatureProvider.class);
mAccessibilitySearchFeatureProvider = mock(AccessibilitySearchFeatureProvider.class);
} }
@Override @Override
@@ -272,4 +275,9 @@ public class FakeFeatureFactory extends FeatureFactory {
public GameSettingsFeatureProvider getGameSettingsFeatureProvider() { public GameSettingsFeatureProvider getGameSettingsFeatureProvider() {
return gameSettingsFeatureProvider; return gameSettingsFeatureProvider;
} }
@Override
public AccessibilitySearchFeatureProvider getAccessibilitySearchFeatureProvider() {
return mAccessibilitySearchFeatureProvider;
}
} }

View File

@@ -19,6 +19,7 @@ import static org.mockito.Mockito.mock;
import android.content.Context; import android.content.Context;
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
import com.android.settings.accounts.AccountFeatureProvider; import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider;
import com.android.settings.applications.GameSettingsFeatureProvider; import com.android.settings.applications.GameSettingsFeatureProvider;
@@ -82,6 +83,7 @@ public class FakeFeatureFactory extends FeatureFactory {
public ExtraAppInfoFeatureProvider extraAppInfoFeatureProvider; public ExtraAppInfoFeatureProvider extraAppInfoFeatureProvider;
public SecuritySettingsFeatureProvider securitySettingsFeatureProvider; public SecuritySettingsFeatureProvider securitySettingsFeatureProvider;
public GameSettingsFeatureProvider gameSettingsFeatureProvider; public GameSettingsFeatureProvider gameSettingsFeatureProvider;
public AccessibilitySearchFeatureProvider mAccessibilitySearchFeatureProvider;
/** /**
* Call this in {@code @Before} method of the test class to use fake factory. * Call this in {@code @Before} method of the test class to use fake factory.
@@ -258,4 +260,9 @@ public class FakeFeatureFactory extends FeatureFactory {
public GameSettingsFeatureProvider getGameSettingsFeatureProvider() { public GameSettingsFeatureProvider getGameSettingsFeatureProvider() {
return gameSettingsFeatureProvider; return gameSettingsFeatureProvider;
} }
@Override
public AccessibilitySearchFeatureProvider getAccessibilitySearchFeatureProvider() {
return mAccessibilitySearchFeatureProvider;
}
} }