Skip to content
Snippets Groups Projects
Commit f2c2344c authored by chiachangwang's avatar chiachangwang Committed by Cherrypicker Worker
Browse files

DO not throw exception for ERROR_NO_SUCH_SLOT error

There are multiple independent reasons a keepalive can stop. Some
are software (e.g. the app stops the keepalive) and some are hardware
(e.g. the SIM card gets removed). Therefore, there is a very low
probability that both of these happen at the same time, which would
result in the first stop attempt returning SUCCESS and the second
stop attempt returning NO_SUCH_SLOT. Such a race condition can be
ignored with a log, not to crash the system. Change to wtf log so
that the issue could still be visible since this implies possible
bugs in the system.

Also update the javadoc for SocketKeepalive.ERROR_NO_SUCH_SLOT.

Bug: 281484381
Test: atest FrameworksNetTests
(cherry picked from https://android-review.googlesource.com/q/commit:75673ba5025faa191ae188100b117a4095fab8ab)
Merged-In: I316a2193fc7302b04e074ff0b03dc43946fe5ce6
Change-Id: I316a2193fc7302b04e074ff0b03dc43946fe5ce6
parent 76f4365d
No related branches found
No related tags found
No related merge requests found
......@@ -149,9 +149,7 @@ public abstract class SocketKeepalive implements AutoCloseable {
public static final int ERROR_INSUFFICIENT_RESOURCES = -32;
/**
* There was no such slot. This should only be internally as it indicates
* a programming error in the system server. It should not propagate to
* applications.
* There was no such slot, or no keepalive running on this slot.
* @hide
*/
@SystemApi
......
......@@ -569,7 +569,20 @@ public class KeepaliveTracker {
} else if (reason == ERROR_STOP_REASON_UNINITIALIZED) {
throw new IllegalStateException("Unexpected stop reason: " + reason);
} else if (reason == ERROR_NO_SUCH_SLOT) {
throw new IllegalStateException("No such slot: " + reason);
// There are multiple independent reasons a keepalive can stop. Some
// are software (e.g. the app stops the keepalive) and some are hardware
// (e.g. the SIM card gets removed). Therefore, there is a very low
// probability that both of these happen at the same time, which would
// result in the first stop attempt returning SUCCESS and the second
// stop attempt returning NO_SUCH_SLOT. Such a race condition can be
// ignored with a log.
// This should still be reported because if it happens with any frequency
// it probably means there is a bug where the system server is trying
// to use a non-existing hardware slot.
// TODO : separate the non-existing hardware slot from the case where
// there is no keepalive running on this slot.
Log.wtf(TAG, "Keepalive on slot " + slot + " can't be stopped : " + reason);
notifyErrorCallback(ki.mCallback, reason);
} else {
notifyErrorCallback(ki.mCallback, reason);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment