Merge "Duplicate the fd instead of reference" into main
diff --git a/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java b/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java
index 368860e..d03cac6 100644
--- a/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java
+++ b/service/src/com/android/server/connectivity/AutomaticOnOffKeepaliveTracker.java
@@ -495,8 +495,11 @@
final AutomaticOnOffKeepalive autoKi;
try {
autoKi = target.withKeepaliveInfo(res.second);
- // Close the duplicated fd.
- target.close();
+ // Only automatic keepalives duplicate the fd.
+ if (target.mAutomaticOnOffState != STATE_ALWAYS_ON) {
+ // Close the duplicated fd.
+ target.close();
+ }
} catch (InvalidSocketException e) {
Log.wtf(TAG, "Fail to create AutomaticOnOffKeepalive", e);
return;