diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml index 48a1d4ce1e5..42fbefba0d5 100644 --- a/res/layout/search_panel.xml +++ b/res/layout/search_panel.xml @@ -76,7 +76,7 @@ android:id="@+id/no_results_layout" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="96dp" + android:paddingTop="35dp" android:orientation="vertical" android:visibility="gone"> diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml index 27ef86948d1..87d3e5e1d12 100644 --- a/res/xml/display_settings.xml +++ b/res/xml/display_settings.xml @@ -64,9 +64,11 @@ android:key="auto_rotate" android:title="@string/accelerometer_title" /> - + android:title="@string/color_mode_title" + android:fragment="com.android.settings.display.ColorModePreferenceFragment" + settings:keywords="@string/keywords_color_mode" /> getXmlResourcesToIndex(Context context, - boolean enabled) { - List resources = new ArrayList<>(); - SearchIndexableResource resource = new SearchIndexableResource(context); - resource.xmlResId = R.xml.data_usage; - resources.add(resource); - - resource = new SearchIndexableResource(context); - resource.xmlResId = R.xml.data_plan_usage_cell_data_preference_screen; - resources.add(resource); - - resource = new SearchIndexableResource(context); - resource.xmlResId = R.xml.data_usage_wifi; - resources.add(resource); - - return resources; - } - - @Override - public List getNonIndexableKeys(Context context) { - List keys = super.getNonIndexableKeys(context); - - if (!DataUsageUtils.hasMobileData(context)) { - keys.add(KEY_MOBILE_USAGE_TITLE); - keys.add(KEY_MOBILE_DATA_USAGE_TOGGLE); - } - - if (!DataUsageUtils.hasWifiRadio(context)) { - keys.add(KEY_WIFI_DATA_USAGE); - keys.add(KEY_NETWORK_RESTRICTIONS); - } - - keys.add(KEY_WIFI_USAGE_TITLE); - - return keys; - } - }; } diff --git a/src/com/android/settings/development/CameraHalHdrPlusPreferenceControllerV2.java b/src/com/android/settings/development/CameraHalHdrplusPreferenceControllerV2.java similarity index 96% rename from src/com/android/settings/development/CameraHalHdrPlusPreferenceControllerV2.java rename to src/com/android/settings/development/CameraHalHdrplusPreferenceControllerV2.java index 11ee6c78a15..b8828fe1d02 100644 --- a/src/com/android/settings/development/CameraHalHdrPlusPreferenceControllerV2.java +++ b/src/com/android/settings/development/CameraHalHdrplusPreferenceControllerV2.java @@ -29,7 +29,7 @@ import com.android.settings.R; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.development.DeveloperOptionsPreferenceController; -public class CameraHalHdrPlusPreferenceControllerV2 extends +public class CameraHalHdrplusPreferenceControllerV2 extends DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin { @@ -45,7 +45,7 @@ public class CameraHalHdrPlusPreferenceControllerV2 extends private SwitchPreference mPreference; - public CameraHalHdrPlusPreferenceControllerV2(Context context) { + public CameraHalHdrplusPreferenceControllerV2(Context context) { super(context); } diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java index fa89ba40f7c..d532136cd39 100644 --- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java +++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java @@ -376,7 +376,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra controllers.add(new LogPersistPreferenceControllerV2(context, fragment, lifecycle)); controllers.add(new ConnectivityMonitorPreferenceControllerV2(context)); controllers.add(new CameraLaserSensorPreferenceControllerV2(context)); - controllers.add(new CameraHalHdrPlusPreferenceControllerV2(context)); + controllers.add(new CameraHalHdrplusPreferenceControllerV2(context)); controllers.add(new WifiDisplayCertificationPreferenceController(context)); controllers.add(new WifiVerboseLoggingPreferenceController(context)); controllers.add(new WifiAggressiveHandoverPreferenceController(context)); diff --git a/src/com/android/settings/display/ColorModePreferenceController.java b/src/com/android/settings/display/ColorModePreferenceController.java index 2d669d0e881..2ab2ec9e564 100644 --- a/src/com/android/settings/display/ColorModePreferenceController.java +++ b/src/com/android/settings/display/ColorModePreferenceController.java @@ -18,36 +18,24 @@ import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.os.ServiceManager; -import android.os.SystemProperties; -import android.support.v7.preference.Preference; -import android.support.v7.preference.TwoStatePreference; import android.util.Log; + import com.android.internal.annotations.VisibleForTesting; import com.android.settings.core.PreferenceControllerMixin; import com.android.settingslib.core.AbstractPreferenceController; public class ColorModePreferenceController extends AbstractPreferenceController implements - PreferenceControllerMixin, Preference.OnPreferenceChangeListener { + PreferenceControllerMixin { private static final String TAG = "ColorModePreference"; - private static final String KEY_COLOR_MODE = "color_mode"; - @VisibleForTesting - static final float COLOR_SATURATION_DEFAULT = 1.0f; - @VisibleForTesting - static final float COLOR_SATURATION_VIVID = 1.1f; + private static final int SURFACE_FLINGER_TRANSACTION_QUERY_WIDE_COLOR = 1024; - private static final int SURFACE_FLINGER_TRANSACTION_SATURATION = 1022; - @VisibleForTesting - static final String PERSISTENT_PROPERTY_SATURATION = "persist.sys.sf.color_saturation"; - - private final IBinder mSurfaceFlinger; private final ConfigurationWrapper mConfigWrapper; public ColorModePreferenceController(Context context) { super(context); - mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger"); - mConfigWrapper = new ConfigurationWrapper(context); + mConfigWrapper = new ConfigurationWrapper(); } @Override @@ -55,65 +43,36 @@ public class ColorModePreferenceController extends AbstractPreferenceController return KEY_COLOR_MODE; } - @Override - public void updateState(Preference preference) { - TwoStatePreference colorMode = (TwoStatePreference) preference; - colorMode.setChecked(getSaturationValue() > 1.0f); - } - @Override public boolean isAvailable() { return mConfigWrapper.isScreenWideColorGamut(); } - @Override - public boolean onPreferenceChange(Preference preference, Object newValue) { - float saturation = (boolean) newValue - ? COLOR_SATURATION_VIVID : COLOR_SATURATION_DEFAULT; - - SystemProperties.set(PERSISTENT_PROPERTY_SATURATION, Float.toString(saturation)); - applySaturation(saturation); - - return true; - } - - /** - * Propagates the provided saturation to the SurfaceFlinger. - */ - private void applySaturation(float saturation) { - if (mSurfaceFlinger != null) { - final Parcel data = Parcel.obtain(); - data.writeInterfaceToken("android.ui.ISurfaceComposer"); - data.writeFloat(saturation); - try { - mSurfaceFlinger.transact(SURFACE_FLINGER_TRANSACTION_SATURATION, data, null, 0); - } catch (RemoteException ex) { - Log.e(TAG, "Failed to set saturation", ex); - } finally { - data.recycle(); - } - } - } - - private static float getSaturationValue() { - try { - return Float.parseFloat(SystemProperties.get( - PERSISTENT_PROPERTY_SATURATION, Float.toString(COLOR_SATURATION_DEFAULT))); - } catch (NumberFormatException e) { - return COLOR_SATURATION_DEFAULT; - } - } - @VisibleForTesting static class ConfigurationWrapper { - private final Context mContext; + private final IBinder mSurfaceFlinger; - ConfigurationWrapper(Context context) { - mContext = context; + ConfigurationWrapper() { + mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger"); } boolean isScreenWideColorGamut() { - return mContext.getResources().getConfiguration().isScreenWideColorGamut(); + if (mSurfaceFlinger != null) { + final Parcel data = Parcel.obtain(); + final Parcel reply = Parcel.obtain(); + data.writeInterfaceToken("android.ui.ISurfaceComposer"); + try { + mSurfaceFlinger.transact(SURFACE_FLINGER_TRANSACTION_QUERY_WIDE_COLOR, + data, reply, 0); + return reply.readBoolean(); + } catch (RemoteException ex) { + Log.e(TAG, "Failed to query wide color support", ex); + } finally { + data.recycle(); + reply.recycle(); + } + } + return false; } } } diff --git a/src/com/android/settings/display/ColorModePreferenceFragment.java b/src/com/android/settings/display/ColorModePreferenceFragment.java new file mode 100644 index 00000000000..7c8b841b38b --- /dev/null +++ b/src/com/android/settings/display/ColorModePreferenceFragment.java @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2017 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.display; + +import android.app.ActivityManager; +import android.app.IActivityManager; +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.os.IBinder; +import android.os.Parcel; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.os.SystemProperties; +import android.support.annotation.VisibleForTesting; +import android.util.Log; + +import com.android.internal.logging.nano.MetricsProto; + +import com.android.settings.R; +import com.android.settings.widget.RadioButtonPickerFragment; + +import java.util.Arrays; +import java.util.List; + +@SuppressWarnings("WeakerAccess") +public class ColorModePreferenceFragment extends RadioButtonPickerFragment { + private static final String TAG = "ColorModePreferenceFragment"; + + @VisibleForTesting + static final float COLOR_SATURATION_NATURAL = 1.0f; + @VisibleForTesting + static final float COLOR_SATURATION_BOOSTED = 1.1f; + + private static final int SURFACE_FLINGER_TRANSACTION_SATURATION = 1022; + private static final int SURFACE_FLINGER_TRANSACTION_NATIVE_MODE = 1023; + + @VisibleForTesting + static final String PERSISTENT_PROPERTY_SATURATION = "persist.sys.sf.color_saturation"; + @VisibleForTesting + static final String PERSISTENT_PROPERTY_NATIVE_MODE = "persist.sys.sf.native_mode"; + + @VisibleForTesting + static final String KEY_COLOR_MODE_NATURAL = "color_mode_natural"; + @VisibleForTesting + static final String KEY_COLOR_MODE_BOOSTED = "color_mode_boosted"; + @VisibleForTesting + static final String KEY_COLOR_MODE_SATURATED = "color_mode_saturated"; + + private IBinder mSurfaceFlinger; + private IActivityManager mActivityManager; + + @Override + public void onAttach(Context context) { + super.onAttach(context); + mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger"); + mActivityManager = ActivityManager.getService(); + } + + @Override + protected List getCandidates() { + Context c = getContext(); + return Arrays.asList( + new ColorModeCandidateInfo(c.getString(R.string.color_mode_option_natural), + KEY_COLOR_MODE_NATURAL), + new ColorModeCandidateInfo(c.getString(R.string.color_mode_option_boosted), + KEY_COLOR_MODE_BOOSTED), + new ColorModeCandidateInfo(c.getString(R.string.color_mode_option_saturated), + KEY_COLOR_MODE_SATURATED) + ); + } + + @Override + protected String getDefaultKey() { + if (isNativeModeEnabled()) { + return KEY_COLOR_MODE_SATURATED; + } + if (getSaturationValue() > COLOR_SATURATION_NATURAL) { + return KEY_COLOR_MODE_BOOSTED; + } + return KEY_COLOR_MODE_NATURAL; + } + + @Override + protected boolean setDefaultKey(String key) { + switch (key) { + case KEY_COLOR_MODE_NATURAL: + applySaturation(COLOR_SATURATION_NATURAL); + setNativeMode(false); + break; + case KEY_COLOR_MODE_BOOSTED: + applySaturation(COLOR_SATURATION_BOOSTED); + setNativeMode(false); + break; + case KEY_COLOR_MODE_SATURATED: + applySaturation(COLOR_SATURATION_NATURAL); + setNativeMode(true); + break; + } + + updateConfiguration(); + + return true; + } + + @VisibleForTesting + void updateConfiguration() { + try { + mActivityManager.updateConfiguration(null); + } catch (RemoteException e) { + Log.d(TAG, "Could not update configuration", e); + } + } + + @Override + public int getMetricsCategory() { + return MetricsProto.MetricsEvent.COLOR_MODE_SETTINGS; + } + + /** + * Propagates the provided saturation to the SurfaceFlinger. + */ + private void applySaturation(float saturation) { + SystemProperties.set(PERSISTENT_PROPERTY_SATURATION, Float.toString(saturation)); + if (mSurfaceFlinger != null) { + final Parcel data = Parcel.obtain(); + data.writeInterfaceToken("android.ui.ISurfaceComposer"); + data.writeFloat(saturation); + try { + mSurfaceFlinger.transact(SURFACE_FLINGER_TRANSACTION_SATURATION, data, null, 0); + } catch (RemoteException ex) { + Log.e(TAG, "Failed to set saturation", ex); + } finally { + data.recycle(); + } + } + } + + private static float getSaturationValue() { + try { + return Float.parseFloat(SystemProperties.get( + PERSISTENT_PROPERTY_SATURATION, Float.toString(COLOR_SATURATION_NATURAL))); + } catch (NumberFormatException e) { + return COLOR_SATURATION_NATURAL; + } + } + + /** + * Toggles native mode on/off in SurfaceFlinger. + */ + private void setNativeMode(boolean enabled) { + SystemProperties.set(PERSISTENT_PROPERTY_NATIVE_MODE, enabled ? "1" : "0"); + if (mSurfaceFlinger != null) { + final Parcel data = Parcel.obtain(); + data.writeInterfaceToken("android.ui.ISurfaceComposer"); + data.writeInt(enabled ? 1 : 0); + try { + mSurfaceFlinger.transact(SURFACE_FLINGER_TRANSACTION_NATIVE_MODE, data, null, 0); + } catch (RemoteException ex) { + Log.e(TAG, "Failed to set native mode", ex); + } finally { + data.recycle(); + } + } + } + + private static boolean isNativeModeEnabled() { + return SystemProperties.getBoolean(PERSISTENT_PROPERTY_NATIVE_MODE, false); + } + + @VisibleForTesting + static class ColorModeCandidateInfo extends CandidateInfo { + private final CharSequence mLabel; + private final String mKey; + + ColorModeCandidateInfo(CharSequence label, String key) { + super(true); + mLabel = label; + mKey = key; + } + + @Override + public CharSequence loadLabel() { + return mLabel; + } + + @Override + public Drawable loadIcon() { + return null; + } + + @Override + public String getKey() { + return mKey; + } + } +} diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java index 88dab494355..f00b9520bba 100644 --- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java +++ b/src/com/android/settings/fuelgauge/BatterySaverSettings.java @@ -25,6 +25,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.PowerManager; +import android.provider.SearchIndexableResource; import android.provider.Settings.Global; import android.support.annotation.VisibleForTesting; import android.util.Log; @@ -38,10 +39,16 @@ import com.android.settings.Utils; import com.android.settings.dashboard.conditional.BatterySaverCondition; import com.android.settings.dashboard.conditional.ConditionManager; import com.android.settings.notification.SettingPref; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; import com.android.settings.widget.SwitchBar; +import java.util.Arrays; +import java.util.List; + public class BatterySaverSettings extends SettingsPreferenceFragment - implements SwitchBar.OnSwitchChangeListener, BatterySaverReceiver.BatterySaverListener { + implements SwitchBar.OnSwitchChangeListener, BatterySaverReceiver.BatterySaverListener, + Indexable { private static final String TAG = "BatterySaverSettings"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final String KEY_TURN_ON_AUTOMATICALLY = "turn_on_automatically"; @@ -89,7 +96,7 @@ public class BatterySaverSettings extends SettingsPreferenceFragment protected String getCaption(Resources res, int value) { if (value > 0 && value < 100) { return res.getString(R.string.battery_saver_turn_on_automatically_pct, - Utils.formatPercentage(value)); + Utils.formatPercentage(value)); } return res.getString(R.string.battery_saver_turn_on_automatically_never); } @@ -219,4 +226,18 @@ public class BatterySaverSettings extends SettingsPreferenceFragment } } } + + /** + * For Search. + */ + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + @Override + public List getXmlResourcesToIndex( + Context context, boolean enabled) { + final SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.battery_saver_settings; + return Arrays.asList(sir); + } + }; } diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java index d66b3105d2d..39d5f6d214a 100644 --- a/src/com/android/settings/location/LocationSettings.java +++ b/src/com/android/settings/location/LocationSettings.java @@ -27,6 +27,7 @@ import android.location.SettingInjectorService; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; +import android.provider.SearchIndexableResource; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceCategory; import android.support.v7.preference.PreferenceGroup; @@ -40,6 +41,8 @@ import com.android.settings.SettingsActivity; import com.android.settings.Utils; import com.android.settings.applications.InstalledAppDetails; import com.android.settings.dashboard.SummaryLoader; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; import com.android.settings.widget.SwitchBar; import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedPreference; @@ -47,6 +50,7 @@ import com.android.settingslib.RestrictedSwitchPreference; import com.android.settingslib.location.RecentLocationApps; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -77,7 +81,7 @@ import java.util.List; * implementation. */ public class LocationSettings extends LocationSettingsBase - implements SwitchBar.OnSwitchChangeListener { + implements SwitchBar.OnSwitchChangeListener, Indexable { private static final String TAG = "LocationSettings"; @@ -455,4 +459,18 @@ public class LocationSettings extends LocationSettingsBase return new SummaryProvider(activity, summaryLoader); } }; + + /** + * For Search. + */ + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + @Override + public List getXmlResourcesToIndex( + Context context, boolean enabled) { + final SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.location_settings; + return Arrays.asList(sir); + } + }; } diff --git a/src/com/android/settings/location/ScanningSettings.java b/src/com/android/settings/location/ScanningSettings.java index fd5a7fd663d..5c34b62b6a4 100644 --- a/src/com/android/settings/location/ScanningSettings.java +++ b/src/com/android/settings/location/ScanningSettings.java @@ -16,6 +16,8 @@ package com.android.settings.location; +import android.content.Context; +import android.provider.SearchIndexableResource; import android.provider.Settings.Global; import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; @@ -24,11 +26,16 @@ import android.support.v7.preference.PreferenceScreen; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; + +import java.util.Arrays; +import java.util.List; /** * A page that configures the background scanning settings for Wi-Fi and Bluetooth. */ -public class ScanningSettings extends SettingsPreferenceFragment { +public class ScanningSettings extends SettingsPreferenceFragment implements Indexable { private static final String KEY_WIFI_SCAN_ALWAYS_AVAILABLE = "wifi_always_scanning"; private static final String KEY_BLUETOOTH_SCAN_ALWAYS_AVAILABLE = "bluetooth_always_scanning"; @@ -56,13 +63,13 @@ public class ScanningSettings extends SettingsPreferenceFragment { private void initPreferences() { final SwitchPreference wifiScanAlwaysAvailable = - (SwitchPreference) findPreference(KEY_WIFI_SCAN_ALWAYS_AVAILABLE); + (SwitchPreference) findPreference(KEY_WIFI_SCAN_ALWAYS_AVAILABLE); wifiScanAlwaysAvailable.setChecked(Global.getInt(getContentResolver(), - Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1); + Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1); final SwitchPreference bleScanAlwaysAvailable = - (SwitchPreference) findPreference(KEY_BLUETOOTH_SCAN_ALWAYS_AVAILABLE); + (SwitchPreference) findPreference(KEY_BLUETOOTH_SCAN_ALWAYS_AVAILABLE); bleScanAlwaysAvailable.setChecked(Global.getInt(getContentResolver(), - Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1); + Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1); } @Override @@ -81,4 +88,18 @@ public class ScanningSettings extends SettingsPreferenceFragment { } return true; } + + /** + * For Search. + */ + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + @Override + public List getXmlResourcesToIndex( + Context context, boolean enabled) { + final SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.location_scanning; + return Arrays.asList(sir); + } + }; } diff --git a/src/com/android/settings/notification/ZenModeBehaviorSettings.java b/src/com/android/settings/notification/ZenModeBehaviorSettings.java index 1b5e69f8697..d03b0158860 100644 --- a/src/com/android/settings/notification/ZenModeBehaviorSettings.java +++ b/src/com/android/settings/notification/ZenModeBehaviorSettings.java @@ -18,7 +18,9 @@ package com.android.settings.notification; import android.app.NotificationManager; import android.app.NotificationManager.Policy; +import android.content.Context; import android.os.Bundle; +import android.provider.SearchIndexableResource; import android.provider.Settings; import android.service.notification.ZenModeConfig; import android.support.v14.preference.SwitchPreference; @@ -30,8 +32,13 @@ import android.util.Log; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; -public class ZenModeBehaviorSettings extends ZenModeSettingsBase { +import java.util.Arrays; +import java.util.List; + +public class ZenModeBehaviorSettings extends ZenModeSettingsBase implements Indexable { private static final String KEY_ALARMS = "zen_mode_alarms"; private static final String KEY_MEDIA = "zen_mode_media"; private static final String KEY_REMINDERS = "zen_mode_reminders"; @@ -303,4 +310,18 @@ public class ZenModeBehaviorSettings extends ZenModeSettingsBase { NotificationManager.from(mContext).setNotificationPolicy(mPolicy); } + /** + * For Search. + */ + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + @Override + public List getXmlResourcesToIndex( + Context context, boolean enabled) { + final SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.zen_mode_behavior_settings; + return Arrays.asList(sir); + } + }; + } diff --git a/src/com/android/settings/notification/ZenModeSettings.java b/src/com/android/settings/notification/ZenModeSettings.java index f112c1b9b26..7f9a7c34940 100644 --- a/src/com/android/settings/notification/ZenModeSettings.java +++ b/src/com/android/settings/notification/ZenModeSettings.java @@ -29,6 +29,7 @@ import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.content.res.Resources; import android.os.Bundle; +import android.provider.SearchIndexableResource; import android.provider.Settings; import android.service.notification.ConditionProviderService; import android.service.notification.ZenModeConfig; @@ -41,6 +42,8 @@ import android.view.View; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; import com.android.settings.utils.ManagedServiceSettings; import com.android.settings.utils.ZenServiceListing; import com.android.settingslib.TwoTargetPreference; @@ -52,7 +55,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -public class ZenModeSettings extends ZenModeSettingsBase { +public class ZenModeSettings extends ZenModeSettingsBase implements Indexable { public static final String KEY_VISUAL_SETTINGS = "zen_mode_visual_interruptions_settings"; private static final String KEY_BEHAVIOR_SETTINGS = "zen_mode_behavior_settings"; @@ -499,4 +502,17 @@ public class ZenModeSettings extends ZenModeSettingsBase { return type + rule.getName().toString(); } }; + /** + * For Search. + */ + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + @Override + public List getXmlResourcesToIndex( + Context context, boolean enabled) { + final SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.zen_mode_settings; + return Arrays.asList(sir); + } + }; } diff --git a/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java b/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java index aa2784804c6..474992c1c91 100644 --- a/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java +++ b/src/com/android/settings/notification/ZenModeVisualInterruptionSettings.java @@ -18,7 +18,9 @@ package com.android.settings.notification; import android.app.NotificationManager; import android.app.NotificationManager.Policy; +import android.content.Context; import android.os.Bundle; +import android.provider.SearchIndexableResource; import android.support.v14.preference.SwitchPreference; import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceScreen; @@ -26,8 +28,13 @@ import android.util.Log; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; -public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase { +import java.util.Arrays; +import java.util.List; + +public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase implements Indexable { private static final String KEY_SCREEN_OFF = "screenOff"; private static final String KEY_SCREEN_ON = "screenOn"; @@ -122,4 +129,18 @@ public class ZenModeVisualInterruptionSettings extends ZenModeSettingsBase { suppressedVisualEffects); NotificationManager.from(mContext).setNotificationPolicy(mPolicy); } + + /** + * For Search. + */ + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + @Override + public List getXmlResourcesToIndex( + Context context, boolean enabled) { + final SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.zen_mode_visual_interruptions_settings; + return Arrays.asList(sir); + } + }; } diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index be79daa12a9..7252e2d492b 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -26,7 +26,6 @@ import com.android.settings.DeviceInfoSettings; import com.android.settings.DisplaySettings; import com.android.settings.EncryptionAndCredential; import com.android.settings.LegalSettings; -import com.android.settings.R; import com.android.settings.ScreenPinningSettings; import com.android.settings.SecuritySettings; import com.android.settings.accessibility.AccessibilitySettings; @@ -41,7 +40,6 @@ import com.android.settings.backup.BackupSettingsActivity; import com.android.settings.backup.BackupSettingsFragment; import com.android.settings.bluetooth.BluetoothSettings; import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment; -import com.android.settings.datausage.DataPlanUsageSummary; import com.android.settings.datausage.DataUsageMeteredSettings; import com.android.settings.datausage.DataUsageSummary; import com.android.settings.deletionhelper.AutomaticStorageManagerSettings; @@ -109,15 +107,15 @@ public final class SearchIndexableResources { static final HashMap sResMap = new HashMap<>(); @VisibleForTesting - static void addIndex(Class indexClass, @XmlRes int xmlResId) { - addIndex(indexClass, xmlResId, null /* targetAction */); + static void addIndex(Class indexClass) { + addIndex(indexClass, null /* targetAction */); } @VisibleForTesting - static void addIndex(Class indexClass, @XmlRes int xmlResId, String targetAction) { + static void addIndex(Class indexClass, String targetAction) { String className = indexClass.getName(); - SearchIndexableResource resource = new SearchIndexableResource(0, xmlResId, className, - NO_RES_ID); + SearchIndexableResource resource = new SearchIndexableResource( + 0 /* rank */, NO_RES_ID, className, NO_RES_ID); if (!TextUtils.isEmpty(targetAction)) { resource.intentAction = targetAction; @@ -128,75 +126,73 @@ public final class SearchIndexableResources { } static { - addIndex(WifiSettings.class, NO_RES_ID); - addIndex(NetworkDashboardFragment.class, NO_RES_ID); - addIndex(ConfigureWifiSettings.class, NO_RES_ID); - addIndex(SavedAccessPointsWifiSettings.class, NO_RES_ID); - addIndex(BluetoothSettings.class, NO_RES_ID); - addIndex(SimSettings.class, NO_RES_ID); - addIndex(DataPlanUsageSummary.class, NO_RES_ID); - addIndex(DataUsageSummary.class, NO_RES_ID); - addIndex(DataUsageMeteredSettings.class, NO_RES_ID); - addIndex(ScreenZoomSettings.class, NO_RES_ID); - addIndex(DisplaySettings.class, NO_RES_ID, "android.settings.DISPLAY_SETTINGS"); - addIndex(AmbientDisplaySettings.class, NO_RES_ID); - addIndex(WallpaperTypeSettings.class, NO_RES_ID); - addIndex(AppAndNotificationDashboardFragment.class, NO_RES_ID); - addIndex(SoundSettings.class, NO_RES_ID, "android.settings.SOUND_SETTINGS"); - addIndex(ZenModeSettings.class, R.xml.zen_mode_settings); - addIndex(StorageSettings.class, NO_RES_ID); - addIndex(PowerUsageAdvanced.class, NO_RES_ID); - addIndex(DefaultAppSettings.class, NO_RES_ID); - addIndex(ManageAssist.class, NO_RES_ID); - addIndex(SpecialAccessSettings.class, NO_RES_ID); - addIndex(UserSettings.class, NO_RES_ID); - addIndex(AssistGestureSettings.class, NO_RES_ID); - addIndex(PickupGestureSettings.class, NO_RES_ID); - addIndex(DoubleTapScreenSettings.class, NO_RES_ID); - addIndex(DoubleTapPowerSettings.class, NO_RES_ID); - addIndex(DoubleTwistGestureSettings.class, NO_RES_ID); - addIndex(SwipeToNotificationSettings.class, NO_RES_ID); - addIndex(GestureSettings.class, NO_RES_ID); - addIndex(LanguageAndInputSettings.class, NO_RES_ID); - addIndex(LocationSettings.class, R.xml.location_settings); - addIndex(ScanningSettings.class, R.xml.location_scanning); - addIndex(SecuritySettings.class, NO_RES_ID); - addIndex(EncryptionAndCredential.class, NO_RES_ID); - addIndex(ScreenPinningSettings.class, NO_RES_ID); - addIndex(UserAndAccountDashboardFragment.class, NO_RES_ID); - addIndex(VirtualKeyboardFragment.class, NO_RES_ID); - addIndex(AvailableVirtualKeyboardFragment.class, NO_RES_ID); - addIndex(PhysicalKeyboardFragment.class, NO_RES_ID); - addIndex(BackupSettingsActivity.class, NO_RES_ID); - addIndex(BackupSettingsFragment.class, NO_RES_ID); - addIndex(DateTimeSettings.class, NO_RES_ID); - addIndex(AccessibilitySettings.class, NO_RES_ID); - addIndex(PrintSettingsFragment.class, NO_RES_ID); - addIndex(DevelopmentSettingsDashboardFragment.class, NO_RES_ID); - addIndex(DeviceInfoSettings.class, NO_RES_ID); - addIndex(Status.class, NO_RES_ID); - addIndex(LegalSettings.class, NO_RES_ID); - addIndex(SystemDashboardFragment.class, NO_RES_ID); - addIndex(ResetDashboardFragment.class, NO_RES_ID); - addIndex(StorageDashboardFragment.class, NO_RES_ID); - addIndex(ConnectedDeviceDashboardFragment.class, NO_RES_ID); - addIndex(EnterprisePrivacySettings.class, NO_RES_ID); - addIndex(PaymentSettings.class, NO_RES_ID); - addIndex(TextToSpeechSettings.class, NO_RES_ID); - addIndex(TtsEnginePreferenceFragment.class, NO_RES_ID); - addIndex(MagnificationPreferenceFragment.class, NO_RES_ID); - addIndex(AccessibilityShortcutPreferenceFragment.class, NO_RES_ID); - addIndex(ChannelImportanceSettings.class, NO_RES_ID); - addIndex(DreamSettings.class, NO_RES_ID); - addIndex(SupportDashboardActivity.class, NO_RES_ID); - addIndex(AutomaticStorageManagerSettings.class, NO_RES_ID); - addIndex(ConfigureNotificationSettings.class, R.xml.configure_notification_settings); - addIndex(ZenModeBehaviorSettings.class, R.xml.zen_mode_behavior_settings); - addIndex(PowerUsageSummary.class, R.xml.power_usage_summary); - addIndex(BatterySaverSettings.class, R.xml.battery_saver_settings); - addIndex(LockscreenDashboardFragment.class, R.xml.security_lockscreen_settings); - addIndex(ZenModeVisualInterruptionSettings.class, - R.xml.zen_mode_visual_interruptions_settings); + addIndex(WifiSettings.class); + addIndex(NetworkDashboardFragment.class); + addIndex(ConfigureWifiSettings.class); + addIndex(SavedAccessPointsWifiSettings.class); + addIndex(BluetoothSettings.class); + addIndex(SimSettings.class); + addIndex(DataUsageSummary.class); + addIndex(DataUsageMeteredSettings.class); + addIndex(ScreenZoomSettings.class); + addIndex(DisplaySettings.class, "android.settings.DISPLAY_SETTINGS"); + addIndex(AmbientDisplaySettings.class); + addIndex(WallpaperTypeSettings.class); + addIndex(AppAndNotificationDashboardFragment.class); + addIndex(SoundSettings.class, "android.settings.SOUND_SETTINGS"); + addIndex(ZenModeSettings.class); + addIndex(StorageSettings.class); + addIndex(PowerUsageAdvanced.class); + addIndex(DefaultAppSettings.class); + addIndex(ManageAssist.class); + addIndex(SpecialAccessSettings.class); + addIndex(UserSettings.class); + addIndex(AssistGestureSettings.class); + addIndex(PickupGestureSettings.class); + addIndex(DoubleTapScreenSettings.class); + addIndex(DoubleTapPowerSettings.class); + addIndex(DoubleTwistGestureSettings.class); + addIndex(SwipeToNotificationSettings.class); + addIndex(GestureSettings.class); + addIndex(LanguageAndInputSettings.class); + addIndex(LocationSettings.class); + addIndex(ScanningSettings.class); + addIndex(SecuritySettings.class); + addIndex(EncryptionAndCredential.class); + addIndex(ScreenPinningSettings.class); + addIndex(UserAndAccountDashboardFragment.class); + addIndex(VirtualKeyboardFragment.class); + addIndex(AvailableVirtualKeyboardFragment.class); + addIndex(PhysicalKeyboardFragment.class); + addIndex(BackupSettingsActivity.class); + addIndex(BackupSettingsFragment.class); + addIndex(DateTimeSettings.class); + addIndex(AccessibilitySettings.class); + addIndex(PrintSettingsFragment.class); + addIndex(DevelopmentSettingsDashboardFragment.class); + addIndex(DeviceInfoSettings.class); + addIndex(Status.class); + addIndex(LegalSettings.class); + addIndex(SystemDashboardFragment.class); + addIndex(ResetDashboardFragment.class); + addIndex(StorageDashboardFragment.class); + addIndex(ConnectedDeviceDashboardFragment.class); + addIndex(EnterprisePrivacySettings.class); + addIndex(PaymentSettings.class); + addIndex(TextToSpeechSettings.class); + addIndex(TtsEnginePreferenceFragment.class); + addIndex(MagnificationPreferenceFragment.class); + addIndex(AccessibilityShortcutPreferenceFragment.class); + addIndex(ChannelImportanceSettings.class); + addIndex(DreamSettings.class); + addIndex(SupportDashboardActivity.class); + addIndex(AutomaticStorageManagerSettings.class); + addIndex(ConfigureNotificationSettings.class); + addIndex(PowerUsageSummary.class); + addIndex(BatterySaverSettings.class); + addIndex(LockscreenDashboardFragment.class); + addIndex(ZenModeBehaviorSettings.class); + addIndex(ZenModeVisualInterruptionSettings.class); } private SearchIndexableResources() { diff --git a/src/com/android/settings/search/indexing/IndexDataConverter.java b/src/com/android/settings/search/indexing/IndexDataConverter.java index 8010db9bfc0..2b875c3f112 100644 --- a/src/com/android/settings/search/indexing/IndexDataConverter.java +++ b/src/com/android/settings/search/indexing/IndexDataConverter.java @@ -30,7 +30,6 @@ import android.util.Log; import android.util.Xml; import com.android.settings.core.PreferenceControllerMixin; - import com.android.settings.search.DatabaseIndexingUtils; import com.android.settings.search.Indexable; import com.android.settings.search.ResultPayload; @@ -44,7 +43,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Set; @@ -310,8 +308,8 @@ public class IndexDataConverter { } catch (XmlPullParserException e) { Log.w(LOG_TAG, "XML Error parsing PreferenceScreen: ", e); } catch (IOException e) { - Log.w(LOG_TAG, "IO Error parsing PreferenceScreen: " , e); - } catch (Resources.NotFoundException e ) { + Log.w(LOG_TAG, "IO Error parsing PreferenceScreen: ", e); + } catch (Resources.NotFoundException e) { Log.w(LOG_TAG, "Resoucre not found error parsing PreferenceScreen: ", e); } finally { if (parser != null) parser.close(); diff --git a/tests/robotests/assets/grandfather_not_implementing_indexable b/tests/robotests/assets/grandfather_not_implementing_indexable index d4a8d2d1645..091ba1242f4 100644 --- a/tests/robotests/assets/grandfather_not_implementing_indexable +++ b/tests/robotests/assets/grandfather_not_implementing_indexable @@ -1,5 +1,4 @@ com.android.settings.location.LocationMode -com.android.settings.notification.ZenModeVisualInterruptionSettings com.android.settings.accessibility.ToggleScreenMagnificationPreferenceFragment com.android.settings.deviceinfo.SimStatus com.android.settings.deviceinfo.PrivateVolumeForget @@ -23,18 +22,16 @@ com.android.settings.datausage.DataSaverSummary com.android.settings.notification.ChannelNotificationSettings com.android.settings.notification.ChannelGroupNotificationSettings com.android.settings.datausage.AppDataUsage +com.android.settings.datausage.DataPlanUsageSummary com.android.settings.accessibility.FontSizePreferenceFragmentForSetupWizard com.android.settings.applications.ManageDomainUrls com.android.settings.applications.WriteSettingsDetails -com.android.settings.location.LocationSettings com.android.settings.applications.ProcessStatsSummary com.android.settings.users.RestrictedProfileSettings com.android.settings.accounts.ChooseAccountActivity com.android.settings.accounts.ManagedProfileSettings com.android.settings.accessibility.ToggleAutoclickPreferenceFragment com.android.settings.applications.AppLaunchSettings -com.android.settings.fuelgauge.BatterySaverSettings -com.android.settings.location.ScanningSettings com.android.settings.applications.ProcessStatsUi com.android.settings.notification.ZenModeScheduleRuleSettings com.android.settings.datausage.BillingCycleSettings @@ -68,8 +65,6 @@ com.android.settings.applications.PremiumSmsAccess com.android.settings.applications.UsageAccessDetails com.android.settings.applications.AppStorageSettings com.android.settings.notification.NotificationAccessSettings -com.android.settings.notification.ZenModeSettings -com.android.settings.notification.ZenModeBehaviorSettings com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment com.android.settings.localepicker.LocaleListEditor com.android.settings.applications.ExternalSourcesDetails diff --git a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java b/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java index 72e0b10e935..748c3173793 100644 --- a/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java +++ b/tests/robotests/src/com/android/settings/datausage/DataPlanUsageSummaryTest.java @@ -33,17 +33,13 @@ import android.net.wifi.WifiManager; import com.android.settings.R; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settings.testutils.XmlTestUtils; -import com.android.settings.testutils.shadow.ShadowDataUsageUtils; import com.android.settingslib.NetworkPolicyEditor; import java.util.ArrayList; -import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; import org.robolectric.shadows.ShadowApplication; import org.robolectric.util.ReflectionHelpers; @@ -128,53 +124,6 @@ public class DataPlanUsageSummaryTest { assertThat(mDataUsageSummary.isMetered(mWifiConfiguration)).isFalse(); } - @Test - @Config(shadows = ShadowDataUsageUtils.class) - public void testNonIndexableKeys_existInXmlLayout() { - final Context context = RuntimeEnvironment.application; - ShadowDataUsageUtils.IS_WIFI_SUPPORTED = true; - ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = true; - final List niks = DataPlanUsageSummary.SEARCH_INDEX_DATA_PROVIDER - .getNonIndexableKeys(context); - final List keys = new ArrayList<>(); - - keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.data_usage_wifi)); - keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context, R.xml.data_usage)); - keys.addAll(XmlTestUtils.getKeysFromPreferenceXml(context, - R.xml.data_plan_usage_cell_data_preference_screen)); - - assertThat(keys).containsAllIn(niks); - } - - @Test - @Config(shadows = ShadowDataUsageUtils.class) - public void testNonIndexableKeys_hasMobileData_hasWifi_allNonIndexableKeysAdded() { - ShadowDataUsageUtils.IS_WIFI_SUPPORTED = false; - ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = false; - List keys = DataPlanUsageSummary.SEARCH_INDEX_DATA_PROVIDER - .getNonIndexableKeys(mContext); - - // Mobile data keys - assertThat(keys).contains(DataPlanUsageSummary.KEY_MOBILE_USAGE_TITLE); - assertThat(keys).contains(DataPlanUsageSummary.KEY_MOBILE_DATA_USAGE_TOGGLE); - - // Wifi keys - assertThat(keys).contains(DataPlanUsageSummary.KEY_WIFI_DATA_USAGE); - assertThat(keys).contains(DataPlanUsageSummary.KEY_NETWORK_RESTRICTIONS); - assertThat(keys).contains(DataPlanUsageSummary.KEY_WIFI_USAGE_TITLE); - } - - @Test - @Config(shadows = ShadowDataUsageUtils.class) - public void testNonIndexableKeys_noMobile_noWifi_limitedNonIndexableKeys() { - ShadowDataUsageUtils.IS_WIFI_SUPPORTED = true; - ShadowDataUsageUtils.IS_MOBILE_DATA_SUPPORTED = true; - List keys = DataPlanUsageSummary.SEARCH_INDEX_DATA_PROVIDER - .getNonIndexableKeys(mContext); - - assertThat(keys).containsExactly(DataPlanUsageSummary.KEY_WIFI_USAGE_TITLE); - } - private void initTest() { mDataUsageSummary = new DataPlanUsageSummary(); mPolicyEditor = mock(NetworkPolicyEditor.class); diff --git a/tests/robotests/src/com/android/settings/development/CameraHalHdrPlusPreferenceControllerV2Test.java b/tests/robotests/src/com/android/settings/development/CameraHalHdrplusPreferenceControllerV2Test.java similarity index 75% rename from tests/robotests/src/com/android/settings/development/CameraHalHdrPlusPreferenceControllerV2Test.java rename to tests/robotests/src/com/android/settings/development/CameraHalHdrplusPreferenceControllerV2Test.java index f28fd6e2671..e0e137c3b19 100644 --- a/tests/robotests/src/com/android/settings/development/CameraHalHdrPlusPreferenceControllerV2Test.java +++ b/tests/robotests/src/com/android/settings/development/CameraHalHdrplusPreferenceControllerV2Test.java @@ -42,7 +42,7 @@ import org.robolectric.annotation.Config; @RunWith(SettingsRobolectricTestRunner.class) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = {SettingsShadowSystemProperties.class}) -public class CameraHalHdrPlusPreferenceControllerV2Test { +public class CameraHalHdrplusPreferenceControllerV2Test { @Mock private PreferenceScreen mScreen; @@ -50,7 +50,7 @@ public class CameraHalHdrPlusPreferenceControllerV2Test { private SwitchPreference mPreference; private Context mContext; - private CameraHalHdrPlusPreferenceControllerV2 mController; + private CameraHalHdrplusPreferenceControllerV2 mController; static final String USERDEBUG_BUILD = "userdebug"; @@ -58,7 +58,7 @@ public class CameraHalHdrPlusPreferenceControllerV2Test { public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; - mController = new CameraHalHdrPlusPreferenceControllerV2(mContext); + mController = new CameraHalHdrplusPreferenceControllerV2(mContext); when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); when(mPreference.getKey()).thenReturn(mController.getPreferenceKey()); mController.displayPreference(mScreen); @@ -73,18 +73,18 @@ public class CameraHalHdrPlusPreferenceControllerV2Test { @Config(qualifiers = "mcc999") public void isAvailable_withConfigNoShowAndUserDebugBuild_shouldReturnFalse() { SettingsShadowSystemProperties.set( - CameraHalHdrPlusPreferenceControllerV2.BUILD_TYPE, USERDEBUG_BUILD); + CameraHalHdrplusPreferenceControllerV2.BUILD_TYPE, USERDEBUG_BUILD); assertThat(mController.isAvailable()).isFalse(); } @Test - public void updateState_cameraHalHdrPlusEnabled_shouldCheckedPreference() { + public void updateState_cameraHalHdrplusEnabled_shouldCheckedPreference() { SettingsShadowSystemProperties.set( - CameraHalHdrPlusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, - CameraHalHdrPlusPreferenceControllerV2.ENABLED); + CameraHalHdrplusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, + CameraHalHdrplusPreferenceControllerV2.ENABLED); SettingsShadowSystemProperties.set( - CameraHalHdrPlusPreferenceControllerV2.BUILD_TYPE, USERDEBUG_BUILD); + CameraHalHdrplusPreferenceControllerV2.BUILD_TYPE, USERDEBUG_BUILD); mController.updateState(mPreference); @@ -92,12 +92,12 @@ public class CameraHalHdrPlusPreferenceControllerV2Test { } @Test - public void updateState_cameraHalHdrPlusEnabled_shouldUncheckedPreference() { + public void updateState_cameraHalHdrplusEnabled_shouldUncheckedPreference() { SettingsShadowSystemProperties.set( - CameraHalHdrPlusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, - CameraHalHdrPlusPreferenceControllerV2.DISABLED); + CameraHalHdrplusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, + CameraHalHdrplusPreferenceControllerV2.DISABLED); SettingsShadowSystemProperties.set( - CameraHalHdrPlusPreferenceControllerV2.BUILD_TYPE, USERDEBUG_BUILD); + CameraHalHdrplusPreferenceControllerV2.BUILD_TYPE, USERDEBUG_BUILD); mController.updateState(mPreference); @@ -108,20 +108,20 @@ public class CameraHalHdrPlusPreferenceControllerV2Test { public void onPreferenceChange_preferenceChecked_shouldEnableCameraHalHdrplus() { mController.onPreferenceChange(mPreference, true /* new value */); - assertThat(CameraHalHdrPlusPreferenceControllerV2.ENABLED).isEqualTo( + assertThat(CameraHalHdrplusPreferenceControllerV2.ENABLED).isEqualTo( SystemProperties.get( - CameraHalHdrPlusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, - CameraHalHdrPlusPreferenceControllerV2.DISABLED)); + CameraHalHdrplusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, + CameraHalHdrplusPreferenceControllerV2.DISABLED)); } @Test public void handlePreferenceTreeClick_preferenceUnchecked_shouldDisableCameraHalHdrplus() { mController.onPreferenceChange(mPreference, false /* new value */); - assertThat(CameraHalHdrPlusPreferenceControllerV2.DISABLED).isEqualTo( + assertThat(CameraHalHdrplusPreferenceControllerV2.DISABLED).isEqualTo( SystemProperties.get( - CameraHalHdrPlusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, - CameraHalHdrPlusPreferenceControllerV2.DISABLED)); + CameraHalHdrplusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, + CameraHalHdrplusPreferenceControllerV2.DISABLED)); } @Test @@ -137,9 +137,9 @@ public class CameraHalHdrPlusPreferenceControllerV2Test { verify(mPreference).setEnabled(false); verify(mPreference).setChecked(false); - assertThat(CameraHalHdrPlusPreferenceControllerV2.DISABLED).isEqualTo( + assertThat(CameraHalHdrplusPreferenceControllerV2.DISABLED).isEqualTo( SystemProperties.get( - CameraHalHdrPlusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, - CameraHalHdrPlusPreferenceControllerV2.DISABLED)); + CameraHalHdrplusPreferenceControllerV2.PROPERTY_CAMERA_HAL_HDRPLUS, + CameraHalHdrplusPreferenceControllerV2.DISABLED)); } } diff --git a/tests/robotests/src/com/android/settings/display/ColorModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ColorModePreferenceControllerTest.java deleted file mode 100644 index 00d910eb82c..00000000000 --- a/tests/robotests/src/com/android/settings/display/ColorModePreferenceControllerTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2017 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.display; - -import android.content.Context; -import android.os.IBinder; -import android.support.v14.preference.SwitchPreference; -import android.support.v7.preference.PreferenceScreen; -import com.android.settings.testutils.SettingsRobolectricTestRunner; -import com.android.settings.TestConfig; -import com.android.settings.testutils.shadow.SettingsShadowSystemProperties; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.robolectric.annotation.Config; -import org.robolectric.util.ReflectionHelpers; - -import static com.google.common.truth.Truth.assertThat; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@RunWith(SettingsRobolectricTestRunner.class) -@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) -public class ColorModePreferenceControllerTest { - @Mock - private ColorModePreferenceController.ConfigurationWrapper mConfigWrapper; - @Mock - private SwitchPreference mPreference; - @Mock - private PreferenceScreen mScreen; - @Mock - private Context mContext; - @Mock - private IBinder mSurfaceFlinger; - - private ColorModePreferenceController mController; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - SettingsShadowSystemProperties.clear(); - - mController = new ColorModePreferenceController(mContext); - ReflectionHelpers.setField(mController, "mSurfaceFlinger", mSurfaceFlinger); - ReflectionHelpers.setField(mController, "mConfigWrapper", mConfigWrapper); - - when(mConfigWrapper.isScreenWideColorGamut()).thenReturn(true); - - when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); - when(mPreference.getKey()).thenReturn(mController.getPreferenceKey()); - } - - @Config(shadows = {SettingsShadowSystemProperties.class}) - @Test - public void shouldCheckPreference() { - SettingsShadowSystemProperties.set( - ColorModePreferenceController.PERSISTENT_PROPERTY_SATURATION, - Float.toString(ColorModePreferenceController.COLOR_SATURATION_VIVID)); - - mController.updateState(mPreference); - - verify(mPreference).setChecked(true); - } - - @Config(shadows = {SettingsShadowSystemProperties.class}) - @Test - public void shouldUncheckPreference() { - SettingsShadowSystemProperties.set( - ColorModePreferenceController.PERSISTENT_PROPERTY_SATURATION, - Float.toString(ColorModePreferenceController.COLOR_SATURATION_DEFAULT)); - - mController.updateState(mPreference); - - verify(mPreference).setChecked(false); - } - - @Config(shadows = {SettingsShadowSystemProperties.class}) - @Test - public void shouldBoostSaturationOnCheck() { - mController.onPreferenceChange(mPreference, true); - - String saturation = SettingsShadowSystemProperties - .get(ColorModePreferenceController.PERSISTENT_PROPERTY_SATURATION); - assertThat(saturation) - .isEqualTo(Float.toString(ColorModePreferenceController.COLOR_SATURATION_VIVID)); - } - - @Config(shadows = {SettingsShadowSystemProperties.class}) - @Test - public void shouldResetSaturationOnUncheck() { - mController.onPreferenceChange(mPreference, false); - - String saturation = SettingsShadowSystemProperties - .get(ColorModePreferenceController.PERSISTENT_PROPERTY_SATURATION); - assertThat(saturation) - .isEqualTo(Float.toString(ColorModePreferenceController.COLOR_SATURATION_DEFAULT)); - } -} diff --git a/tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java new file mode 100644 index 00000000000..435f4f21a67 --- /dev/null +++ b/tests/robotests/src/com/android/settings/display/ColorModePreferenceFragmentTest.java @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2017 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.display; + +import static com.google.common.truth.Truth.assertThat; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; + +import android.app.IActivityManager; +import android.content.res.Configuration; +import android.os.IBinder; +import android.os.RemoteException; + +import com.android.internal.logging.nano.MetricsProto; + +import com.android.settings.TestConfig; +import com.android.settings.testutils.SettingsRobolectricTestRunner; +import com.android.settings.testutils.shadow.SettingsShadowSystemProperties; +import com.android.settings.widget.RadioButtonPickerFragment; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; +import org.robolectric.util.ReflectionHelpers; + +import java.util.List; + +@RunWith(SettingsRobolectricTestRunner.class) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +public class ColorModePreferenceFragmentTest { + @Mock + private IBinder mSurfaceFlinger; + @Mock + private IActivityManager mActivityManager; + + private ColorModePreferenceFragment mFragment; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + SettingsShadowSystemProperties.clear(); + + mFragment = spy(new ColorModePreferenceFragment()); + doReturn(RuntimeEnvironment.application).when(mFragment).getContext(); + doNothing().when(mFragment).updateConfiguration(); + + ReflectionHelpers.setField(mFragment, "mSurfaceFlinger", mSurfaceFlinger); + ReflectionHelpers.setField(mFragment, "mActivityManager", mActivityManager); + } + + @Test + public void verifyMetricsConstant() { + assertThat(mFragment.getMetricsCategory()) + .isEqualTo(MetricsProto.MetricsEvent.COLOR_MODE_SETTINGS); + } + + @Test + public void getCandidates() { + List candidates = + mFragment.getCandidates(); + + assertThat(candidates.size()).isEqualTo(3); + assertThat(candidates.get(0).getKey()) + .isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_NATURAL); + assertThat(candidates.get(1).getKey()) + .isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_BOOSTED); + assertThat(candidates.get(2).getKey()) + .isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED); + } + + @Config(shadows = {SettingsShadowSystemProperties.class}) + @Test + public void getKey_natural() { + SettingsShadowSystemProperties.set( + ColorModePreferenceFragment.PERSISTENT_PROPERTY_SATURATION, + Float.toString(ColorModePreferenceFragment.COLOR_SATURATION_NATURAL)); + SettingsShadowSystemProperties.set( + ColorModePreferenceFragment.PERSISTENT_PROPERTY_NATIVE_MODE, "0"); + + assertThat(mFragment.getDefaultKey()) + .isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_NATURAL); + } + + @Config(shadows = {SettingsShadowSystemProperties.class}) + @Test + public void getKey_boosted() { + SettingsShadowSystemProperties.set( + ColorModePreferenceFragment.PERSISTENT_PROPERTY_SATURATION, + Float.toString(ColorModePreferenceFragment.COLOR_SATURATION_BOOSTED)); + SettingsShadowSystemProperties.set( + ColorModePreferenceFragment.PERSISTENT_PROPERTY_NATIVE_MODE, "0"); + + assertThat(mFragment.getDefaultKey()) + .isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_BOOSTED); + } + + @Config(shadows = {SettingsShadowSystemProperties.class}) + @Test + public void getKey_saturated() { + SettingsShadowSystemProperties.set( + ColorModePreferenceFragment.PERSISTENT_PROPERTY_NATIVE_MODE, "1"); + + assertThat(mFragment.getDefaultKey()) + .isEqualTo(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED); + } + + @Config(shadows = {SettingsShadowSystemProperties.class}) + @Test + public void setKey_natural() { + mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_NATURAL); + + String saturation = SettingsShadowSystemProperties + .get(ColorModePreferenceFragment.PERSISTENT_PROPERTY_SATURATION); + assertThat(saturation) + .isEqualTo(Float.toString(ColorModePreferenceFragment.COLOR_SATURATION_NATURAL)); + + String nativeMode = SettingsShadowSystemProperties + .get(ColorModePreferenceFragment.PERSISTENT_PROPERTY_NATIVE_MODE); + assertThat(nativeMode).isEqualTo("0"); + } + + @Config(shadows = {SettingsShadowSystemProperties.class}) + @Test + public void setKey_boosted() { + mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_BOOSTED); + + String saturation = SettingsShadowSystemProperties + .get(ColorModePreferenceFragment.PERSISTENT_PROPERTY_SATURATION); + assertThat(saturation) + .isEqualTo(Float.toString(ColorModePreferenceFragment.COLOR_SATURATION_BOOSTED)); + + String nativeMode = SettingsShadowSystemProperties + .get(ColorModePreferenceFragment.PERSISTENT_PROPERTY_NATIVE_MODE); + assertThat(nativeMode).isEqualTo("0"); + } + + @Config(shadows = {SettingsShadowSystemProperties.class}) + @Test + public void setKey_saturated() { + mFragment.setDefaultKey(ColorModePreferenceFragment.KEY_COLOR_MODE_SATURATED); + + String saturation = SettingsShadowSystemProperties + .get(ColorModePreferenceFragment.PERSISTENT_PROPERTY_SATURATION); + assertThat(saturation) + .isEqualTo(Float.toString(ColorModePreferenceFragment.COLOR_SATURATION_NATURAL)); + + String nativeMode = SettingsShadowSystemProperties + .get(ColorModePreferenceFragment.PERSISTENT_PROPERTY_NATIVE_MODE); + assertThat(nativeMode).isEqualTo("1"); + } +} diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java index 1e173a2ba52..0e32f6bd16f 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/BatterySaverSettingsTest.java @@ -18,7 +18,9 @@ package com.android.settings.fuelgauge; import static com.google.common.truth.Truth.assertThat; import android.content.Context; +import android.provider.SearchIndexableResource; +import com.android.settings.R; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settings.widget.SwitchBar; @@ -30,6 +32,8 @@ import org.mockito.MockitoAnnotations; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; +import java.util.List; + @RunWith(SettingsRobolectricTestRunner.class) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) public class BatterySaverSettingsTest { @@ -58,4 +62,13 @@ public class BatterySaverSettingsTest { assertThat(mBatterySaverSettings.mSwitchBar.isEnabled()).isTrue(); } + + @Test + public void searchProvider_shouldIndexDefaultXml() { + final List sir = mBatterySaverSettings.SEARCH_INDEX_DATA_PROVIDER + .getXmlResourcesToIndex(mContext, true /* enabled */); + + assertThat(sir).hasSize(1); + assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.battery_saver_settings); + } } diff --git a/tests/robotests/src/com/android/settings/location/ScanningSettingsTest.java b/tests/robotests/src/com/android/settings/location/ScanningSettingsTest.java new file mode 100644 index 00000000000..47b81bf93a6 --- /dev/null +++ b/tests/robotests/src/com/android/settings/location/ScanningSettingsTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2017 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.location; + +import static com.google.common.truth.Truth.assertThat; + +import android.content.Context; +import android.provider.SearchIndexableResource; + +import com.android.settings.R; +import com.android.settings.TestConfig; +import com.android.settings.testutils.SettingsRobolectricTestRunner; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RuntimeEnvironment; +import org.robolectric.annotation.Config; + +import java.util.List; + +@RunWith(SettingsRobolectricTestRunner.class) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +public class ScanningSettingsTest { + + private Context mContext; + private ScanningSettings mSettings; + + + @Before + public void setUp() { + mContext = RuntimeEnvironment.application; + mSettings = new ScanningSettings(); + } + + @Test + public void searchProvider_shouldIndexDefaultXml() { + final List sir = mSettings.SEARCH_INDEX_DATA_PROVIDER + .getXmlResourcesToIndex(mContext, true /* enabled */); + + assertThat(sir).hasSize(1); + assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.location_scanning); + } +} diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java index 1135d7c1b16..fa2c6b9a2e0 100644 --- a/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java +++ b/tests/robotests/src/com/android/settings/notification/ZenModeSettingsTest.java @@ -22,6 +22,7 @@ import static junit.framework.Assert.assertTrue; import android.app.NotificationManager; import android.content.Context; +import android.provider.SearchIndexableResource; import android.provider.Settings; import com.android.settings.R; @@ -34,16 +35,20 @@ import org.junit.runner.RunWith; import org.robolectric.RuntimeEnvironment; import org.robolectric.annotation.Config; +import java.util.List; + @RunWith(SettingsRobolectricTestRunner.class) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) public class ZenModeSettingsTest { private ZenModeSettings.SummaryBuilder mBuilder; private Context mContext; + private ZenModeSettings mSettings; @Before public void setUp() { mContext = RuntimeEnvironment.application.getApplicationContext(); + mSettings = new ZenModeSettings(); mBuilder = new ZenModeSettings.SummaryBuilder(mContext); } @@ -72,4 +77,13 @@ public class ZenModeSettingsTest { && result.indexOf(reminders) < result.indexOf(events)); } + @Test + public void searchProvider_shouldIndexDefaultXml() { + final List sir = mSettings.SEARCH_INDEX_DATA_PROVIDER + .getXmlResourcesToIndex(mContext, true /* enabled */); + + assertThat(sir).hasSize(1); + assertThat(sir.get(0).xmlResId).isEqualTo(R.xml.zen_mode_settings); + } + } diff --git a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java index 16debdf4337..0e3ce502c2f 100644 --- a/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java +++ b/tests/robotests/src/com/android/settings/search/SearchIndexableResourcesTest.java @@ -18,18 +18,15 @@ package com.android.settings.search; import static android.provider.SearchIndexablesContract.COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE; import static com.android.settings.search.SearchIndexableResources.NO_RES_ID; - import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.spy; -import android.annotation.XmlRes; import android.database.Cursor; import android.provider.SearchIndexableResource; - import android.text.TextUtils; -import com.android.settings.R; -import com.android.settings.testutils.SettingsRobolectricTestRunner; + import com.android.settings.TestConfig; +import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settings.wifi.WifiSettings; import org.junit.After; @@ -45,9 +42,6 @@ import java.util.Map; @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) public class SearchIndexableResourcesTest { - @XmlRes - private static final int XML_RES_ID = R.xml.physical_keyboard_settings; - Map sResMapCopy; @Before @@ -69,13 +63,13 @@ public class SearchIndexableResourcesTest { assertThat(SearchIndexableResources.getResourceByName("java.lang.String")).isNull(); final int beforeCount = SearchIndexableResources.values().size(); - SearchIndexableResources.addIndex(java.lang.String.class, XML_RES_ID); + SearchIndexableResources.addIndex(java.lang.String.class); final SearchIndexableResource index = SearchIndexableResources .getResourceByName("java.lang.String"); assertThat(index).isNotNull(); assertThat(index.className).isEqualTo("java.lang.String"); - assertThat(index.xmlResId).isEqualTo(XML_RES_ID); + assertThat(index.xmlResId).isEqualTo(NO_RES_ID); assertThat(index.iconResId).isEqualTo(NO_RES_ID); final int afterCount = SearchIndexableResources.values().size(); assertThat(afterCount).isEqualTo(beforeCount + 1); @@ -95,13 +89,13 @@ public class SearchIndexableResourcesTest { @Test public void testNonIndexableKeys_GetsKeyFromProvider() { SearchIndexableResources.sResMap.clear(); - SearchIndexableResources.addIndex(FakeIndexProvider.class, 0); + SearchIndexableResources.addIndex(FakeIndexProvider.class); SettingsSearchIndexablesProvider provider = spy(new SettingsSearchIndexablesProvider()); Cursor cursor = provider.queryNonIndexableKeys(null); boolean hasTestKey = false; - while(cursor.moveToNext()) { + while (cursor.moveToNext()) { String key = cursor.getString(COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE); if (TextUtils.equals(key, FakeIndexProvider.KEY)) { hasTestKey = true;