Merge "Remove aidl wrappers for framework parcelables" am: 1a1396070e
am: 7cf43a2f53
Change-Id: I41a07768ec8d9af2b7f16d86ee074c206b153b0c
This commit is contained in:
13
Android.bp
13
Android.bp
@@ -832,14 +832,9 @@ aidl_interface {
|
|||||||
"core/java/android/net/INetworkStackConnector.aidl",
|
"core/java/android/net/INetworkStackConnector.aidl",
|
||||||
"core/java/android/net/INetworkStackStatusCallback.aidl",
|
"core/java/android/net/INetworkStackStatusCallback.aidl",
|
||||||
"core/java/android/net/InitialConfigurationParcelable.aidl",
|
"core/java/android/net/InitialConfigurationParcelable.aidl",
|
||||||
"core/java/android/net/IpPrefixParcelable.aidl",
|
|
||||||
"core/java/android/net/LinkAddressParcelable.aidl",
|
|
||||||
"core/java/android/net/LinkPropertiesParcelable.aidl",
|
|
||||||
"core/java/android/net/NetworkParcelable.aidl",
|
"core/java/android/net/NetworkParcelable.aidl",
|
||||||
"core/java/android/net/PrivateDnsConfigParcel.aidl",
|
"core/java/android/net/PrivateDnsConfigParcel.aidl",
|
||||||
"core/java/android/net/ProvisioningConfigurationParcelable.aidl",
|
"core/java/android/net/ProvisioningConfigurationParcelable.aidl",
|
||||||
"core/java/android/net/ProxyInfoParcelable.aidl",
|
|
||||||
"core/java/android/net/RouteInfoParcelable.aidl",
|
|
||||||
"core/java/android/net/StaticIpConfigurationParcelable.aidl",
|
"core/java/android/net/StaticIpConfigurationParcelable.aidl",
|
||||||
"core/java/android/net/TcpKeepalivePacketDataParcelable.aidl",
|
"core/java/android/net/TcpKeepalivePacketDataParcelable.aidl",
|
||||||
"core/java/android/net/dhcp/DhcpServingParamsParcel.aidl",
|
"core/java/android/net/dhcp/DhcpServingParamsParcel.aidl",
|
||||||
@@ -848,6 +843,14 @@ aidl_interface {
|
|||||||
"core/java/android/net/ip/IIpClient.aidl",
|
"core/java/android/net/ip/IIpClient.aidl",
|
||||||
"core/java/android/net/ip/IIpClientCallbacks.aidl",
|
"core/java/android/net/ip/IIpClientCallbacks.aidl",
|
||||||
],
|
],
|
||||||
|
backend: {
|
||||||
|
ndk: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
cpp: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
api_dir: "aidl/networkstack",
|
api_dir: "aidl/networkstack",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import android.net.IpPrefixParcelable;
|
import android.net.IpPrefix;
|
||||||
import android.net.LinkAddressParcelable;
|
import android.net.LinkAddress;
|
||||||
|
|
||||||
parcelable InitialConfigurationParcelable {
|
parcelable InitialConfigurationParcelable {
|
||||||
LinkAddressParcelable[] ipAddresses;
|
LinkAddress[] ipAddresses;
|
||||||
IpPrefixParcelable[] directlyConnectedRoutes;
|
IpPrefix[] directlyConnectedRoutes;
|
||||||
String[] dnsServers;
|
String[] dnsServers;
|
||||||
String gateway;
|
String gateway;
|
||||||
}
|
}
|
||||||
@@ -17,4 +17,6 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
parcelable IpPrefix cpp_header "binder/IpPrefix.h";
|
// @JavaOnlyStableParcelable only affects the parcelable when built as stable aidl (aidl_interface
|
||||||
|
// build rule). IpPrefix is also used in cpp but only as non-stable aidl.
|
||||||
|
@JavaOnlyStableParcelable parcelable IpPrefix cpp_header "binder/IpPrefix.h";
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 IpPrefixParcelable {
|
|
||||||
String address;
|
|
||||||
int prefixLength;
|
|
||||||
}
|
|
||||||
@@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
parcelable LinkAddress;
|
@JavaOnlyStableParcelable parcelable LinkAddress;
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 LinkAddressParcelable {
|
|
||||||
String address;
|
|
||||||
int prefixLength;
|
|
||||||
int flags;
|
|
||||||
int scope;
|
|
||||||
}
|
|
||||||
@@ -17,4 +17,4 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
parcelable LinkProperties;
|
@JavaOnlyStableParcelable parcelable LinkProperties;
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
import android.net.IpPrefixParcelable;
|
|
||||||
import android.net.LinkAddressParcelable;
|
|
||||||
import android.net.ProxyInfoParcelable;
|
|
||||||
import android.net.RouteInfoParcelable;
|
|
||||||
|
|
||||||
parcelable LinkPropertiesParcelable {
|
|
||||||
String ifaceName;
|
|
||||||
LinkAddressParcelable[] linkAddresses;
|
|
||||||
String[] dnses;
|
|
||||||
String[] pcscfs;
|
|
||||||
String[] validatedPrivateDnses;
|
|
||||||
boolean usePrivateDns;
|
|
||||||
String privateDnsServerName;
|
|
||||||
String domains;
|
|
||||||
RouteInfoParcelable[] routes;
|
|
||||||
ProxyInfoParcelable httpProxy;
|
|
||||||
int mtu;
|
|
||||||
String tcpBufferSizes;
|
|
||||||
IpPrefixParcelable nat64Prefix;
|
|
||||||
}
|
|
||||||
@@ -17,5 +17,5 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
parcelable ProxyInfo;
|
@JavaOnlyStableParcelable parcelable ProxyInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 ProxyInfoParcelable {
|
|
||||||
String host;
|
|
||||||
int port;
|
|
||||||
String[] exclusionList;
|
|
||||||
String pacFileUrl;
|
|
||||||
}
|
|
||||||
@@ -16,4 +16,4 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
parcelable RouteInfo;
|
@JavaOnlyStableParcelable parcelable RouteInfo;
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
import android.net.IpPrefixParcelable;
|
|
||||||
|
|
||||||
parcelable RouteInfoParcelable {
|
|
||||||
IpPrefixParcelable destination;
|
|
||||||
String gatewayAddr;
|
|
||||||
String ifaceName;
|
|
||||||
int type;
|
|
||||||
}
|
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import android.net.LinkAddressParcelable;
|
import android.net.LinkAddress;
|
||||||
|
|
||||||
parcelable StaticIpConfigurationParcelable {
|
parcelable StaticIpConfigurationParcelable {
|
||||||
LinkAddressParcelable ipAddress;
|
LinkAddress ipAddress;
|
||||||
String gateway;
|
String gateway;
|
||||||
String[] dnsServers;
|
String[] dnsServers;
|
||||||
String domains;
|
String domains;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package android.net.ip;
|
package android.net.ip;
|
||||||
|
|
||||||
import android.net.ProxyInfoParcelable;
|
import android.net.ProxyInfo;
|
||||||
import android.net.ProvisioningConfigurationParcelable;
|
import android.net.ProvisioningConfigurationParcelable;
|
||||||
import android.net.TcpKeepalivePacketDataParcelable;
|
import android.net.TcpKeepalivePacketDataParcelable;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ oneway interface IIpClient {
|
|||||||
void startProvisioning(in ProvisioningConfigurationParcelable req);
|
void startProvisioning(in ProvisioningConfigurationParcelable req);
|
||||||
void stop();
|
void stop();
|
||||||
void setTcpBufferSizes(in String tcpBufferSizes);
|
void setTcpBufferSizes(in String tcpBufferSizes);
|
||||||
void setHttpProxy(in ProxyInfoParcelable proxyInfo);
|
void setHttpProxy(in ProxyInfo proxyInfo);
|
||||||
void setMulticastFilter(boolean enabled);
|
void setMulticastFilter(boolean enabled);
|
||||||
void addKeepalivePacketFilter(int slot, in TcpKeepalivePacketDataParcelable pkt);
|
void addKeepalivePacketFilter(int slot, in TcpKeepalivePacketDataParcelable pkt);
|
||||||
void removeKeepalivePacketFilter(int slot);
|
void removeKeepalivePacketFilter(int slot);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package android.net.ip;
|
package android.net.ip;
|
||||||
|
|
||||||
import android.net.LinkPropertiesParcelable;
|
import android.net.LinkProperties;
|
||||||
import android.net.ip.IIpClient;
|
import android.net.ip.IIpClient;
|
||||||
import android.net.DhcpResultsParcelable;
|
import android.net.DhcpResultsParcelable;
|
||||||
|
|
||||||
@@ -34,11 +34,11 @@ oneway interface IIpClientCallbacks {
|
|||||||
// null or not.
|
// null or not.
|
||||||
void onNewDhcpResults(in DhcpResultsParcelable dhcpResults);
|
void onNewDhcpResults(in DhcpResultsParcelable dhcpResults);
|
||||||
|
|
||||||
void onProvisioningSuccess(in LinkPropertiesParcelable newLp);
|
void onProvisioningSuccess(in LinkProperties newLp);
|
||||||
void onProvisioningFailure(in LinkPropertiesParcelable newLp);
|
void onProvisioningFailure(in LinkProperties newLp);
|
||||||
|
|
||||||
// Invoked on LinkProperties changes.
|
// Invoked on LinkProperties changes.
|
||||||
void onLinkPropertiesChange(in LinkPropertiesParcelable newLp);
|
void onLinkPropertiesChange(in LinkProperties newLp);
|
||||||
|
|
||||||
// Called when the internal IpReachabilityMonitor (if enabled) has
|
// Called when the internal IpReachabilityMonitor (if enabled) has
|
||||||
// detected the loss of a critical number of required neighbors.
|
// detected the loss of a critical number of required neighbors.
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ package android.net.ip;
|
|||||||
|
|
||||||
import static android.net.RouteInfo.RTN_UNICAST;
|
import static android.net.RouteInfo.RTN_UNICAST;
|
||||||
import static android.net.shared.IpConfigurationParcelableUtil.toStableParcelable;
|
import static android.net.shared.IpConfigurationParcelableUtil.toStableParcelable;
|
||||||
import static android.net.shared.LinkPropertiesParcelableUtil.fromStableParcelable;
|
|
||||||
import static android.net.shared.LinkPropertiesParcelableUtil.toStableParcelable;
|
|
||||||
|
|
||||||
import static com.android.server.util.PermissionUtil.checkNetworkStackCallingPermission;
|
import static com.android.server.util.PermissionUtil.checkNetworkStackCallingPermission;
|
||||||
|
|
||||||
@@ -33,7 +31,6 @@ import android.net.LinkAddress;
|
|||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.ProvisioningConfigurationParcelable;
|
import android.net.ProvisioningConfigurationParcelable;
|
||||||
import android.net.ProxyInfo;
|
import android.net.ProxyInfo;
|
||||||
import android.net.ProxyInfoParcelable;
|
|
||||||
import android.net.RouteInfo;
|
import android.net.RouteInfo;
|
||||||
import android.net.TcpKeepalivePacketDataParcelable;
|
import android.net.TcpKeepalivePacketDataParcelable;
|
||||||
import android.net.apf.ApfCapabilities;
|
import android.net.apf.ApfCapabilities;
|
||||||
@@ -201,7 +198,7 @@ public class IpClient extends StateMachine {
|
|||||||
public void onProvisioningSuccess(LinkProperties newLp) {
|
public void onProvisioningSuccess(LinkProperties newLp) {
|
||||||
log("onProvisioningSuccess({" + newLp + "})");
|
log("onProvisioningSuccess({" + newLp + "})");
|
||||||
try {
|
try {
|
||||||
mCallback.onProvisioningSuccess(toStableParcelable(newLp));
|
mCallback.onProvisioningSuccess(newLp);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
log("Failed to call onProvisioningSuccess", e);
|
log("Failed to call onProvisioningSuccess", e);
|
||||||
}
|
}
|
||||||
@@ -210,7 +207,7 @@ public class IpClient extends StateMachine {
|
|||||||
public void onProvisioningFailure(LinkProperties newLp) {
|
public void onProvisioningFailure(LinkProperties newLp) {
|
||||||
log("onProvisioningFailure({" + newLp + "})");
|
log("onProvisioningFailure({" + newLp + "})");
|
||||||
try {
|
try {
|
||||||
mCallback.onProvisioningFailure(toStableParcelable(newLp));
|
mCallback.onProvisioningFailure(newLp);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
log("Failed to call onProvisioningFailure", e);
|
log("Failed to call onProvisioningFailure", e);
|
||||||
}
|
}
|
||||||
@@ -219,7 +216,7 @@ public class IpClient extends StateMachine {
|
|||||||
public void onLinkPropertiesChange(LinkProperties newLp) {
|
public void onLinkPropertiesChange(LinkProperties newLp) {
|
||||||
log("onLinkPropertiesChange({" + newLp + "})");
|
log("onLinkPropertiesChange({" + newLp + "})");
|
||||||
try {
|
try {
|
||||||
mCallback.onLinkPropertiesChange(toStableParcelable(newLp));
|
mCallback.onLinkPropertiesChange(newLp);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
log("Failed to call onLinkPropertiesChange", e);
|
log("Failed to call onLinkPropertiesChange", e);
|
||||||
}
|
}
|
||||||
@@ -525,9 +522,9 @@ public class IpClient extends StateMachine {
|
|||||||
IpClient.this.setTcpBufferSizes(tcpBufferSizes);
|
IpClient.this.setTcpBufferSizes(tcpBufferSizes);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void setHttpProxy(ProxyInfoParcelable proxyInfo) {
|
public void setHttpProxy(ProxyInfo proxyInfo) {
|
||||||
checkNetworkStackCallingPermission();
|
checkNetworkStackCallingPermission();
|
||||||
IpClient.this.setHttpProxy(fromStableParcelable(proxyInfo));
|
IpClient.this.setHttpProxy(proxyInfo);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void setMulticastFilter(boolean enabled) {
|
public void setMulticastFilter(boolean enabled) {
|
||||||
|
|||||||
@@ -16,13 +16,10 @@
|
|||||||
|
|
||||||
package android.net.ip;
|
package android.net.ip;
|
||||||
|
|
||||||
import static android.net.shared.LinkPropertiesParcelableUtil.fromStableParcelable;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.mockito.ArgumentMatchers.argThat;
|
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.anyString;
|
import static org.mockito.Mockito.anyString;
|
||||||
import static org.mockito.Mockito.eq;
|
import static org.mockito.Mockito.eq;
|
||||||
@@ -207,8 +204,7 @@ public class IpClientTest {
|
|||||||
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceSetEnableIPv6(iface, false);
|
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceSetEnableIPv6(iface, false);
|
||||||
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceClearAddrs(iface);
|
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceClearAddrs(iface);
|
||||||
verify(mCb, timeout(TEST_TIMEOUT_MS).times(1))
|
verify(mCb, timeout(TEST_TIMEOUT_MS).times(1))
|
||||||
.onLinkPropertiesChange(argThat(
|
.onLinkPropertiesChange(makeEmptyLinkProperties(iface));
|
||||||
lp -> fromStableParcelable(lp).equals(makeEmptyLinkProperties(iface))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -253,15 +249,13 @@ public class IpClientTest {
|
|||||||
mObserver.onInterfaceAddressUpdated(new LinkAddress(addresses[lastAddr]), iface);
|
mObserver.onInterfaceAddressUpdated(new LinkAddress(addresses[lastAddr]), iface);
|
||||||
LinkProperties want = linkproperties(links(addresses), routes(prefixes));
|
LinkProperties want = linkproperties(links(addresses), routes(prefixes));
|
||||||
want.setInterfaceName(iface);
|
want.setInterfaceName(iface);
|
||||||
verify(mCb, timeout(TEST_TIMEOUT_MS).times(1)).onProvisioningSuccess(argThat(
|
verify(mCb, timeout(TEST_TIMEOUT_MS).times(1)).onProvisioningSuccess(want);
|
||||||
lp -> fromStableParcelable(lp).equals(want)));
|
|
||||||
|
|
||||||
ipc.shutdown();
|
ipc.shutdown();
|
||||||
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceSetEnableIPv6(iface, false);
|
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceSetEnableIPv6(iface, false);
|
||||||
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceClearAddrs(iface);
|
verify(mNetd, timeout(TEST_TIMEOUT_MS).times(1)).interfaceClearAddrs(iface);
|
||||||
verify(mCb, timeout(TEST_TIMEOUT_MS).times(1))
|
verify(mCb, timeout(TEST_TIMEOUT_MS).times(1))
|
||||||
.onLinkPropertiesChange(argThat(
|
.onLinkPropertiesChange(makeEmptyLinkProperties(iface));
|
||||||
lp -> fromStableParcelable(lp).equals(makeEmptyLinkProperties(iface))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -17,12 +17,10 @@
|
|||||||
package android.net.ip;
|
package android.net.ip;
|
||||||
|
|
||||||
import static android.net.shared.IpConfigurationParcelableUtil.fromStableParcelable;
|
import static android.net.shared.IpConfigurationParcelableUtil.fromStableParcelable;
|
||||||
import static android.net.shared.LinkPropertiesParcelableUtil.fromStableParcelable;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.DhcpResultsParcelable;
|
import android.net.DhcpResultsParcelable;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.LinkPropertiesParcelable;
|
|
||||||
import android.net.NetworkStackClient;
|
import android.net.NetworkStackClient;
|
||||||
import android.os.ConditionVariable;
|
import android.os.ConditionVariable;
|
||||||
|
|
||||||
@@ -122,18 +120,18 @@ public class IpClientUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProvisioningSuccess(LinkPropertiesParcelable newLp) {
|
public void onProvisioningSuccess(LinkProperties newLp) {
|
||||||
mCb.onProvisioningSuccess(fromStableParcelable(newLp));
|
mCb.onProvisioningSuccess(newLp);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onProvisioningFailure(LinkPropertiesParcelable newLp) {
|
public void onProvisioningFailure(LinkProperties newLp) {
|
||||||
mCb.onProvisioningFailure(fromStableParcelable(newLp));
|
mCb.onProvisioningFailure(newLp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoked on LinkProperties changes.
|
// Invoked on LinkProperties changes.
|
||||||
@Override
|
@Override
|
||||||
public void onLinkPropertiesChange(LinkPropertiesParcelable newLp) {
|
public void onLinkPropertiesChange(LinkProperties newLp) {
|
||||||
mCb.onLinkPropertiesChange(fromStableParcelable(newLp));
|
mCb.onLinkPropertiesChange(newLp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the internal IpReachabilityMonitor (if enabled) has
|
// Called when the internal IpReachabilityMonitor (if enabled) has
|
||||||
|
|||||||
@@ -23,13 +23,12 @@ import static android.text.TextUtils.join;
|
|||||||
import android.net.InetAddresses;
|
import android.net.InetAddresses;
|
||||||
import android.net.InitialConfigurationParcelable;
|
import android.net.InitialConfigurationParcelable;
|
||||||
import android.net.IpPrefix;
|
import android.net.IpPrefix;
|
||||||
import android.net.IpPrefixParcelable;
|
|
||||||
import android.net.LinkAddress;
|
import android.net.LinkAddress;
|
||||||
import android.net.LinkAddressParcelable;
|
|
||||||
import android.net.RouteInfo;
|
import android.net.RouteInfo;
|
||||||
|
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -148,10 +147,8 @@ public class InitialConfiguration {
|
|||||||
*/
|
*/
|
||||||
public InitialConfigurationParcelable toStableParcelable() {
|
public InitialConfigurationParcelable toStableParcelable() {
|
||||||
final InitialConfigurationParcelable p = new InitialConfigurationParcelable();
|
final InitialConfigurationParcelable p = new InitialConfigurationParcelable();
|
||||||
p.ipAddresses = toParcelableArray(ipAddresses,
|
p.ipAddresses = ipAddresses.toArray(new LinkAddress[0]);
|
||||||
LinkPropertiesParcelableUtil::toStableParcelable, LinkAddressParcelable.class);
|
p.directlyConnectedRoutes = directlyConnectedRoutes.toArray(new IpPrefix[0]);
|
||||||
p.directlyConnectedRoutes = toParcelableArray(directlyConnectedRoutes,
|
|
||||||
LinkPropertiesParcelableUtil::toStableParcelable, IpPrefixParcelable.class);
|
|
||||||
p.dnsServers = toParcelableArray(
|
p.dnsServers = toParcelableArray(
|
||||||
dnsServers, IpConfigurationParcelableUtil::parcelAddress, String.class);
|
dnsServers, IpConfigurationParcelableUtil::parcelAddress, String.class);
|
||||||
return p;
|
return p;
|
||||||
@@ -164,10 +161,8 @@ public class InitialConfiguration {
|
|||||||
public static InitialConfiguration fromStableParcelable(InitialConfigurationParcelable p) {
|
public static InitialConfiguration fromStableParcelable(InitialConfigurationParcelable p) {
|
||||||
if (p == null) return null;
|
if (p == null) return null;
|
||||||
final InitialConfiguration config = new InitialConfiguration();
|
final InitialConfiguration config = new InitialConfiguration();
|
||||||
config.ipAddresses.addAll(fromParcelableArray(
|
config.ipAddresses.addAll(Arrays.asList(p.ipAddresses));
|
||||||
p.ipAddresses, LinkPropertiesParcelableUtil::fromStableParcelable));
|
config.directlyConnectedRoutes.addAll(Arrays.asList(p.directlyConnectedRoutes));
|
||||||
config.directlyConnectedRoutes.addAll(fromParcelableArray(
|
|
||||||
p.directlyConnectedRoutes, LinkPropertiesParcelableUtil::fromStableParcelable));
|
|
||||||
config.dnsServers.addAll(
|
config.dnsServers.addAll(
|
||||||
fromParcelableArray(p.dnsServers, IpConfigurationParcelableUtil::unparcelAddress));
|
fromParcelableArray(p.dnsServers, IpConfigurationParcelableUtil::unparcelAddress));
|
||||||
return config;
|
return config;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public final class IpConfigurationParcelableUtil {
|
|||||||
@Nullable StaticIpConfiguration config) {
|
@Nullable StaticIpConfiguration config) {
|
||||||
if (config == null) return null;
|
if (config == null) return null;
|
||||||
final StaticIpConfigurationParcelable p = new StaticIpConfigurationParcelable();
|
final StaticIpConfigurationParcelable p = new StaticIpConfigurationParcelable();
|
||||||
p.ipAddress = LinkPropertiesParcelableUtil.toStableParcelable(config.getIpAddress());
|
p.ipAddress = config.getIpAddress();
|
||||||
p.gateway = parcelAddress(config.getGateway());
|
p.gateway = parcelAddress(config.getGateway());
|
||||||
p.dnsServers = toParcelableArray(
|
p.dnsServers = toParcelableArray(
|
||||||
config.getDnsServers(), IpConfigurationParcelableUtil::parcelAddress, String.class);
|
config.getDnsServers(), IpConfigurationParcelableUtil::parcelAddress, String.class);
|
||||||
@@ -59,7 +59,7 @@ public final class IpConfigurationParcelableUtil {
|
|||||||
@Nullable StaticIpConfigurationParcelable p) {
|
@Nullable StaticIpConfigurationParcelable p) {
|
||||||
if (p == null) return null;
|
if (p == null) return null;
|
||||||
final StaticIpConfiguration config = new StaticIpConfiguration();
|
final StaticIpConfiguration config = new StaticIpConfiguration();
|
||||||
config.setIpAddress(LinkPropertiesParcelableUtil.fromStableParcelable(p.ipAddress));
|
config.setIpAddress(p.ipAddress);
|
||||||
config.setGateway(unparcelAddress(p.gateway));
|
config.setGateway(unparcelAddress(p.gateway));
|
||||||
for (InetAddress addr : fromParcelableArray(
|
for (InetAddress addr : fromParcelableArray(
|
||||||
p.dnsServers, IpConfigurationParcelableUtil::unparcelAddress)) {
|
p.dnsServers, IpConfigurationParcelableUtil::unparcelAddress)) {
|
||||||
|
|||||||
@@ -16,25 +16,9 @@
|
|||||||
|
|
||||||
package android.net.shared;
|
package android.net.shared;
|
||||||
|
|
||||||
import static android.net.shared.IpConfigurationParcelableUtil.parcelAddress;
|
|
||||||
import static android.net.shared.IpConfigurationParcelableUtil.unparcelAddress;
|
|
||||||
import static android.net.shared.ParcelableUtil.fromParcelableArray;
|
|
||||||
import static android.net.shared.ParcelableUtil.toParcelableArray;
|
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.net.IpPrefix;
|
|
||||||
import android.net.IpPrefixParcelable;
|
|
||||||
import android.net.LinkAddress;
|
|
||||||
import android.net.LinkAddressParcelable;
|
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.LinkPropertiesParcelable;
|
|
||||||
import android.net.ProxyInfo;
|
import android.net.ProxyInfo;
|
||||||
import android.net.ProxyInfoParcelable;
|
|
||||||
import android.net.RouteInfo;
|
|
||||||
import android.net.RouteInfoParcelable;
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of utility methods to convert to and from stable AIDL parcelables for LinkProperties
|
* Collection of utility methods to convert to and from stable AIDL parcelables for LinkProperties
|
||||||
@@ -42,177 +26,22 @@ import java.util.Arrays;
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public final class LinkPropertiesParcelableUtil {
|
public final class LinkPropertiesParcelableUtil {
|
||||||
|
// Temporary methods to facilitate migrating clients away from LinkPropertiesParcelable
|
||||||
|
// TODO: remove the following methods after migrating clients.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a ProxyInfo to a ProxyInfoParcelable
|
* @deprecated conversion to stable parcelable is no longer necessary.
|
||||||
*/
|
*/
|
||||||
public static ProxyInfoParcelable toStableParcelable(@Nullable ProxyInfo proxyInfo) {
|
@Deprecated
|
||||||
if (proxyInfo == null) {
|
public static LinkProperties toStableParcelable(@Nullable LinkProperties lp) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final ProxyInfoParcelable parcel = new ProxyInfoParcelable();
|
|
||||||
parcel.host = proxyInfo.getHost();
|
|
||||||
parcel.port = proxyInfo.getPort();
|
|
||||||
parcel.exclusionList = proxyInfo.getExclusionList();
|
|
||||||
parcel.pacFileUrl = proxyInfo.getPacFileUrl().toString();
|
|
||||||
return parcel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a ProxyInfoParcelable to a ProxyInfo
|
|
||||||
*/
|
|
||||||
public static ProxyInfo fromStableParcelable(@Nullable ProxyInfoParcelable parcel) {
|
|
||||||
if (parcel == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (Uri.EMPTY.toString().equals(parcel.pacFileUrl)) {
|
|
||||||
return ProxyInfo.buildDirectProxy(
|
|
||||||
parcel.host, parcel.port, Arrays.asList(parcel.exclusionList));
|
|
||||||
} else {
|
|
||||||
return ProxyInfo.buildPacProxy(Uri.parse(parcel.pacFileUrl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an IpPrefixParcelable to an IpPrefix
|
|
||||||
*/
|
|
||||||
public static IpPrefixParcelable toStableParcelable(@Nullable IpPrefix ipPrefix) {
|
|
||||||
if (ipPrefix == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final IpPrefixParcelable parcel = new IpPrefixParcelable();
|
|
||||||
parcel.address = parcelAddress(ipPrefix.getAddress());
|
|
||||||
parcel.prefixLength = ipPrefix.getPrefixLength();
|
|
||||||
return parcel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an IpPrefix to an IpPrefixParcelable
|
|
||||||
*/
|
|
||||||
public static IpPrefix fromStableParcelable(@Nullable IpPrefixParcelable parcel) {
|
|
||||||
if (parcel == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new IpPrefix(unparcelAddress(parcel.address), parcel.prefixLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a RouteInfoParcelable to a RouteInfo
|
|
||||||
*/
|
|
||||||
public static RouteInfoParcelable toStableParcelable(@Nullable RouteInfo routeInfo) {
|
|
||||||
if (routeInfo == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final RouteInfoParcelable parcel = new RouteInfoParcelable();
|
|
||||||
parcel.destination = toStableParcelable(routeInfo.getDestination());
|
|
||||||
parcel.gatewayAddr = parcelAddress(routeInfo.getGateway());
|
|
||||||
parcel.ifaceName = routeInfo.getInterface();
|
|
||||||
parcel.type = routeInfo.getType();
|
|
||||||
return parcel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a RouteInfo to a RouteInfoParcelable
|
|
||||||
*/
|
|
||||||
public static RouteInfo fromStableParcelable(@Nullable RouteInfoParcelable parcel) {
|
|
||||||
if (parcel == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final IpPrefix destination = fromStableParcelable(parcel.destination);
|
|
||||||
return new RouteInfo(
|
|
||||||
destination, unparcelAddress(parcel.gatewayAddr),
|
|
||||||
parcel.ifaceName, parcel.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a LinkAddressParcelable to a LinkAddress
|
|
||||||
*/
|
|
||||||
public static LinkAddressParcelable toStableParcelable(@Nullable LinkAddress la) {
|
|
||||||
if (la == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final LinkAddressParcelable parcel = new LinkAddressParcelable();
|
|
||||||
parcel.address = parcelAddress(la.getAddress());
|
|
||||||
parcel.prefixLength = la.getPrefixLength();
|
|
||||||
parcel.flags = la.getFlags();
|
|
||||||
parcel.scope = la.getScope();
|
|
||||||
return parcel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a LinkAddress to a LinkAddressParcelable
|
|
||||||
*/
|
|
||||||
public static LinkAddress fromStableParcelable(@Nullable LinkAddressParcelable parcel) {
|
|
||||||
if (parcel == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new LinkAddress(
|
|
||||||
unparcelAddress(parcel.address),
|
|
||||||
parcel.prefixLength,
|
|
||||||
parcel.flags,
|
|
||||||
parcel.scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a LinkProperties to a LinkPropertiesParcelable
|
|
||||||
*/
|
|
||||||
public static LinkPropertiesParcelable toStableParcelable(@Nullable LinkProperties lp) {
|
|
||||||
if (lp == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final LinkPropertiesParcelable parcel = new LinkPropertiesParcelable();
|
|
||||||
parcel.ifaceName = lp.getInterfaceName();
|
|
||||||
parcel.linkAddresses = toParcelableArray(
|
|
||||||
lp.getLinkAddresses(),
|
|
||||||
LinkPropertiesParcelableUtil::toStableParcelable,
|
|
||||||
LinkAddressParcelable.class);
|
|
||||||
parcel.dnses = toParcelableArray(
|
|
||||||
lp.getDnsServers(), IpConfigurationParcelableUtil::parcelAddress, String.class);
|
|
||||||
parcel.pcscfs = toParcelableArray(
|
|
||||||
lp.getPcscfServers(), IpConfigurationParcelableUtil::parcelAddress, String.class);
|
|
||||||
parcel.validatedPrivateDnses = toParcelableArray(lp.getValidatedPrivateDnsServers(),
|
|
||||||
IpConfigurationParcelableUtil::parcelAddress, String.class);
|
|
||||||
parcel.usePrivateDns = lp.isPrivateDnsActive();
|
|
||||||
parcel.privateDnsServerName = lp.getPrivateDnsServerName();
|
|
||||||
parcel.domains = lp.getDomains();
|
|
||||||
parcel.routes = toParcelableArray(
|
|
||||||
lp.getRoutes(), LinkPropertiesParcelableUtil::toStableParcelable,
|
|
||||||
RouteInfoParcelable.class);
|
|
||||||
parcel.httpProxy = toStableParcelable(lp.getHttpProxy());
|
|
||||||
parcel.mtu = lp.getMtu();
|
|
||||||
parcel.tcpBufferSizes = lp.getTcpBufferSizes();
|
|
||||||
parcel.nat64Prefix = toStableParcelable(lp.getNat64Prefix());
|
|
||||||
return parcel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a LinkPropertiesParcelable to a LinkProperties
|
|
||||||
*/
|
|
||||||
public static LinkProperties fromStableParcelable(@Nullable LinkPropertiesParcelable parcel) {
|
|
||||||
if (parcel == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final LinkProperties lp = new LinkProperties();
|
|
||||||
lp.setInterfaceName(parcel.ifaceName);
|
|
||||||
lp.setLinkAddresses(fromParcelableArray(parcel.linkAddresses,
|
|
||||||
LinkPropertiesParcelableUtil::fromStableParcelable));
|
|
||||||
lp.setDnsServers(fromParcelableArray(
|
|
||||||
parcel.dnses, IpConfigurationParcelableUtil::unparcelAddress));
|
|
||||||
lp.setPcscfServers(fromParcelableArray(
|
|
||||||
parcel.pcscfs, IpConfigurationParcelableUtil::unparcelAddress));
|
|
||||||
lp.setValidatedPrivateDnsServers(
|
|
||||||
fromParcelableArray(parcel.validatedPrivateDnses,
|
|
||||||
IpConfigurationParcelableUtil::unparcelAddress));
|
|
||||||
lp.setUsePrivateDns(parcel.usePrivateDns);
|
|
||||||
lp.setPrivateDnsServerName(parcel.privateDnsServerName);
|
|
||||||
lp.setDomains(parcel.domains);
|
|
||||||
for (RouteInfoParcelable route : parcel.routes) {
|
|
||||||
lp.addRoute(fromStableParcelable(route));
|
|
||||||
}
|
|
||||||
lp.setHttpProxy(fromStableParcelable(parcel.httpProxy));
|
|
||||||
lp.setMtu(parcel.mtu);
|
|
||||||
lp.setTcpBufferSizes(parcel.tcpBufferSizes);
|
|
||||||
lp.setNat64Prefix(fromStableParcelable(parcel.nat64Prefix));
|
|
||||||
return lp;
|
return lp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated conversion to stable parcelable is no longer necessary.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static ProxyInfo toStableParcelable(@Nullable ProxyInfo info) {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,184 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.shared;
|
|
||||||
|
|
||||||
import static android.net.shared.LinkPropertiesParcelableUtil.fromStableParcelable;
|
|
||||||
import static android.net.shared.LinkPropertiesParcelableUtil.toStableParcelable;
|
|
||||||
import static android.net.shared.ParcelableTestUtil.assertFieldCountEquals;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import android.net.InetAddresses;
|
|
||||||
import android.net.IpPrefix;
|
|
||||||
import android.net.LinkAddress;
|
|
||||||
import android.net.LinkProperties;
|
|
||||||
import android.net.ProxyInfo;
|
|
||||||
import android.net.RouteInfo;
|
|
||||||
import android.net.Uri;
|
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link LinkPropertiesParcelableUtil}
|
|
||||||
*/
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
|
||||||
@SmallTest
|
|
||||||
public class LinkPropertiesParcelableUtilTest {
|
|
||||||
private LinkProperties mLinkProperties;
|
|
||||||
|
|
||||||
private static final String TEST_LINKPROPS_IFACE = "TEST_IFACE";
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
mLinkProperties = new LinkProperties();
|
|
||||||
mLinkProperties.setInterfaceName(TEST_LINKPROPS_IFACE);
|
|
||||||
mLinkProperties.setLinkAddresses(Arrays.asList(
|
|
||||||
new LinkAddress(InetAddresses.parseNumericAddress("192.168.0.42"), 16),
|
|
||||||
new LinkAddress(InetAddresses.parseNumericAddress("2001:db8::7"), 42)));
|
|
||||||
mLinkProperties.setDnsServers(Arrays.asList(
|
|
||||||
InetAddresses.parseNumericAddress("2001:db8::42"),
|
|
||||||
InetAddresses.parseNumericAddress("192.168.1.1")
|
|
||||||
));
|
|
||||||
mLinkProperties.setValidatedPrivateDnsServers(Arrays.asList(
|
|
||||||
InetAddresses.parseNumericAddress("2001:db8::43"),
|
|
||||||
InetAddresses.parseNumericAddress("192.168.42.43")
|
|
||||||
));
|
|
||||||
mLinkProperties.setPcscfServers(Arrays.asList(
|
|
||||||
InetAddresses.parseNumericAddress("2001:db8::47"),
|
|
||||||
InetAddresses.parseNumericAddress("192.168.42.47")
|
|
||||||
));
|
|
||||||
mLinkProperties.setUsePrivateDns(true);
|
|
||||||
mLinkProperties.setPrivateDnsServerName("test.example.com");
|
|
||||||
mLinkProperties.setDomains("test1.example.com,test2.example.com");
|
|
||||||
mLinkProperties.addRoute(new RouteInfo(
|
|
||||||
new IpPrefix(InetAddresses.parseNumericAddress("2001:db8::44"), 45),
|
|
||||||
InetAddresses.parseNumericAddress("2001:db8::45"),
|
|
||||||
TEST_LINKPROPS_IFACE,
|
|
||||||
RouteInfo.RTN_UNICAST
|
|
||||||
));
|
|
||||||
mLinkProperties.addRoute(new RouteInfo(
|
|
||||||
new IpPrefix(InetAddresses.parseNumericAddress("192.168.44.45"), 16),
|
|
||||||
InetAddresses.parseNumericAddress("192.168.45.1"),
|
|
||||||
TEST_LINKPROPS_IFACE,
|
|
||||||
RouteInfo.RTN_THROW
|
|
||||||
));
|
|
||||||
mLinkProperties.setHttpProxy(new ProxyInfo("test3.example.com", 8000,
|
|
||||||
"excl1.example.com,excl2.example.com"));
|
|
||||||
mLinkProperties.setMtu(5000);
|
|
||||||
mLinkProperties.setTcpBufferSizes("1,2,3,4,5,6");
|
|
||||||
mLinkProperties.setNat64Prefix(
|
|
||||||
new IpPrefix(InetAddresses.parseNumericAddress("2001:db8::48"), 96));
|
|
||||||
|
|
||||||
// Verify that this test does not miss any new field added later.
|
|
||||||
// If any added field is not included in LinkProperties#equals, assertLinkPropertiesEquals
|
|
||||||
// must also be updated.
|
|
||||||
assertFieldCountEquals(14, LinkProperties.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel() {
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_NullInterface() {
|
|
||||||
mLinkProperties.setInterfaceName(null);
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_NullPrivateDnsServer() {
|
|
||||||
mLinkProperties.setPrivateDnsServerName(null);
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_NullDomains() {
|
|
||||||
mLinkProperties.setDomains(null);
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_NullProxy() {
|
|
||||||
mLinkProperties.setHttpProxy(null);
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_NullTcpBufferSizes() {
|
|
||||||
mLinkProperties.setTcpBufferSizes(null);
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_EmptyLinkAddresses() {
|
|
||||||
mLinkProperties.setLinkAddresses(Collections.emptyList());
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_EmptyDnses() {
|
|
||||||
mLinkProperties.setDnsServers(Collections.emptyList());
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_EmptyValidatedPrivateDnses() {
|
|
||||||
mLinkProperties.setValidatedPrivateDnsServers(Collections.emptyList());
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_EmptyRoutes() {
|
|
||||||
for (RouteInfo r : mLinkProperties.getAllRoutes()) {
|
|
||||||
mLinkProperties.removeRoute(r);
|
|
||||||
}
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_PacFileProxyInfo() {
|
|
||||||
mLinkProperties.setHttpProxy(new ProxyInfo(Uri.parse("http://pacfile.example.com")));
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testParcelUnparcel_NullNat64Prefix() {
|
|
||||||
mLinkProperties.setNat64Prefix(null);
|
|
||||||
doParcelUnparcelTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doParcelUnparcelTest() {
|
|
||||||
final LinkProperties unparceled = fromStableParcelable(toStableParcelable(mLinkProperties));
|
|
||||||
assertLinkPropertiesEquals(mLinkProperties, unparceled);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void assertLinkPropertiesEquals(LinkProperties expected, LinkProperties actual) {
|
|
||||||
assertEquals(expected, actual);
|
|
||||||
|
|
||||||
// Equality on stacked links is not tested as they should not be passed to processes using
|
|
||||||
// LinkPropertiesParcelable.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user