Search in sources :

Example 6 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiDialogActivity method onSubmit.

@Override
public void onSubmit(WifiDialog2 dialog) {
    final WifiEntry wifiEntry = dialog.getController().getWifiEntry();
    final WifiConfiguration config = dialog.getController().getConfig();
    if (getIntent().getBooleanExtra(KEY_CONNECT_FOR_CALLER, true)) {
        if (config == null && wifiEntry != null && wifiEntry.canConnect()) {
            wifiEntry.connect(null);
        } else {
            getSystemService(WifiManager.class).connect(config, null);
        }
    }
    final Intent resultData = new Intent();
    if (config != null) {
        resultData.putExtra(KEY_WIFI_CONFIGURATION, config);
    }
    setResult(RESULT_CONNECTED, resultData);
    finish();
}
Also used : WifiManager(android.net.wifi.WifiManager) WifiConfiguration(android.net.wifi.WifiConfiguration) WifiEntry(com.android.wifitrackerlib.WifiEntry) Intent(android.content.Intent)

Example 7 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiDialogActivity method onForget.

@Override
public void onForget(WifiDialog2 dialog) {
    final WifiEntry wifiEntry = dialog.getController().getWifiEntry();
    if (wifiEntry != null && wifiEntry.canForget()) {
        wifiEntry.forget(null);
    }
    setResult(RESULT_FORGET);
    finish();
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry)

Example 8 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class WifiConnectionPreferenceController method update.

private void update() {
    final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry();
    if (connectedWifiEntry == null) {
        updatePreference(null);
    } else {
        if (mPreference == null || !mPreference.getWifiEntry().equals(connectedWifiEntry)) {
            updatePreference(connectedWifiEntry);
        } else if (mPreference != null) {
            mPreference.refresh();
        }
    }
    mUpdateListener.onChildrenUpdated();
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry)

Example 9 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderWorkerTest method getWifiEntry_connectedWifiKey_shouldGetConnectedWifi.

@Test
@UiThreadTest
public void getWifiEntry_connectedWifiKey_shouldGetConnectedWifi() {
    final String key = "key";
    final WifiEntry connectedWifiEntry = mock(WifiEntry.class);
    when(connectedWifiEntry.getKey()).thenReturn(key);
    when(mMockWifiPickerTracker.getConnectedWifiEntry()).thenReturn(connectedWifiEntry);
    assertThat(mMockNetworkProviderWorker.getWifiEntry(key)).isEqualTo(connectedWifiEntry);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 10 with WifiEntry

use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.

the class NetworkProviderWorkerTest method getWifiEntry_reachableWifiKey_shouldGetReachableWifi.

@Test
@UiThreadTest
public void getWifiEntry_reachableWifiKey_shouldGetReachableWifi() {
    final String key = "key";
    final WifiEntry reachableWifiEntry = mock(WifiEntry.class);
    when(reachableWifiEntry.getKey()).thenReturn(key);
    when(mMockWifiPickerTracker.getWifiEntries()).thenReturn(Arrays.asList(reachableWifiEntry));
    assertThat(mMockNetworkProviderWorker.getWifiEntry(key)).isEqualTo(reachableWifiEntry);
}
Also used : WifiEntry(com.android.wifitrackerlib.WifiEntry) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest) UiThreadTest(androidx.test.annotation.UiThreadTest)

Aggregations

WifiEntry (com.android.wifitrackerlib.WifiEntry)54 Test (org.junit.Test)28 WifiConfiguration (android.net.wifi.WifiConfiguration)10 WifiEntryPreference (com.android.settingslib.wifi.WifiEntryPreference)10 LongPressWifiEntryPreference (com.android.settingslib.wifi.LongPressWifiEntryPreference)8 Intent (android.content.Intent)7 Preference (androidx.preference.Preference)5 Context (android.content.Context)4 Bundle (android.os.Bundle)4 DataUsagePreference (com.android.settings.datausage.DataUsagePreference)4 WifiManager (android.net.wifi.WifiManager)3 Handler (android.os.Handler)3 View (android.view.View)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)3 AddWifiNetworkPreference (com.android.settings.wifi.AddWifiNetworkPreference)3 ConnectedWifiEntryPreference (com.android.settings.wifi.ConnectedWifiEntryPreference)3 FooterPreference (com.android.settingslib.widget.FooterPreference)3 LayoutPreference (com.android.settingslib.widget.LayoutPreference)3 ArrayList (java.util.ArrayList)3