From 57ab3f648e1b7d7650d31f878ea4f6013cd83a2e Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Mon, 2 Apr 2018 18:12:34 -0700 Subject: [PATCH 1/2] Force creation of Socket upon Transform application This change forces Socket and DatagramSocket to populate the SocketImpl, ensuring that the socket file descriptor can be retrieved when applying Transport mode Transforms This is done by calling getSoLinger(), triggering a getImpl(), which triggers setImpl() if needed. Bug: 77491294 Test: Added tests in IpSecManagerTest, ran on walleye Merged-In: I40da08b031357710eb794e0f866aec5660c79594 Change-Id: I40da08b031357710eb794e0f866aec5660c79594 (cherry picked from commit d175a3d3a01cfdb5ab6d4e61d15950583f8006d6) --- core/java/android/net/IpSecManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/java/android/net/IpSecManager.java b/core/java/android/net/IpSecManager.java index e0654fde6e..0d04fe5a91 100644 --- a/core/java/android/net/IpSecManager.java +++ b/core/java/android/net/IpSecManager.java @@ -337,6 +337,9 @@ public final class IpSecManager { */ public void applyTransportModeTransform(@NonNull Socket socket, @PolicyDirection int direction, @NonNull IpSecTransform transform) throws IOException { + // Ensure creation of FD. See b/77548890 for more details. + socket.getSoLinger(); + applyTransportModeTransform(socket.getFileDescriptor$(), direction, transform); } @@ -441,6 +444,9 @@ public final class IpSecManager { * @throws IOException indicating that the transform could not be removed from the socket */ public void removeTransportModeTransforms(@NonNull Socket socket) throws IOException { + // Ensure creation of FD. See b/77548890 for more details. + socket.getSoLinger(); + removeTransportModeTransforms(socket.getFileDescriptor$()); } From 17a51c8a56426c296fa787918031579cbe549343 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 30 Mar 2018 16:25:11 -0600 Subject: [PATCH 2/2] API council requested tweaks to SubscriptionPlan. Return new shiny Range<> object instead of Pair<>. Tell developers what permission to check on refresh broadcast. Describe what exceptions might be thrown, and that an empty list is okay. Allow creation of plans with richer Period object, instead of forcing them into rigid week or day options. Protect SubscriptionPlan broadcast. Test: atest android.util.RecurrenceRuleTest Test: atest com.android.server.NetworkPolicyManagerServiceTest Bug: 74945820 Change-Id: I7e555798e0cfaa214ca93d9df627c6443fc5d986 --- .../com/android/server/net/NetworkStatsCollection.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/net/NetworkStatsCollection.java b/services/core/java/com/android/server/net/NetworkStatsCollection.java index 2ef754e2ba..ab525237db 100644 --- a/services/core/java/com/android/server/net/NetworkStatsCollection.java +++ b/services/core/java/com/android/server/net/NetworkStatsCollection.java @@ -47,7 +47,7 @@ import android.util.ArrayMap; import android.util.AtomicFile; import android.util.IntArray; import android.util.MathUtils; -import android.util.Pair; +import android.util.Range; import android.util.Slog; import android.util.proto.ProtoOutputStream; @@ -266,11 +266,11 @@ public class NetworkStatsCollection implements FileRotator.Reader { long collectEnd = end; if (augmentEnd != SubscriptionPlan.TIME_UNKNOWN) { - final Iterator> it = augmentPlan.cycleIterator(); + final Iterator> it = augmentPlan.cycleIterator(); while (it.hasNext()) { - final Pair cycle = it.next(); - final long cycleStart = cycle.first.toInstant().toEpochMilli(); - final long cycleEnd = cycle.second.toInstant().toEpochMilli(); + final Range cycle = it.next(); + final long cycleStart = cycle.getLower().toInstant().toEpochMilli(); + final long cycleEnd = cycle.getUpper().toInstant().toEpochMilli(); if (cycleStart <= augmentEnd && augmentEnd < cycleEnd) { augmentStart = cycleStart; collectStart = Long.min(collectStart, augmentStart);