Loading src/com/android/settings/search/DeviceIndexFeatureProvider.java +5 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import android.net.Uri; import android.os.Build; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import com.android.settings.R; Loading @@ -32,7 +33,6 @@ import com.android.settings.slices.SettingsSliceProvider; import java.util.List; import java.util.Locale; import java.util.Objects; public interface DeviceIndexFeatureProvider { Loading Loading @@ -96,10 +96,11 @@ public interface DeviceIndexFeatureProvider { } static boolean skipIndex(Context context) { final boolean isSameVersion = Objects.equals( final boolean isSameVersion = TextUtils.equals( Settings.Secure.getString(context.getContentResolver(), INDEX_VERSION), VERSION); final boolean isSameLanguage = Objects.equals( Settings.Secure.getString(context.getContentResolver(), INDEX_LANGUAGE), LANGUAGE); final boolean isSameLanguage = TextUtils.equals( Settings.Secure.getString(context.getContentResolver(), INDEX_LANGUAGE), LANGUAGE.toString()); return isSameLanguage && isSameVersion; } Loading tests/robotests/src/com/android/settings/search/DeviceIndexFeatureProviderTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.app.job.JobScheduler; import android.os.Build; import android.provider.Settings; import com.android.settings.testutils.FakeFeatureFactory; Loading Loading @@ -113,15 +112,19 @@ public class DeviceIndexFeatureProviderTest { @Test public void updateIndex_enabled_provisioned_sameBuild_sameLang_shouldNotIndex() { // Enabled when(mProvider.isIndexingEnabled()).thenReturn(true); // Provisioned Settings.Global.putInt(mActivity.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1); // Same build and same language DeviceIndexFeatureProvider.setIndexState(mActivity); JobScheduler jobScheduler = mock(JobScheduler.class); when(mProvider.isIndexingEnabled()).thenReturn(true); final JobScheduler jobScheduler = mock(JobScheduler.class); when(mActivity.getSystemService(JobScheduler.class)).thenReturn(jobScheduler); mProvider.updateIndex(mActivity, false); verify(mProvider, never()).index(any(), any(), any(), any(), any()); verify(jobScheduler, never()).schedule(any()); } } Loading
src/com/android/settings/search/DeviceIndexFeatureProvider.java +5 −4 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.content.Context; import android.net.Uri; import android.os.Build; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import com.android.settings.R; Loading @@ -32,7 +33,6 @@ import com.android.settings.slices.SettingsSliceProvider; import java.util.List; import java.util.Locale; import java.util.Objects; public interface DeviceIndexFeatureProvider { Loading Loading @@ -96,10 +96,11 @@ public interface DeviceIndexFeatureProvider { } static boolean skipIndex(Context context) { final boolean isSameVersion = Objects.equals( final boolean isSameVersion = TextUtils.equals( Settings.Secure.getString(context.getContentResolver(), INDEX_VERSION), VERSION); final boolean isSameLanguage = Objects.equals( Settings.Secure.getString(context.getContentResolver(), INDEX_LANGUAGE), LANGUAGE); final boolean isSameLanguage = TextUtils.equals( Settings.Secure.getString(context.getContentResolver(), INDEX_LANGUAGE), LANGUAGE.toString()); return isSameLanguage && isSameVersion; } Loading
tests/robotests/src/com/android/settings/search/DeviceIndexFeatureProviderTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static org.mockito.Mockito.when; import android.app.Activity; import android.app.job.JobScheduler; import android.os.Build; import android.provider.Settings; import com.android.settings.testutils.FakeFeatureFactory; Loading Loading @@ -113,15 +112,19 @@ public class DeviceIndexFeatureProviderTest { @Test public void updateIndex_enabled_provisioned_sameBuild_sameLang_shouldNotIndex() { // Enabled when(mProvider.isIndexingEnabled()).thenReturn(true); // Provisioned Settings.Global.putInt(mActivity.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1); // Same build and same language DeviceIndexFeatureProvider.setIndexState(mActivity); JobScheduler jobScheduler = mock(JobScheduler.class); when(mProvider.isIndexingEnabled()).thenReturn(true); final JobScheduler jobScheduler = mock(JobScheduler.class); when(mActivity.getSystemService(JobScheduler.class)).thenReturn(jobScheduler); mProvider.updateIndex(mActivity, false); verify(mProvider, never()).index(any(), any(), any(), any(), any()); verify(jobScheduler, never()).schedule(any()); } }