am f226bc60
: Merge "Use LinkAddress in address notifications."
* commit 'f226bc606af9ce5aceff6b05fc4b0200c94cb248': Use LinkAddress in address notifications.
This commit is contained in:
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
|
import android.net.LinkAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback class for receiving events from an INetworkManagementService
|
* Callback class for receiving events from an INetworkManagementService
|
||||||
*
|
*
|
||||||
@ -62,7 +64,7 @@ interface INetworkManagementEventObserver {
|
|||||||
* @param flags The address flags.
|
* @param flags The address flags.
|
||||||
* @param scope The address scope.
|
* @param scope The address scope.
|
||||||
*/
|
*/
|
||||||
void addressUpdated(String address, String iface, int flags, int scope);
|
void addressUpdated(in LinkAddress address, String iface, int flags, int scope);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface address has been removed
|
* An interface address has been removed
|
||||||
@ -72,7 +74,7 @@ interface INetworkManagementEventObserver {
|
|||||||
* @param flags The address flags.
|
* @param flags The address flags.
|
||||||
* @param scope The address scope.
|
* @param scope The address scope.
|
||||||
*/
|
*/
|
||||||
void addressRemoved(String address, String iface, int flags, int scope);
|
void addressRemoved(in LinkAddress address, String iface, int flags, int scope);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A networking quota limit has been reached. The quota might not
|
* A networking quota limit has been reached. The quota might not
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.android.server.net;
|
package com.android.server.net;
|
||||||
|
|
||||||
import android.net.INetworkManagementEventObserver;
|
import android.net.INetworkManagementEventObserver;
|
||||||
|
import android.net.LinkAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base {@link INetworkManagementEventObserver} that provides no-op
|
* Base {@link INetworkManagementEventObserver} that provides no-op
|
||||||
@ -36,12 +37,12 @@ public class BaseNetworkObserver extends INetworkManagementEventObserver.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addressUpdated(String address, String iface, int flags, int scope) {
|
public void addressUpdated(LinkAddress address, String iface, int flags, int scope) {
|
||||||
// default no-op
|
// default no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addressRemoved(String address, String iface, int flags, int scope) {
|
public void addressRemoved(LinkAddress address, String iface, int flags, int scope) {
|
||||||
// default no-op
|
// default no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,7 +405,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
/**
|
/**
|
||||||
* Notify our observers of a new or updated interface address.
|
* Notify our observers of a new or updated interface address.
|
||||||
*/
|
*/
|
||||||
private void notifyAddressUpdated(String address, String iface, int flags, int scope) {
|
private void notifyAddressUpdated(LinkAddress address, String iface, int flags, int scope) {
|
||||||
final int length = mObservers.beginBroadcast();
|
final int length = mObservers.beginBroadcast();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
try {
|
try {
|
||||||
@ -420,7 +420,7 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
/**
|
/**
|
||||||
* Notify our observers of a deleted interface address.
|
* Notify our observers of a deleted interface address.
|
||||||
*/
|
*/
|
||||||
private void notifyAddressRemoved(String address, String iface, int flags, int scope) {
|
private void notifyAddressRemoved(LinkAddress address, String iface, int flags, int scope) {
|
||||||
final int length = mObservers.beginBroadcast();
|
final int length = mObservers.beginBroadcast();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
try {
|
try {
|
||||||
@ -537,17 +537,21 @@ public class NetworkManagementService extends INetworkManagementService.Stub
|
|||||||
|
|
||||||
int flags;
|
int flags;
|
||||||
int scope;
|
int scope;
|
||||||
|
LinkAddress address;
|
||||||
try {
|
try {
|
||||||
flags = Integer.parseInt(cooked[5]);
|
flags = Integer.parseInt(cooked[5]);
|
||||||
scope = Integer.parseInt(cooked[6]);
|
scope = Integer.parseInt(cooked[6]);
|
||||||
} catch(NumberFormatException e) {
|
address = new LinkAddress(cooked[3]);
|
||||||
throw new IllegalStateException(errorMessage);
|
} catch(NumberFormatException e) { // Non-numeric lifetime or scope.
|
||||||
|
throw new IllegalStateException(errorMessage, e);
|
||||||
|
} catch(IllegalArgumentException e) { // Malformed IP address.
|
||||||
|
throw new IllegalStateException(errorMessage, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cooked[2].equals("updated")) {
|
if (cooked[2].equals("updated")) {
|
||||||
notifyAddressUpdated(cooked[3], cooked[4], flags, scope);
|
notifyAddressUpdated(address, cooked[4], flags, scope);
|
||||||
} else {
|
} else {
|
||||||
notifyAddressRemoved(cooked[3], cooked[4], flags, scope);
|
notifyAddressRemoved(address, cooked[4], flags, scope);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
// break;
|
// break;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.android.server;
|
package com.android.server;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.LinkAddress;
|
||||||
import android.net.LocalSocket;
|
import android.net.LocalSocket;
|
||||||
import android.net.LocalServerSocket;
|
import android.net.LocalServerSocket;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
@ -157,19 +158,22 @@ public class NetworkManagementServiceTest extends AndroidTestCase {
|
|||||||
* IP address changes.
|
* IP address changes.
|
||||||
*/
|
*/
|
||||||
sendMessage("614 Address updated fe80::1/64 wlan0 128 253");
|
sendMessage("614 Address updated fe80::1/64 wlan0 128 253");
|
||||||
expectSoon(observer).addressUpdated("fe80::1/64", "wlan0", 128, 253);
|
expectSoon(observer).addressUpdated(
|
||||||
|
new LinkAddress("fe80::1/64"), "wlan0", 128, 253);
|
||||||
|
|
||||||
// There is no "added".
|
// There is no "added", so we take this as "removed".
|
||||||
sendMessage("614 Address added fe80::1/64 wlan0 128 253");
|
sendMessage("614 Address added fe80::1/64 wlan0 128 253");
|
||||||
expectSoon(observer).addressRemoved("fe80::1/64", "wlan0", 128, 253);
|
expectSoon(observer).addressRemoved(
|
||||||
|
new LinkAddress("fe80::1/64"), "wlan0", 128, 253);
|
||||||
|
|
||||||
sendMessage("614 Address removed 2001:db8::1/64 wlan0 1 0");
|
sendMessage("614 Address removed 2001:db8::1/64 wlan0 1 0");
|
||||||
expectSoon(observer).addressRemoved("2001:db8::1/64", "wlan0", 1, 0);
|
expectSoon(observer).addressRemoved(
|
||||||
|
new LinkAddress("2001:db8::1/64"), "wlan0", 1, 0);
|
||||||
|
|
||||||
sendMessage("614 Address removed 2001:db8::1/64 wlan0 1");
|
sendMessage("614 Address removed 2001:db8::1/64 wlan0 1");
|
||||||
// Not enough arguments.
|
// Not enough arguments.
|
||||||
|
|
||||||
sendMessage("666 Address added 2001:db8::1/64 wlan0 1 0");
|
sendMessage("666 Address removed 2001:db8::1/64 wlan0 1 0");
|
||||||
// Invalid code.
|
// Invalid code.
|
||||||
|
|
||||||
|
|
||||||
|
@ -242,24 +242,24 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addressUpdated(String address, String iface, int flags, int scope) {
|
public void addressUpdated(LinkAddress address, String iface, int flags, int scope) {
|
||||||
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
|
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("addressUpdated: " + address + " on " + iface +
|
log("addressUpdated: " + address + " on " + iface +
|
||||||
" flags " + flags + " scope " + scope);
|
" flags " + flags + " scope " + scope);
|
||||||
}
|
}
|
||||||
mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_UPDATED, new LinkAddress(address));
|
mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_UPDATED, address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addressRemoved(String address, String iface, int flags, int scope) {
|
public void addressRemoved(LinkAddress address, String iface, int flags, int scope) {
|
||||||
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
|
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("addressRemoved: " + address + " on " + iface +
|
log("addressRemoved: " + address + " on " + iface +
|
||||||
" flags " + flags + " scope " + scope);
|
" flags " + flags + " scope " + scope);
|
||||||
}
|
}
|
||||||
mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_REMOVED, new LinkAddress(address));
|
mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_REMOVED, address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user