Separate events usage for starting socket keepalives

This is a clean up commit to correct the javadoc of
NetworkAgent.CMD_START_SOCKET_KEEPALIVE. This event was used
between ConnectivityService/NetworkAgent, and also
ConnectivityService/KeepaliveTracker with different semantics.
This may confuse the developers to update the doc incorrectly,
so also separate the usage to different events.

Also move the event definitions together so that a new event
definition will not mis-use the existing values.

Test: atest FrameworksNetTests
Change-Id: I73ebd8abcc610531da3057da2d643a41befb2099
This commit is contained in:
chiachangwang
2023-04-14 07:32:43 +00:00
parent e2294fb13e
commit f1b1fb4b7f
4 changed files with 50 additions and 41 deletions

View File

@@ -281,9 +281,8 @@ public abstract class NetworkAgent {
*
* arg1 = the hardware slot number of the keepalive to start
* arg2 = interval in seconds
* obj = AutomaticKeepaliveInfo object
* obj = KeepalivePacketData object describing the data to be sent
*
* Also used internally by ConnectivityService / KeepaliveTracker, with different semantics.
* @hide
*/
public static final int CMD_START_SOCKET_KEEPALIVE = BASE + 11;
@@ -435,6 +434,14 @@ public abstract class NetworkAgent {
*/
public static final int CMD_DSCP_POLICY_STATUS = BASE + 28;
/**
* Sent by the NetworkAgent to ConnectivityService to notify that this network is expected to be
* replaced within the specified time by a similar network.
* arg1 = timeout in milliseconds
* @hide
*/
public static final int EVENT_UNREGISTER_AFTER_REPLACEMENT = BASE + 29;
/**
* DSCP policy was successfully added.
*/
@@ -477,27 +484,6 @@ public abstract class NetworkAgent {
@Retention(RetentionPolicy.SOURCE)
public @interface DscpPolicyStatus {}
/**
* Sent by the NetworkAgent to ConnectivityService to notify that this network is expected to be
* replaced within the specified time by a similar network.
* arg1 = timeout in milliseconds
* @hide
*/
public static final int EVENT_UNREGISTER_AFTER_REPLACEMENT = BASE + 29;
/**
* Sent by AutomaticOnOffKeepaliveTracker periodically (when relevant) to trigger monitor
* automatic keepalive request.
*
* NATT keepalives have an automatic mode where the system only sends keepalive packets when
* TCP sockets are open over a VPN. The system will check periodically for presence of
* such open sockets, and this message is what triggers the re-evaluation.
*
* obj = A Binder object associated with the keepalive.
* @hide
*/
public static final int CMD_MONITOR_AUTOMATIC_KEEPALIVE = BASE + 30;
private static NetworkInfo getLegacyNetworkInfo(final NetworkAgentConfig config) {
final NetworkInfo ni = new NetworkInfo(config.legacyType, config.legacySubType,
config.legacyTypeName, config.legacySubTypeName);