summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mark Chien <markchien@google.com> 2019-04-29 10:26:35 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-04-29 10:26:35 +0000
commit6d7ed608344172e9d313a1d2b5899a81390406fa (patch)
tree54171085f3a9125f2f61f308aa7addb7f7e212dc
parentd38eaa88208885045b05fa5d3d105752edab58af (diff)
parent76985bd9a5577fb905e45b20513661ee10c1f44f (diff)
Merge "Add AIDL parcelable for NattKeepalivePacketData"
-rw-r--r--services/net/Android.bp1
-rw-r--r--services/net/java/android/net/NattKeepalivePacketData.java19
-rw-r--r--services/net/java/android/net/NattKeepalivePacketDataParcelable.aidl25
3 files changed, 43 insertions, 2 deletions
diff --git a/services/net/Android.bp b/services/net/Android.bp
index d72f1cf8382b..10a5b4d10f44 100644
--- a/services/net/Android.bp
+++ b/services/net/Android.bp
@@ -30,6 +30,7 @@ aidl_interface {
"java/android/net/INetworkStackConnector.aidl",
"java/android/net/INetworkStackStatusCallback.aidl",
"java/android/net/InitialConfigurationParcelable.aidl",
+ "java/android/net/NattKeepalivePacketDataParcelable.aidl",
"java/android/net/PrivateDnsConfigParcel.aidl",
"java/android/net/ProvisioningConfigurationParcelable.aidl",
"java/android/net/TcpKeepalivePacketDataParcelable.aidl",
diff --git a/services/net/java/android/net/NattKeepalivePacketData.java b/services/net/java/android/net/NattKeepalivePacketData.java
index bdb246f516a2..27ed11e119b7 100644
--- a/services/net/java/android/net/NattKeepalivePacketData.java
+++ b/services/net/java/android/net/NattKeepalivePacketData.java
@@ -19,8 +19,10 @@ package android.net;
import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS;
import static android.net.SocketKeepalive.ERROR_INVALID_PORT;
+import android.annotation.NonNull;
import android.net.SocketKeepalive.InvalidPacketException;
import android.net.util.IpUtils;
+import android.os.Parcelable;
import android.system.OsConstants;
import java.net.Inet4Address;
@@ -29,8 +31,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/** @hide */
-public final class NattKeepalivePacketData extends KeepalivePacketData {
-
+public final class NattKeepalivePacketData extends KeepalivePacketData implements Parcelable {
// This should only be constructed via static factory methods, such as
// nattKeepalivePacket
private NattKeepalivePacketData(InetAddress srcAddress, int srcPort,
@@ -77,4 +78,18 @@ public final class NattKeepalivePacketData extends KeepalivePacketData {
return new NattKeepalivePacketData(srcAddress, srcPort, dstAddress, dstPort, buf.array());
}
+
+ /**
+ * Convert this NattKeepalivePacketData to a NattKeepalivePacketDataParcelable.
+ */
+ @NonNull
+ public NattKeepalivePacketDataParcelable toStableParcelable() {
+ final NattKeepalivePacketDataParcelable parcel = new NattKeepalivePacketDataParcelable();
+
+ parcel.srcAddress = srcAddress.getAddress();
+ parcel.srcPort = srcPort;
+ parcel.dstAddress = dstAddress.getAddress();
+ parcel.dstPort = dstPort;
+ return parcel;
+ }
}
diff --git a/services/net/java/android/net/NattKeepalivePacketDataParcelable.aidl b/services/net/java/android/net/NattKeepalivePacketDataParcelable.aidl
new file mode 100644
index 000000000000..6f006d4971fb
--- /dev/null
+++ b/services/net/java/android/net/NattKeepalivePacketDataParcelable.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net;
+
+parcelable NattKeepalivePacketDataParcelable {
+ byte[] srcAddress;
+ int srcPort;
+ byte[] dstAddress;
+ int dstPort;
+}
+