[DK3] Send onPause/onResume keepalive callbacks
Test: CTS in the patch immediately on top of this, [DK4]
Change-Id: I208ceceb37c7977452479361f70f046fabafb37a
diff --git a/framework/src/android/net/SocketKeepalive.java b/framework/src/android/net/SocketKeepalive.java
index 2911ce7..00104f6 100644
--- a/framework/src/android/net/SocketKeepalive.java
+++ b/framework/src/android/net/SocketKeepalive.java
@@ -64,6 +64,12 @@
public static final int SUCCESS = 0;
/**
+ * Success when trying to suspend.
+ * @hide
+ */
+ public static final int SUCCESS_PAUSED = 1;
+
+ /**
* No keepalive. This should only be internally as it indicates There is no keepalive.
* It should not propagate to applications.
* @hide
@@ -271,6 +277,18 @@
}
@Override
+ public void onResumed() {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ mExecutor.execute(() -> {
+ callback.onResumed();
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
public void onStopped() {
final long token = Binder.clearCallingIdentity();
try {
@@ -283,6 +301,18 @@
}
@Override
+ public void onPaused() {
+ final long token = Binder.clearCallingIdentity();
+ try {
+ executor.execute(() -> {
+ callback.onPaused();
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ @Override
public void onError(int error) {
final long token = Binder.clearCallingIdentity();
try {
@@ -387,8 +417,18 @@
public static class Callback {
/** The requested keepalive was successfully started. */
public void onStarted() {}
+ /**
+ * The keepalive was resumed by the system after being suspended.
+ * @hide
+ **/
+ public void onResumed() {}
/** The keepalive was successfully stopped. */
public void onStopped() {}
+ /**
+ * The keepalive was paused by the system because it's not necessary right now.
+ * @hide
+ **/
+ public void onPaused() {}
/** An error occurred. */
public void onError(@ErrorCode int error) {}
/** The keepalive on a TCP socket was stopped because the socket received data. This is