diff options
author | Haoyu Bai <bhy@google.com> | 2012-06-20 14:29:57 -0700 |
---|---|---|
committer | Haoyu Bai <bhy@google.com> | 2012-07-17 17:13:03 -0700 |
commit | db3c8678e5cbdfec011afaf25bde2091152c30ad (patch) | |
tree | e0f4b593cfba82bd5a35e921eebf351091d2e542 /services/java/com/android/server/NetworkManagementService.java | |
parent | 6b7358d9511df7e519bb417fbed6017c06a33d45 (diff) |
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
Diffstat (limited to 'services/java/com/android/server/NetworkManagementService.java')
-rw-r--r-- | services/java/com/android/server/NetworkManagementService.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java index 67bb68072106..c3f3a5d47fe4 100644 --- a/services/java/com/android/server/NetworkManagementService.java +++ b/services/java/com/android/server/NetworkManagementService.java @@ -280,6 +280,20 @@ public class NetworkManagementService extends INetworkManagementService.Stub } /** + * 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; |