Merge "Add AIDL parcelable for NattKeepalivePacketData" am: 6d7ed60834
am: 719477eb03
Change-Id: Iae8d866230dfd8aa2de1b69891d8494812886aac
This commit is contained in:
@@ -30,6 +30,7 @@ aidl_interface {
|
|||||||
"java/android/net/INetworkStackConnector.aidl",
|
"java/android/net/INetworkStackConnector.aidl",
|
||||||
"java/android/net/INetworkStackStatusCallback.aidl",
|
"java/android/net/INetworkStackStatusCallback.aidl",
|
||||||
"java/android/net/InitialConfigurationParcelable.aidl",
|
"java/android/net/InitialConfigurationParcelable.aidl",
|
||||||
|
"java/android/net/NattKeepalivePacketDataParcelable.aidl",
|
||||||
"java/android/net/PrivateDnsConfigParcel.aidl",
|
"java/android/net/PrivateDnsConfigParcel.aidl",
|
||||||
"java/android/net/ProvisioningConfigurationParcelable.aidl",
|
"java/android/net/ProvisioningConfigurationParcelable.aidl",
|
||||||
"java/android/net/TcpKeepalivePacketDataParcelable.aidl",
|
"java/android/net/TcpKeepalivePacketDataParcelable.aidl",
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ package android.net;
|
|||||||
import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS;
|
import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS;
|
||||||
import static android.net.SocketKeepalive.ERROR_INVALID_PORT;
|
import static android.net.SocketKeepalive.ERROR_INVALID_PORT;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.net.SocketKeepalive.InvalidPacketException;
|
import android.net.SocketKeepalive.InvalidPacketException;
|
||||||
import android.net.util.IpUtils;
|
import android.net.util.IpUtils;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.system.OsConstants;
|
import android.system.OsConstants;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
@@ -29,8 +31,7 @@ import java.nio.ByteBuffer;
|
|||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
/** @hide */
|
/** @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
|
// This should only be constructed via static factory methods, such as
|
||||||
// nattKeepalivePacket
|
// nattKeepalivePacket
|
||||||
private NattKeepalivePacketData(InetAddress srcAddress, int srcPort,
|
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());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user