Update IpSecManager to use InetAddress and prefixLen

LinkAddress constructors are currently @hide; this change updates
IpSecManager to use InetAddress and prefixLen, and then construct a
LinkAddress internally. LinkAddress is used over the binder interface to
IpSecService to ensure validity.

Bug: 77528639
Test: CTS, Java unit tests ran on walleye
Change-Id: I19e124adef6d9f4992d8293db3190bcf74c95848
This commit is contained in:
Benedict Wong
2018-04-03 20:30:54 -07:00
committed by Nathan Harold
parent 65ef843176
commit d39837f7e2

View File

@@ -684,14 +684,15 @@ public final class IpSecManager {
* tunneled traffic. * tunneled traffic.
* *
* @param address the local address for traffic inside the tunnel * @param address the local address for traffic inside the tunnel
* @param prefixLen length of the InetAddress prefix
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS)
public void addAddress(@NonNull LinkAddress address) throws IOException { public void addAddress(@NonNull InetAddress address, int prefixLen) throws IOException {
try { try {
mService.addAddressToTunnelInterface( mService.addAddressToTunnelInterface(
mResourceId, address, mOpPackageName); mResourceId, new LinkAddress(address, prefixLen), mOpPackageName);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }
@@ -703,14 +704,15 @@ public final class IpSecManager {
* <p>Remove an address which was previously added to the IpSecTunnelInterface * <p>Remove an address which was previously added to the IpSecTunnelInterface
* *
* @param address to be removed * @param address to be removed
* @param prefixLen length of the InetAddress prefix
* @hide * @hide
*/ */
@SystemApi @SystemApi
@RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS) @RequiresPermission(android.Manifest.permission.MANAGE_IPSEC_TUNNELS)
public void removeAddress(@NonNull LinkAddress address) throws IOException { public void removeAddress(@NonNull InetAddress address, int prefixLen) throws IOException {
try { try {
mService.removeAddressFromTunnelInterface( mService.removeAddressFromTunnelInterface(
mResourceId, address, mOpPackageName); mResourceId, new LinkAddress(address, prefixLen), mOpPackageName);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
} }