use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiNetworkListFragment method onSavedWifiEntriesChanged.
/**
* Called when the state of Wifi has changed.
*/
@Override
public void onSavedWifiEntriesChanged() {
final List<WifiEntry> savedWifiEntries = mSavedNetworkTracker.getSavedWifiEntries().stream().filter(entry -> isValidForDppConfiguration(entry)).collect(Collectors.toList());
int index = 0;
mPreferenceGroup.removeAll();
for (WifiEntry savedEntry : savedWifiEntries) {
final DisableUnreachableWifiEntryPreference preference = new DisableUnreachableWifiEntryPreference(getContext(), savedEntry);
preference.setOnPreferenceClickListener(this);
preference.setEnabled(savedEntry.getLevel() != WifiEntry.WIFI_LEVEL_UNREACHABLE);
preference.setOrder(index++);
mPreferenceGroup.addPreference(preference);
}
mAddPreference.setOrder(index);
mPreferenceGroup.addPreference(mAddPreference);
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiNetworkListFragment method onPreferenceClick.
@Override
public boolean onPreferenceClick(Preference preference) {
if (preference instanceof WifiEntryPreference) {
final WifiEntry selectedWifiEntry = ((WifiEntryPreference) preference).getWifiEntry();
// Launch WifiDppAddDeviceFragment to start DPP in Configurator-Initiator role.
final WifiConfiguration wifiConfig = selectedWifiEntry.getWifiConfiguration();
if (wifiConfig == null) {
throw new IllegalArgumentException("Invalid access point");
}
final WifiNetworkConfig networkConfig = WifiNetworkConfig.getValidConfigOrNull(WifiDppUtils.getSecurityString(selectedWifiEntry), wifiConfig.getPrintableSsid(), wifiConfig.preSharedKey, wifiConfig.hiddenSSID, wifiConfig.networkId, /* isHotspot */
false);
if (mOnChooseNetworkListener != null) {
mOnChooseNetworkListener.onChooseNetwork(networkConfig);
}
} else if (preference == mAddPreference) {
new SubSettingLauncher(getContext()).setTitleRes(R.string.wifi_add_network).setDestination(AddNetworkFragment.class.getName()).setSourceMetricsCategory(getMetricsCategory()).setResultListener(this, ADD_NETWORK_REQUEST).launch();
} else {
return super.onPreferenceTreeClick(preference);
}
return true;
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiNetworkDetailsFragment method clearWifiEntryCallback.
private void clearWifiEntryCallback() {
if (mNetworkDetailsTracker == null) {
return;
}
final WifiEntry wifiEntry = mNetworkDetailsTracker.getWifiEntry();
if (wifiEntry == null) {
return;
}
wifiEntry.setListener(null);
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiSettings method onPreferenceTreeClick.
@Override
public boolean onPreferenceTreeClick(Preference preference) {
// If the preference has a fragment set, open that
if (preference.getFragment() != null) {
preference.setOnPreferenceClickListener(null);
return super.onPreferenceTreeClick(preference);
}
if (preference instanceof LongPressWifiEntryPreference) {
final WifiEntry selectedEntry = ((LongPressWifiEntryPreference) preference).getWifiEntry();
if (selectedEntry.shouldEditBeforeConnect()) {
launchConfigNewNetworkFragment(selectedEntry);
return true;
}
connect(selectedEntry, true, /* editIfNoConfig */
true);
} else if (preference == mAddWifiNetworkPreference) {
onAddNetworkPressed();
} else {
return super.onPreferenceTreeClick(preference);
}
return true;
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiSettings method onSubmit.
@Override
public void onSubmit(WifiDialog2 dialog) {
final int dialogMode = dialog.getMode();
final WifiConfiguration config = dialog.getController().getConfig();
final WifiEntry wifiEntry = dialog.getWifiEntry();
if (dialogMode == WifiConfigUiBase2.MODE_MODIFY) {
if (config == null) {
Toast.makeText(getContext(), R.string.wifi_failed_save_message, Toast.LENGTH_SHORT).show();
} else {
mWifiManager.save(config, mSaveListener);
}
} else if (dialogMode == WifiConfigUiBase2.MODE_CONNECT || (dialogMode == WifiConfigUiBase2.MODE_VIEW && wifiEntry.canConnect())) {
if (config == null) {
connect(wifiEntry, false, /* editIfNoConfig */
false);
} else {
mWifiManager.connect(config, new WifiConnectActionListener());
}
}
}
Aggregations