Index the gesture options in System Navigation Settings page
Fixes: 167536360 Test: manual verify & robotest Change-Id: Ie1a24a7206153dc1405f8a28369a6bade11ddd39
This commit is contained in:
@@ -28,6 +28,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.content.om.OverlayInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
@@ -49,6 +50,7 @@ import com.android.settings.support.actionbar.HelpResourceProvider;
|
||||
import com.android.settings.utils.CandidateInfoExtra;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
import com.android.settingslib.widget.IllustrationPreference;
|
||||
import com.android.settingslib.widget.SelectorWithWidgetPreference;
|
||||
@@ -320,6 +322,39 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return SystemNavigationPreferenceController.isGestureAvailable(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final Resources res = context.getResources();
|
||||
final List<SearchIndexableRaw> result = new ArrayList<>();
|
||||
|
||||
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(context,
|
||||
NAV_BAR_MODE_GESTURAL_OVERLAY)) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.edge_to_edge_navigation_title);
|
||||
data.key = KEY_SYSTEM_NAV_GESTURAL;
|
||||
result.add(data);
|
||||
}
|
||||
|
||||
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(context,
|
||||
NAV_BAR_MODE_2BUTTON_OVERLAY)) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.swipe_up_to_switch_apps_title);
|
||||
data.key = KEY_SYSTEM_NAV_2BUTTONS;
|
||||
result.add(data);
|
||||
}
|
||||
|
||||
if (SystemNavigationPreferenceController.isOverlayPackageAvailable(context,
|
||||
NAV_BAR_MODE_3BUTTON_OVERLAY)) {
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.legacy_navigation_title);
|
||||
data.key = KEY_SYSTEM_NAV_3BUTTONS;
|
||||
result.add(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// From HelpResourceProvider
|
||||
|
@@ -34,6 +34,7 @@ import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -41,10 +42,14 @@ import static org.mockito.Mockito.when;
|
||||
import android.content.Context;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.content.om.OverlayInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -67,6 +72,8 @@ public class SystemNavigationGestureSettingsTest {
|
||||
@Mock
|
||||
private IOverlayManager mOverlayManager;
|
||||
@Mock
|
||||
private PackageManager mPackageManager;
|
||||
@Mock
|
||||
private OverlayInfo mOverlayInfoEnabled;
|
||||
@Mock
|
||||
private OverlayInfo mOverlayInfoDisabled;
|
||||
@@ -75,16 +82,17 @@ public class SystemNavigationGestureSettingsTest {
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mContext = spy(RuntimeEnvironment.application);
|
||||
mSettings = new SystemNavigationGestureSettings();
|
||||
|
||||
when(mOverlayInfoDisabled.isEnabled()).thenReturn(false);
|
||||
when(mOverlayInfoEnabled.isEnabled()).thenReturn(true);
|
||||
when(mOverlayManager.getOverlayInfo(any(), anyInt())).thenReturn(mOverlayInfoDisabled);
|
||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchIndexProvider_shouldIndexResource() {
|
||||
public void searchIndexProvider_shouldIndexResource() {
|
||||
final List<SearchIndexableResource> indexRes =
|
||||
SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
|
||||
RuntimeEnvironment.application, true /* enabled */);
|
||||
@@ -93,6 +101,29 @@ public class SystemNavigationGestureSettingsTest {
|
||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchIndexProvider_gesturePackageExist_shouldBeIndexed()
|
||||
throws NameNotFoundException {
|
||||
PackageInfo info = new PackageInfo();
|
||||
when(mPackageManager.getPackageInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, 0))
|
||||
.thenReturn(info);
|
||||
|
||||
final List<SearchIndexableRaw> indexRaws =
|
||||
SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getRawDataToIndex(mContext, true /* enabled */);
|
||||
|
||||
assertThat(indexRaws).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searchIndexProvider_noNavigationPackageExist_shouldReturnEmpty() {
|
||||
final List<SearchIndexableRaw> indexRaws =
|
||||
SystemNavigationGestureSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getRawDataToIndex(mContext, true /* enabled */);
|
||||
|
||||
assertThat(indexRaws).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCurrentSystemNavigationMode() {
|
||||
SettingsShadowResources.overrideResource(
|
||||
|
Reference in New Issue
Block a user