From 06835112ab5b0714956468a6ae1bae4631a8adc9 Mon Sep 17 00:00:00 2001 From: junyulai Date: Thu, 3 Jan 2019 18:50:15 +0800 Subject: [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 --- core/java/android/net/SocketKeepalive.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'core/java/android/net/SocketKeepalive.java') diff --git a/core/java/android/net/SocketKeepalive.java b/core/java/android/net/SocketKeepalive.java index 97d50f4bac05..a47c11af40dc 100644 --- a/core/java/android/net/SocketKeepalive.java +++ b/core/java/android/net/SocketKeepalive.java @@ -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) { -- cgit v1.2.3