summaryrefslogtreecommitdiff
path: root/framework/src/android/net/NetworkAgent.java
diff options
context:
space:
mode:
authorChiachang Wang <chiachangwang@google.com>2021-03-24 18:39:17 +0800
committerChiachang Wang <chiachangwang@google.com>2021-03-25 18:27:24 +0800
commit3f6cc0758ff0b52ea35e28d30be94b65f11e9c53 (patch)
tree29d5a22ac3c99e7ff5e7330ecc60224f61dadc30 /framework/src/android/net/NetworkAgent.java
parentf7d45ff96e6f2fbed0a5d5d138c1af6ab0332bde (diff)
Add network created callback support
Create a network callback to notify network agent after netd has created the network, so that the NetworkAgent may wait for this callback and ensure the pre-work to communicate with netd completed. Bug: 178725261 Test: make update-api Change-Id: I8c2ff7bd6980ae838abc5669f9419d62741b8666 Merged-In: I8c2ff7bd6980ae838abc5669f9419d62741b8666
Diffstat (limited to 'framework/src/android/net/NetworkAgent.java')
-rw-r--r--framework/src/android/net/NetworkAgent.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/framework/src/android/net/NetworkAgent.java b/framework/src/android/net/NetworkAgent.java
index 2eefba9eaf..aea70e3168 100644
--- a/framework/src/android/net/NetworkAgent.java
+++ b/framework/src/android/net/NetworkAgent.java
@@ -362,6 +362,14 @@ public abstract class NetworkAgent {
*/
public static final int CMD_UNREGISTER_QOS_CALLBACK = BASE + 21;
+ /**
+ * Sent by ConnectivityService to {@link NetworkAgent} to inform the agent that its native
+ * network was created and the Network object is now valid.
+ *
+ * @hide
+ */
+ public static final int CMD_NETWORK_CREATED = BASE + 22;
+
private static NetworkInfo getLegacyNetworkInfo(final NetworkAgentConfig config) {
// The subtype can be changed with (TODO) setLegacySubtype, but it starts
// with 0 (TelephonyManager.NETWORK_TYPE_UNKNOWN) and an empty description.
@@ -563,6 +571,10 @@ public abstract class NetworkAgent {
msg.arg1 /* QoS callback id */);
break;
}
+ case CMD_NETWORK_CREATED: {
+ onNetworkCreated();
+ break;
+ }
}
}
}
@@ -703,6 +715,11 @@ public abstract class NetworkAgent {
mHandler.sendMessage(mHandler.obtainMessage(
CMD_UNREGISTER_QOS_CALLBACK, qosCallbackId, 0, null));
}
+
+ @Override
+ public void onNetworkCreated() {
+ mHandler.sendMessage(mHandler.obtainMessage(CMD_NETWORK_CREATED));
+ }
}
/**
@@ -1011,6 +1028,11 @@ public abstract class NetworkAgent {
}
/**
+ * Called when ConnectivityService has successfully created this NetworkAgent's native network.
+ */
+ public void onNetworkCreated() {}
+
+ /**
* Requests that the network hardware send the specified packet at the specified interval.
*
* @param slot the hardware slot on which to start the keepalive.