Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 979aa9e1 authored by Matthew Fritze's avatar Matthew Fritze Committed by android-build-merger
Browse files

Merge "Remove search duplicates for Wifi and Bluetooth" into oc-dev am: b48e6e46

am: 6e4d02fa

Change-Id: I2a35e242e6430fe7f68eb10d5a96177898d29933
parents ddbbe463 6e4d02fa
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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;
                }
            };
+2 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
            }
+8 −0
Original line number Diff line number Diff line
@@ -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;
                }
            };
}
+1 −1
Original line number Diff line number Diff line
@@ -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;
+10 −15
Original line number Diff line number Diff line
@@ -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;
@@ -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)
@@ -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