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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user