Network data activity change intent for network interfaces.

The activity notification is received from netd, an intent
DATA_ACTIVITY_CHANGE is then raised for other part of the system to
consume.

Change-Id: Idfcc4763c51c5b314c57f546c12557082f06bebf
This commit is contained in:
Haoyu Bai
2012-06-20 14:29:57 -07:00
parent 6b7358d951
commit db3c8678e5
11 changed files with 106 additions and 0 deletions

View File

@@ -279,6 +279,20 @@ public class NetworkManagementService extends INetworkManagementService.Stub
mObservers.finishBroadcast();
}
/**
* Notify our observers of a change in the data activity state of the interface
*/
private void notifyInterfaceClassActivity(String label, boolean active) {
final int length = mObservers.beginBroadcast();
for (int i = 0; i < length; i++) {
try {
mObservers.getBroadcastItem(i).interfaceClassDataActivityChanged(label, active);
} catch (RemoteException e) {
}
}
mObservers.finishBroadcast();
}
/**
* Prepare native daemon once connected, enabling modules and pushing any
* existing in-memory rules.
@@ -405,6 +419,19 @@ public class NetworkManagementService extends INetworkManagementService.Stub
throw new IllegalStateException(
String.format("Invalid event from daemon (%s)", raw));
// break;
case NetdResponseCode.InterfaceClassActivity:
/*
* An network interface class state changed (active/idle)
* Format: "NNN IfaceClass <active/idle> <label>"
*/
if (cooked.length < 4 || !cooked[1].equals("IfaceClass")) {
throw new IllegalStateException(
String.format("Invalid event from daemon (%s)", raw));
}
boolean isActive = cooked[2].equals("active");
notifyInterfaceClassActivity(cooked[3], isActive);
return true;
// break;
default: break;
}
return false;