Throw IAE when Network's LinkProperties is null

Improve the setUnderlyingNetwork method by throwing IAE
when Network's LinkProperties is null. Also update the
API doc to give caller more guidance in using this API

Bug: 232309601
Test: UT: IpSecServiceParameterizedTest, IpSecServiceTest,
      IpSecServiceRefcountedResourceTest, IpSecManagerTest, VpnTest
Test: CTS: IpSecManagerTest, IpSecManagerTunnelTest, Ikev2VpnTest
Test: make doc-comment-check-docs
Change-Id: Idab4706b0db42ed2222fb48b168589ed005d2f2f
This commit is contained in:
Yan Yan
2022-05-16 17:13:45 -07:00
parent ae30d8c052
commit be3eb3d56a
3 changed files with 26 additions and 5 deletions

View File

@@ -1452,6 +1452,11 @@ public class IpSecService extends IIpSecService.Stub {
final ConnectivityManager connectivityManager =
mContext.getSystemService(ConnectivityManager.class);
final LinkProperties lp = connectivityManager.getLinkProperties(underlyingNetwork);
if (lp == null) {
throw new IllegalArgumentException(
"LinkProperties is null. The underlyingNetwork may not be functional");
}
if (tunnelInterfaceInfo.getInterfaceName().equals(lp.getInterfaceName())) {
throw new IllegalArgumentException(
"Underlying network cannot be the network being exposed by this tunnel");