Merge "[Wi-Fi] Replace some WifiEntryShell methods with WifiEntry version"
This commit is contained in:
@@ -341,7 +341,7 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
|
|
||||||
if ((!mWifiEntry.isSaved()
|
if ((!mWifiEntry.isSaved()
|
||||||
&& mWifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED
|
&& mWifiEntry.getConnectedState() != WifiEntry.CONNECTED_STATE_CONNECTED
|
||||||
&& !WifiEntryShell.isPasspoint(mWifiEntry))
|
&& !mWifiEntry.isSubscription())
|
||||||
|| mMode != WifiConfigUiBase2.MODE_VIEW) {
|
|| mMode != WifiConfigUiBase2.MODE_VIEW) {
|
||||||
showSecurityFields(/* refreshEapMethods */ true, /* refreshCertificates */ true);
|
showSecurityFields(/* refreshEapMethods */ true, /* refreshCertificates */ true);
|
||||||
showIpConfigFields();
|
showIpConfigFields();
|
||||||
@@ -417,7 +417,7 @@ public class WifiConfigController2 implements TextWatcher,
|
|||||||
}
|
}
|
||||||
if (mWifiEntry.isSaved()
|
if (mWifiEntry.isSaved()
|
||||||
|| mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
|
|| mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED
|
||||||
|| WifiEntryShell.isPasspoint(mWifiEntry)) {
|
|| mWifiEntry.isSubscription()) {
|
||||||
mConfigUi.setForgetButton(res.getString(R.string.wifi_forget));
|
mConfigUi.setForgetButton(res.getString(R.string.wifi_forget));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
import android.net.wifi.WifiConfiguration;
|
|
||||||
|
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,20 +48,6 @@ public class WifiEntryShell {
|
|||||||
*/
|
*/
|
||||||
public static final int HIGHER_FREQ_5GHZ = 5900;
|
public static final int HIGHER_FREQ_5GHZ = 5900;
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping of the corresponding {@link WifiConfiguration} field
|
|
||||||
*/
|
|
||||||
public static int getNetworkId(WifiEntry wifiEntry) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping of the corresponding {@link WifiConfiguration} field
|
|
||||||
*/
|
|
||||||
public static boolean hiddenSSID(WifiEntry wifiEntry) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping of the corresponding {@link AccessPoint} method
|
* Mapping of the corresponding {@link AccessPoint} method
|
||||||
*/
|
*/
|
||||||
@@ -73,13 +57,6 @@ public class WifiEntryShell {
|
|||||||
|
|
||||||
// Passpoint methods
|
// Passpoint methods
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping of the corresponding {@link AccessPoint} method
|
|
||||||
*/
|
|
||||||
public static boolean isPasspoint(WifiEntry wifiEntry) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping of the corresponding {@link AccessPoint} method
|
* Mapping of the corresponding {@link AccessPoint} method
|
||||||
*/
|
*/
|
||||||
|
@@ -537,7 +537,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refreshSsid() {
|
private void refreshSsid() {
|
||||||
if (WifiEntryShell.isPasspoint(mWifiEntry) || WifiEntryShell.isOsuProvider(mWifiEntry)) {
|
if (mWifiEntry.isSubscription() || WifiEntryShell.isOsuProvider(mWifiEntry)) {
|
||||||
mSsidPref.setVisible(true);
|
mSsidPref.setVisible(true);
|
||||||
mSsidPref.setSummary(mWifiEntry.getTitle());
|
mSsidPref.setSummary(mWifiEntry.getTitle());
|
||||||
} else {
|
} else {
|
||||||
@@ -723,7 +723,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
* Forgets the wifi network associated with this preference.
|
* Forgets the wifi network associated with this preference.
|
||||||
*/
|
*/
|
||||||
private void forgetNetwork() {
|
private void forgetNetwork() {
|
||||||
if (WifiEntryShell.isPasspoint(mWifiEntry)) {
|
if (mWifiEntry.isSubscription()) {
|
||||||
// Post a dialog to confirm if user really want to forget the passpoint network.
|
// Post a dialog to confirm if user really want to forget the passpoint network.
|
||||||
showConfirmForgetDialog();
|
showConfirmForgetDialog();
|
||||||
return;
|
return;
|
||||||
@@ -851,7 +851,7 @@ public class WifiDetailPreferenceController2 extends AbstractPreferenceControlle
|
|||||||
// For saved Passpoint network, framework doesn't have the field to keep the MAC choice
|
// For saved Passpoint network, framework doesn't have the field to keep the MAC choice
|
||||||
// persistently, so Passpoint network will always use the default value so far, which is
|
// persistently, so Passpoint network will always use the default value so far, which is
|
||||||
// randomized MAC address, so don't need to modify title.
|
// randomized MAC address, so don't need to modify title.
|
||||||
if (WifiEntryShell.isPasspoint(mWifiEntry)) {
|
if (mWifiEntry.isSubscription()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,7 +32,6 @@ import android.os.Vibrator;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.wifi.WifiEntryShell;
|
|
||||||
import com.android.settingslib.wifi.AccessPoint;
|
import com.android.settingslib.wifi.AccessPoint;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
@@ -150,24 +149,6 @@ public class WifiDppUtils {
|
|||||||
return wifiConfiguration.preSharedKey;
|
return wifiConfiguration.preSharedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPresharedKey(WifiManager wifiManager, WifiEntry wifiEntry) {
|
|
||||||
final List<WifiConfiguration> privilegedWifiConfigurations =
|
|
||||||
wifiManager.getPrivilegedConfiguredNetworks();
|
|
||||||
|
|
||||||
for (WifiConfiguration privilegedWifiConfiguration : privilegedWifiConfigurations) {
|
|
||||||
if (privilegedWifiConfiguration.networkId == WifiEntryShell.getNetworkId(wifiEntry)) {
|
|
||||||
// WEP uses a shared key hence the AuthAlgorithm.SHARED is used to identify it.
|
|
||||||
if (wifiEntry.getSecurity() == WifiEntry.SECURITY_WEP) {
|
|
||||||
return privilegedWifiConfiguration
|
|
||||||
.wepKeys[privilegedWifiConfiguration.wepTxKeyIndex];
|
|
||||||
} else {
|
|
||||||
return privilegedWifiConfiguration.preSharedKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String removeFirstAndLastDoubleQuotes(String str) {
|
private static String removeFirstAndLastDoubleQuotes(String str) {
|
||||||
if (TextUtils.isEmpty(str)) {
|
if (TextUtils.isEmpty(str)) {
|
||||||
return str;
|
return str;
|
||||||
@@ -268,7 +249,8 @@ public class WifiDppUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setConfiguratorIntentExtra(intent, wifiManager, wifiEntry);
|
final WifiConfiguration wifiConfiguration = wifiEntry.getWifiConfiguration();
|
||||||
|
setConfiguratorIntentExtra(intent, wifiManager, wifiConfiguration);
|
||||||
|
|
||||||
// For a transition mode Wi-Fi AP, creates a QR code that's compatible with more devices
|
// For a transition mode Wi-Fi AP, creates a QR code that's compatible with more devices
|
||||||
if (wifiEntry.getSecurity() == WifiEntry.SECURITY_PSK_SAE_TRANSITION) {
|
if (wifiEntry.getSecurity() == WifiEntry.SECURITY_PSK_SAE_TRANSITION) {
|
||||||
@@ -326,13 +308,13 @@ public class WifiDppUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setConfiguratorIntentExtra(intent, wifiManager, wifiEntry);
|
final WifiConfiguration wifiConfiguration = wifiEntry.getWifiConfiguration();
|
||||||
|
setConfiguratorIntentExtra(intent, wifiManager, wifiConfiguration);
|
||||||
|
|
||||||
final int networkId = WifiEntryShell.getNetworkId(wifiEntry);
|
if (wifiConfiguration.networkId == WifiConfiguration.INVALID_NETWORK_ID) {
|
||||||
if (networkId == WifiConfiguration.INVALID_NETWORK_ID) {
|
|
||||||
throw new IllegalArgumentException("Invalid network ID");
|
throw new IllegalArgumentException("Invalid network ID");
|
||||||
} else {
|
} else {
|
||||||
intent.putExtra(EXTRA_WIFI_NETWORK_ID, networkId);
|
intent.putExtra(EXTRA_WIFI_NETWORK_ID, wifiConfiguration.networkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return intent;
|
return intent;
|
||||||
@@ -417,28 +399,6 @@ public class WifiDppUtils {
|
|||||||
intent.putExtra(EXTRA_WIFI_HIDDEN_SSID, wifiConfiguration.hiddenSSID);
|
intent.putExtra(EXTRA_WIFI_HIDDEN_SSID, wifiConfiguration.hiddenSSID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setConfiguratorIntentExtra(Intent intent, WifiManager wifiManager,
|
|
||||||
WifiEntry wifiEntry) {
|
|
||||||
final String ssid = removeFirstAndLastDoubleQuotes(wifiEntry.getTitle());
|
|
||||||
final String security = getSecurityString(wifiEntry);
|
|
||||||
|
|
||||||
// When the value of this key is read, the actual key is not returned, just a "*".
|
|
||||||
// Call privileged system API to obtain actual key.
|
|
||||||
final String preSharedKey = removeFirstAndLastDoubleQuotes(getPresharedKey(wifiManager,
|
|
||||||
wifiEntry));
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(ssid)) {
|
|
||||||
intent.putExtra(EXTRA_WIFI_SSID, ssid);
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(security)) {
|
|
||||||
intent.putExtra(EXTRA_WIFI_SECURITY, security);
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(preSharedKey)) {
|
|
||||||
intent.putExtra(EXTRA_WIFI_PRE_SHARED_KEY, preSharedKey);
|
|
||||||
}
|
|
||||||
intent.putExtra(EXTRA_WIFI_HIDDEN_SSID, WifiEntryShell.hiddenSSID(wifiEntry));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows authentication screen to confirm credentials (pin, pattern or password) for the current
|
* Shows authentication screen to confirm credentials (pin, pattern or password) for the current
|
||||||
* user of the device.
|
* user of the device.
|
||||||
@@ -504,7 +464,7 @@ public class WifiDppUtils {
|
|||||||
* @param wifiEntry The {@link WifiEntry} of the Wi-Fi network
|
* @param wifiEntry The {@link WifiEntry} of the Wi-Fi network
|
||||||
*/
|
*/
|
||||||
public static boolean isSupportConfiguratorQrCodeScanner(Context context, WifiEntry wifiEntry) {
|
public static boolean isSupportConfiguratorQrCodeScanner(Context context, WifiEntry wifiEntry) {
|
||||||
if (WifiEntryShell.isPasspoint(wifiEntry)) {
|
if (wifiEntry.isSubscription()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isSupportWifiDpp(context, wifiEntry.getSecurity());
|
return isSupportWifiDpp(context, wifiEntry.getSecurity());
|
||||||
|
Reference in New Issue
Block a user