Add session ID to VpnTransportInfo

- This will be visible only to apps with the NETWORK_SETTINGS
  permissions (signature), and will be redacted for all other callers.
- This string is expected to be the same as set by
  VpnService#setSession, and in general, VpnConfig.session. But it
  will be a general API that Vpn.java can call when setting the
  VpnTransportInfo.
- This string cannot be updated once the VPN NetworkAgent is connected.

Bug: 171872481
Ignore-AOSP-First: needed to prevent automerger race breaking build
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest NetworkAgentTest
Change-Id: I883035262465238c35c5a931d89707f3e84feef8
This commit is contained in:
lifr
2021-03-25 01:06:45 +08:00
committed by Lorenzo Colitti
parent bee627b39c
commit ac6614fa05

View File

@@ -547,6 +547,7 @@ class NetworkAgentTest {
@Test @Test
@IgnoreUpTo(Build.VERSION_CODES.R) @IgnoreUpTo(Build.VERSION_CODES.R)
fun testSetUnderlyingNetworksAndVpnSpecifier() { fun testSetUnderlyingNetworksAndVpnSpecifier() {
val mySessionId = "MySession12345"
val request = NetworkRequest.Builder() val request = NetworkRequest.Builder()
.addTransportType(TRANSPORT_TEST) .addTransportType(TRANSPORT_TEST)
.addTransportType(TRANSPORT_VPN) .addTransportType(TRANSPORT_VPN)
@@ -560,7 +561,7 @@ class NetworkAgentTest {
addTransportType(TRANSPORT_TEST) addTransportType(TRANSPORT_TEST)
addTransportType(TRANSPORT_VPN) addTransportType(TRANSPORT_VPN)
removeCapability(NET_CAPABILITY_NOT_VPN) removeCapability(NET_CAPABILITY_NOT_VPN)
setTransportInfo(VpnTransportInfo(VpnManager.TYPE_VPN_SERVICE)) setTransportInfo(VpnTransportInfo(VpnManager.TYPE_VPN_SERVICE, mySessionId))
if (SdkLevel.isAtLeastS()) { if (SdkLevel.isAtLeastS()) {
addCapability(NET_CAPABILITY_NOT_VCN_MANAGED) addCapability(NET_CAPABILITY_NOT_VCN_MANAGED)
} }
@@ -580,6 +581,8 @@ class NetworkAgentTest {
assertNotNull(vpnNc) assertNotNull(vpnNc)
assertEquals(VpnManager.TYPE_VPN_SERVICE, assertEquals(VpnManager.TYPE_VPN_SERVICE,
(vpnNc.transportInfo as VpnTransportInfo).type) (vpnNc.transportInfo as VpnTransportInfo).type)
// TODO: b/183938194 please fix the issue and enable following check.
// assertEquals(mySessionId, (vpnNc.transportInfo as VpnTransportInfo).sessionId)
val testAndVpn = intArrayOf(TRANSPORT_TEST, TRANSPORT_VPN) val testAndVpn = intArrayOf(TRANSPORT_TEST, TRANSPORT_VPN)
assertTrue(hasAllTransports(vpnNc, testAndVpn)) assertTrue(hasAllTransports(vpnNc, testAndVpn))