Support for Venue URL and friendly name from Network agent

Extend CaptivePortalData with a member to hold the venue friendly
name. If CaptivePortalData is initialized by both the network
agent and Capport, merge the two objects to include the venue
friendly name and prioritize the venue URL from the network
agent.

Bug: 162783305
Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest
Test: End-to-end test
Change-Id: I4fdf356be42237c5b6c0ae5bacfd3cec4726861b
This commit is contained in:
Hai Shalom
2021-01-11 18:45:34 -08:00
parent 090cbf27ab
commit e58bdc6fd0
5 changed files with 246 additions and 18 deletions

View File

@@ -41,13 +41,14 @@ class CaptivePortalDataTest {
.setBytesRemaining(456L)
.setExpiryTime(789L)
.setCaptive(true)
.setVenueFriendlyName("venue friendly name")
.build()
private fun makeBuilder() = CaptivePortalData.Builder(data)
@Test
fun testParcelUnparcel() {
assertParcelSane(data, fieldCount = 7)
assertParcelSane(data, fieldCount = 8)
assertParcelingIsLossless(makeBuilder().setUserPortalUrl(null).build())
assertParcelingIsLossless(makeBuilder().setVenueInfoUrl(null).build())
@@ -66,6 +67,8 @@ class CaptivePortalDataTest {
assertNotEqualsAfterChange { it.setBytesRemaining(789L) }
assertNotEqualsAfterChange { it.setExpiryTime(12L) }
assertNotEqualsAfterChange { it.setCaptive(false) }
assertNotEqualsAfterChange { it.setVenueFriendlyName("another friendly name") }
assertNotEqualsAfterChange { it.setVenueFriendlyName(null) }
}
@Test
@@ -108,6 +111,11 @@ class CaptivePortalDataTest {
assertFalse(makeBuilder().setCaptive(false).build().isCaptive)
}
@Test
fun testVenueFriendlyName() {
assertEquals("venue friendly name", data.venueFriendlyName)
}
private fun CaptivePortalData.mutate(mutator: (CaptivePortalData.Builder) -> Unit) =
CaptivePortalData.Builder(this).apply { mutator(this) }.build()