summaryrefslogtreecommitdiffstats
path: root/wifi/java
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2013-11-15 18:43:52 +0900
committerLorenzo Colitti <lorenzo@google.com>2013-12-06 13:54:35 +0900
commit64483947fdb03bf838e317ac0a4af5e0f53a5bbf (patch)
tree856dbc2a83c5b1586b1127e0b3c14f6f335a30fc /wifi/java
parent6e2d0c1d91f644ab50e0c0b7cae4306262a4ca41 (diff)
downloadframeworks_base-64483947fdb03bf838e317ac0a4af5e0f53a5bbf.zip
frameworks_base-64483947fdb03bf838e317ac0a4af5e0f53a5bbf.tar.gz
frameworks_base-64483947fdb03bf838e317ac0a4af5e0f53a5bbf.tar.bz2
Add address flags and scope to LinkAddress.
This is necessary so that the framework can know whether an IPv6 address is likely to be usable (i.e., if it's global scope and preferred). Also, it will simplify the address notification methods in INetworkManagementEventObserver, which currently take the address, the flags, and the scope as separate arguments. 1. Add flags and scope to the class and update the unit test. Use the IFA_F_* and RT_SCOPE_* constants defined by libcore. Since most callers don't know about flags and scope, provide constructors that default the flags to zero and determine the scope from the address. Addresses notified by the kernel will have these properly set. Make multicast addresses invalid. Update the class documentation. 2. Provide an isSameAddressAs() method that compares only the address and prefix information between two LinkAddress objects. This is necessary because an interface can't have two addresses with the same address/prefix but different flags. 3. Update LinkProperties's addLinkAddress and removeLinkAddress to identify existing addresses to add/remove using isSameAddressAs instead of implicit equals(). Specifically: - If addLinkAddress is called with an address that is already present, the existing address's flags and scope are updated. This allows, for example, an address on an interface to go from preferred to deprecated when it expires, without it having to be removed and re-added. - If removeLinkAddress is called with an address that is present but with different flags, it deletes that address instead of failing to find a match. 4. Update the INetworkManagementEventObserver address notification methods to take just a LinkAddress instead of LinkAddress, flags, and scope. While I'm at it, change the order of the arguments for consistency with the other functions in the interface. Change-Id: Id8fe0f09a7e8f6bee1ea3b52102178b689a9336e
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java21
1 files changed, 11 insertions, 10 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index 60c7f03..c0bfa5f 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -239,24 +239,25 @@ public class WifiStateMachine extends StateMachine {
mWifiStateMachine = wifiStateMachine;
}
+ private void maybeLog(String operation, String iface, LinkAddress address) {
+ if (DBG) {
+ log(operation + ": " + address + " on " + iface +
+ " flags " + address.getFlags() + " scope " + address.getScope());
+ }
+ }
+
@Override
- public void addressUpdated(LinkAddress address, String iface, int flags, int scope) {
+ public void addressUpdated(String iface, LinkAddress address) {
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
- if (DBG) {
- log("addressUpdated: " + address + " on " + iface +
- " flags " + flags + " scope " + scope);
- }
+ maybeLog("addressUpdated", iface, address);
mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_UPDATED, address);
}
}
@Override
- public void addressRemoved(LinkAddress address, String iface, int flags, int scope) {
+ public void addressRemoved(String iface, LinkAddress address) {
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
- if (DBG) {
- log("addressRemoved: " + address + " on " + iface +
- " flags " + flags + " scope " + scope);
- }
+ maybeLog("addressRemoved", iface, address);
mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_REMOVED, address);
}
}