Loading src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java +1 −3 Original line number Diff line number Diff line Loading @@ -96,9 +96,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment { keys.add(NfcPreferenceController.KEY_TOGGLE_NFC); keys.add(NfcPreferenceController.KEY_ANDROID_BEAM_SETTINGS); } if (!pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { keys.add(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH); } return keys; } }; Loading src/com/android/settings/datausage/DataUsageSummary.java +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs private static final String KEY_LIMIT_SUMMARY = "limit_summary"; private static final String KEY_RESTRICT_BACKGROUND = "restrict_background"; private static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions"; private static final String KEY_WIFI_USAGE_TITLE = "wifi_category"; private DataUsageController mDataUsageController; private DataUsageInfoController mDataInfoController; Loading Loading @@ -491,6 +492,7 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs if (hasMobileData) { keys.add(KEY_RESTRICT_BACKGROUND); } keys.add(KEY_WIFI_USAGE_TITLE); return keys; } Loading src/com/android/settings/network/NetworkDashboardFragment.java +8 −0 Original line number Diff line number Diff line Loading @@ -142,5 +142,13 @@ public class NetworkDashboardFragment extends DashboardFragment implements sir.xmlResId = R.xml.network_and_internet; return Arrays.asList(sir); } @Override public List<String> getNonIndexableKeys(Context context) { List<String> keys = new ArrayList<>(); // Remove master switch as a result keys.add(WifiMasterSwitchPreferenceController.KEY_TOGGLE_WIFI); return keys; } }; } src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class WifiMasterSwitchPreferenceController extends PreferenceController implements SummaryUpdater.OnSummaryChangeListener, LifecycleObserver, OnResume, OnPause, OnStart, OnStop { private static final String KEY_TOGGLE_WIFI = "toggle_wifi"; public static final String KEY_TOGGLE_WIFI = "toggle_wifi"; private MasterSwitchPreference mWifiPreference; private WifiEnabler mWifiEnabler; Loading tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java +10 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController; import com.android.settings.nfc.NfcPreferenceController; import com.android.settings.SettingsRobolectricTestRunner; import com.android.settings.TestConfig; import com.android.settings.testutils.XmlTestUtils; import com.android.settingslib.drawer.CategoryKey; import org.junit.Before; Loading @@ -30,13 +31,12 @@ 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 java.util.List; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @RunWith(SettingsRobolectricTestRunner.class) Loading Loading @@ -92,20 +92,15 @@ public class ConnectedDeviceDashboardFragmentTest { } @Test public void testSearchIndexProvider_NoBluetooth_KeyAdded() { when(mManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(false); final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext); assertThat(keys).isNotNull(); assertThat(keys).contains(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH); } public void testNonIndexableKeys_existInXmlLayout() { final Context context = RuntimeEnvironment.application; when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(false); final List<String> niks = ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER .getNonIndexableKeys(context); final int xmlId = (new ConnectedDeviceDashboardFragment()).getPreferenceScreenResId(); @Test public void testSearchIndexProvider_Bluetooth_KeyNotAdded() { when(mManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(true); final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext); final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId); assertThat(keys).isNotNull(); assertThat(keys).doesNotContain(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH); assertThat(keys).containsAllIn(niks); } } Loading
src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragment.java +1 −3 Original line number Diff line number Diff line Loading @@ -96,9 +96,7 @@ public class ConnectedDeviceDashboardFragment extends DashboardFragment { keys.add(NfcPreferenceController.KEY_TOGGLE_NFC); keys.add(NfcPreferenceController.KEY_ANDROID_BEAM_SETTINGS); } if (!pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) { keys.add(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH); } return keys; } }; Loading
src/com/android/settings/datausage/DataUsageSummary.java +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs private static final String KEY_LIMIT_SUMMARY = "limit_summary"; private static final String KEY_RESTRICT_BACKGROUND = "restrict_background"; private static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions"; private static final String KEY_WIFI_USAGE_TITLE = "wifi_category"; private DataUsageController mDataUsageController; private DataUsageInfoController mDataInfoController; Loading Loading @@ -491,6 +492,7 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs if (hasMobileData) { keys.add(KEY_RESTRICT_BACKGROUND); } keys.add(KEY_WIFI_USAGE_TITLE); return keys; } Loading
src/com/android/settings/network/NetworkDashboardFragment.java +8 −0 Original line number Diff line number Diff line Loading @@ -142,5 +142,13 @@ public class NetworkDashboardFragment extends DashboardFragment implements sir.xmlResId = R.xml.network_and_internet; return Arrays.asList(sir); } @Override public List<String> getNonIndexableKeys(Context context) { List<String> keys = new ArrayList<>(); // Remove master switch as a result keys.add(WifiMasterSwitchPreferenceController.KEY_TOGGLE_WIFI); return keys; } }; }
src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class WifiMasterSwitchPreferenceController extends PreferenceController implements SummaryUpdater.OnSummaryChangeListener, LifecycleObserver, OnResume, OnPause, OnStart, OnStop { private static final String KEY_TOGGLE_WIFI = "toggle_wifi"; public static final String KEY_TOGGLE_WIFI = "toggle_wifi"; private MasterSwitchPreference mWifiPreference; private WifiEnabler mWifiEnabler; Loading
tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceDashboardFragmentTest.java +10 −15 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.settings.bluetooth.BluetoothMasterSwitchPreferenceController; import com.android.settings.nfc.NfcPreferenceController; import com.android.settings.SettingsRobolectricTestRunner; import com.android.settings.TestConfig; import com.android.settings.testutils.XmlTestUtils; import com.android.settingslib.drawer.CategoryKey; import org.junit.Before; Loading @@ -30,13 +31,12 @@ 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 java.util.List; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @RunWith(SettingsRobolectricTestRunner.class) Loading Loading @@ -92,20 +92,15 @@ public class ConnectedDeviceDashboardFragmentTest { } @Test public void testSearchIndexProvider_NoBluetooth_KeyAdded() { when(mManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(false); final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext); assertThat(keys).isNotNull(); assertThat(keys).contains(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH); } public void testNonIndexableKeys_existInXmlLayout() { final Context context = RuntimeEnvironment.application; when(mManager.hasSystemFeature(PackageManager.FEATURE_NFC)).thenReturn(false); final List<String> niks = ConnectedDeviceDashboardFragment.SEARCH_INDEX_DATA_PROVIDER .getNonIndexableKeys(context); final int xmlId = (new ConnectedDeviceDashboardFragment()).getPreferenceScreenResId(); @Test public void testSearchIndexProvider_Bluetooth_KeyNotAdded() { when(mManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)).thenReturn(true); final List<String> keys = mFragment.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(mContext); final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId); assertThat(keys).isNotNull(); assertThat(keys).doesNotContain(BluetoothMasterSwitchPreferenceController.KEY_TOGGLE_BLUETOOTH); assertThat(keys).containsAllIn(niks); } }