Modify LinkProperties address update methods.

1. Make addLinkAddress a no-op if the address already exists.
2. Make addLinkAddress, addStackedLink and removeStackedLink
   return a boolean indicating whether something changed.
3. Add a removeLinkAddress method (currently there is no way of
   removing an address).
3. Move hasIPv6Address from ConnectivityService to
   LinkProperties, where it belongs.

Bug: 9625448
Bug: 10232006
Change-Id: If641d0198432a7a505e358c059171f25bc9f13d5
This commit is contained in:
Lorenzo Colitti
2013-08-08 11:00:12 +09:00
parent b48bb0801a
commit 09de418b17
3 changed files with 105 additions and 22 deletions

View File

@@ -3982,8 +3982,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// Get the type of addresses supported by this link
LinkProperties lp = mCs.getLinkProperties(
ConnectivityManager.TYPE_MOBILE_HIPRI);
boolean linkHasIpv4 = hasIPv4Address(lp);
boolean linkHasIpv6 = hasIPv6Address(lp);
boolean linkHasIpv4 = lp.hasIPv4Address();
boolean linkHasIpv6 = lp.hasIPv6Address();
log("isMobileOk: linkHasIpv4=" + linkHasIpv4
+ " linkHasIpv6=" + linkHasIpv6);
@@ -4129,20 +4129,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
public boolean hasIPv4Address(LinkProperties lp) {
return lp.hasIPv4Address();
}
// Not implemented in LinkProperties, do it here.
public boolean hasIPv6Address(LinkProperties lp) {
for (LinkAddress address : lp.getLinkAddresses()) {
if (address.getAddress() instanceof Inet6Address) {
return true;
}
}
return false;
}
private void log(String s) {
Slog.d(ConnectivityService.TAG, "[" + CHECKMP_TAG + "] " + s);
}