use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiDppQrCodeScannerFragment method isReachableWifiNetwork.
private boolean isReachableWifiNetwork(WifiConfiguration wifiConfiguration) {
final List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries();
final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry();
if (connectedWifiEntry != null) {
// Add connected WifiEntry to prevent fail toast to users when it's connected.
wifiEntries.add(connectedWifiEntry);
}
for (WifiEntry wifiEntry : wifiEntries) {
if (!TextUtils.equals(wifiEntry.getSsid(), sanitizeSsid(wifiConfiguration.SSID))) {
continue;
}
final int security = WifiDppUtils.getSecurityTypeFromWifiConfiguration(wifiConfiguration);
if (security == wifiEntry.getSecurity()) {
return true;
}
// there is no way to know if a WifiEntry is of transition mode. Give it a chance.
if (security == WifiEntry.SECURITY_SAE && wifiEntry.getSecurity() == WifiEntry.SECURITY_PSK) {
return true;
}
}
return false;
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class NetworkRequestDialogFragment method onClick.
@Override
public void onClick(DialogInterface dialog, int which) {
if (mFilteredWifiEntries.size() == 0 || which >= mFilteredWifiEntries.size()) {
// Invalid values.
return;
}
if (mUserSelectionCallback == null) {
// Callback is missing or not ready.
return;
}
final WifiEntry wifiEntry = mFilteredWifiEntries.get(which);
WifiConfiguration config = wifiEntry.getWifiConfiguration();
if (config == null) {
config = WifiUtils.getWifiConfig(wifiEntry, null);
}
mUserSelectionCallback.select(config);
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class SavedAccessPointsPreferenceController2 method updatePreference.
/**
* mPreferenceGroup is not in a RecyclerView. To keep TalkBack focus, this method should not
* mPreferenceGroup.removeAll() then mPreferenceGroup.addPreference for mWifiEntries.
*/
private void updatePreference() {
// Remove the Preference of removed WifiEntry.
final List<String> removedPreferenceKeys = new ArrayList<>();
final int preferenceCount = mPreferenceGroup.getPreferenceCount();
for (int i = 0; i < preferenceCount; i++) {
final String key = mPreferenceGroup.getPreference(i).getKey();
if (mWifiEntries.stream().filter(wifiEntry -> TextUtils.equals(key, wifiEntry.getKey())).count() == 0) {
removedPreferenceKeys.add(key);
}
}
for (String removedPreferenceKey : removedPreferenceKeys) {
mPreferenceGroup.removePreference(mPreferenceGroup.findPreference(removedPreferenceKey));
}
// Add the Preference of new added WifiEntry.
for (WifiEntry wifiEntry : mWifiEntries) {
if (mPreferenceGroup.findPreference(wifiEntry.getKey()) == null) {
final WifiEntryPreference preference = new WifiEntryPreference(mContext, wifiEntry);
preference.setKey(wifiEntry.getKey());
preference.setOnPreferenceClickListener(this);
mPreferenceGroup.addPreference(preference);
}
}
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class WifiScanWorker method getWifiEntry.
/**
* To get the WifiEntry of key.
*/
public WifiEntry getWifiEntry(String key) {
// Get specified WifiEntry.
WifiEntry keyWifiEntry = null;
final WifiEntry connectedWifiEntry = mWifiPickerTracker.getConnectedWifiEntry();
if (connectedWifiEntry != null && TextUtils.equals(key, connectedWifiEntry.getKey())) {
keyWifiEntry = connectedWifiEntry;
} else {
for (WifiEntry wifiEntry : mWifiPickerTracker.getWifiEntries()) {
if (TextUtils.equals(key, wifiEntry.getKey())) {
keyWifiEntry = wifiEntry;
break;
}
}
}
return keyWifiEntry;
}
use of com.android.wifitrackerlib.WifiEntry in project android_packages_apps_Settings by omnirom.
the class ConnectToWifiHandler method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (context == null || intent == null) {
return;
}
final String key = intent.getStringExtra(KEY_CHOSEN_WIFIENTRY_KEY);
if (TextUtils.isEmpty(key)) {
return;
}
if (intent.getParcelableExtra(KEY_WIFI_SLICE_URI) == null) {
return;
}
final WifiScanWorker worker = getWifiScanWorker(intent);
if (worker == null) {
return;
}
final WifiEntry wifiEntry = worker.getWifiEntry(key);
if (wifiEntry == null) {
return;
}
wifiEntry.connect(new WifiEntryConnectCallback(context, wifiEntry));
}
Aggregations