[KA02] internal cleanup and refactor for SocketKeepalive

In previous change, the new SocketKeepalive API was exported.
But internally, old PacketKeepalive names and structures are
still used.

This change rename them properly for code consistency and also
refactor KeepalivePacketData to support different types of
KeepalivePacketData.

Bug: 114151147
Test: 1. atest FrameworksNetTests
      2. atest FrameworksWifiTests
      3. atest FrameworksTelephonyTests

Change-Id: Ia9917d12987e91e87e34ffb3f126e7bc7c9c187e
Merged-In: Ia9917d12987e91e87e34ffb3f126e7bc7c9c187e
This commit is contained in:
junyulai 2019-01-03 18:50:15 +08:00 • committed by Chalard Jean
commit 21c06d06ce

View file

@ -109,6 +109,18 @@ public abstract class SocketKeepalive implements AutoCloseable {
**/
public static final int MAX_INTERVAL_SEC = 3600;
/**
* This packet is invalid.
* See the error code for details.
* @hide
*/
public static class InvalidPacketException extends Exception {
public final int error;
public InvalidPacketException(int error) {
this.error = error;
}
}
@NonNull final IConnectivityManager mService;
@NonNull final Network mNetwork;
@NonNull private final Executor mExecutor;
@ -135,7 +147,7 @@ public abstract class SocketKeepalive implements AutoCloseable {
@Override
public void handleMessage(Message message) {
switch (message.what) {
case NetworkAgent.EVENT_PACKET_KEEPALIVE:
case NetworkAgent.EVENT_SOCKET_KEEPALIVE:
final int status = message.arg2;
try {
if (status == SUCCESS) {