Merge changes from topic "api-review-removedoublequotes"

* changes:
  SettingsLib: Rename removeDoubleQuotes to sanitizeSsid
  Networking: Rename removeDoubleQuotes to sanitizeSsid
  Wifi: Rename removeDoubleQuotes to sanitizeSsid
This commit is contained in:
David Su
2020-01-30 18:16:53 +00:00
committed by Android (Google) Code Review
6 changed files with 19 additions and 12 deletions

View File

@@ -7580,7 +7580,7 @@ package android.net.wifi {
method public boolean isEphemeral();
method public boolean isOsuAp();
method public boolean isPasspointAp();
method @Nullable public static String removeDoubleQuotes(@Nullable String);
method @Nullable public static String sanitizeSsid(@Nullable String);
field public static final String DEFAULT_MAC_ADDRESS = "02:00:00:00:00:00";
field public static final int INVALID_RSSI = -127; // 0xffffff81
}

View File

@@ -539,13 +539,13 @@ public class NetworkPolicyManager {
/** @hide */
public static String resolveNetworkId(WifiConfiguration config) {
return WifiInfo.removeDoubleQuotes(config.isPasspoint()
return WifiInfo.sanitizeSsid(config.isPasspoint()
? config.providerFriendlyName : config.SSID);
}
/** @hide */
public static String resolveNetworkId(String ssid) {
return WifiInfo.removeDoubleQuotes(ssid);
return WifiInfo.sanitizeSsid(ssid);
}
/** @hide */

View File

@@ -32,7 +32,7 @@ import static android.net.NetworkStats.METERED_YES;
import static android.net.NetworkStats.ROAMING_ALL;
import static android.net.NetworkStats.ROAMING_NO;
import static android.net.NetworkStats.ROAMING_YES;
import static android.net.wifi.WifiInfo.removeDoubleQuotes;
import static android.net.wifi.WifiInfo.sanitizeSsid;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.Parcel;
@@ -401,7 +401,7 @@ public class NetworkTemplate implements Parcelable {
switch (ident.mType) {
case TYPE_WIFI:
return Objects.equals(
removeDoubleQuotes(mNetworkId), removeDoubleQuotes(ident.mNetworkId));
sanitizeSsid(mNetworkId), sanitizeSsid(ident.mNetworkId));
default:
return false;
}

View File

@@ -216,7 +216,7 @@ public class NetworkPolicyEditor {
private static NetworkTemplate buildUnquotedNetworkTemplate(NetworkTemplate template) {
if (template == null) return null;
final String networkId = template.getNetworkId();
final String strippedNetworkId = WifiInfo.removeDoubleQuotes(networkId);
final String strippedNetworkId = WifiInfo.sanitizeSsid(networkId);
if (!TextUtils.equals(strippedNetworkId, networkId)) {
return new NetworkTemplate(
template.getMatchRule(), template.getSubscriberId(), strippedNetworkId);

View File

@@ -188,14 +188,14 @@ public class NetworkNotificationManager {
int icon = getIcon(transportType, notifyType);
if (notifyType == NotificationType.NO_INTERNET && transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.wifi_no_internet,
WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID()));
WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
details = r.getString(R.string.wifi_no_internet_detailed);
} else if (notifyType == NotificationType.PRIVATE_DNS_BROKEN) {
if (transportType == TRANSPORT_CELLULAR) {
title = r.getString(R.string.mobile_no_internet);
} else if (transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.wifi_no_internet,
WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID()));
WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
} else {
title = r.getString(R.string.other_networks_no_internet);
}
@@ -203,19 +203,19 @@ public class NetworkNotificationManager {
} else if (notifyType == NotificationType.PARTIAL_CONNECTIVITY
&& transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.network_partial_connectivity,
WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID()));
WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
details = r.getString(R.string.network_partial_connectivity_detailed);
} else if (notifyType == NotificationType.LOST_INTERNET &&
transportType == TRANSPORT_WIFI) {
title = r.getString(R.string.wifi_no_internet,
WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID()));
WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
details = r.getString(R.string.wifi_no_internet_detailed);
} else if (notifyType == NotificationType.SIGN_IN) {
switch (transportType) {
case TRANSPORT_WIFI:
title = r.getString(R.string.wifi_available_sign_in, 0);
details = r.getString(R.string.network_available_sign_in_detailed,
WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID()));
WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
break;
case TRANSPORT_CELLULAR:
title = r.getString(R.string.network_available_sign_in, 0);
@@ -236,7 +236,7 @@ public class NetworkNotificationManager {
break;
}
} else if (notifyType == NotificationType.LOGGED_IN) {
title = WifiInfo.removeDoubleQuotes(nai.networkCapabilities.getSSID());
title = WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID());
details = r.getString(R.string.captive_portal_logged_in_detailed);
} else if (notifyType == NotificationType.NETWORK_SWITCH) {
String fromTransport = getTransportName(transportType);

View File

@@ -889,6 +889,13 @@ public class WifiInfo implements Parcelable {
*/
@Nullable
@SystemApi
public static String sanitizeSsid(@Nullable String string) {
return removeDoubleQuotes(string);
}
/** @hide */
@UnsupportedAppUsage
@Nullable
public static String removeDoubleQuotes(@Nullable String string) {
if (string == null) return null;
final int length = string.length();