Support for Terms & Conditions notification

- Added API to add T&C URL in the CaptivePortalData class, and to
indicate if the source is from Passpoint.
- Added source indication for the Venue URL API.
- Allow the connectivity service to send a new T&C acceptance
notification.
- Updated the merge method to prefer the Capport data over the
network agent data, if the source is not authenticated (not from
Passpoint).
- Propagate the Venue Friendly name to the captive portal activity
to be used instead of SSID, when available.

Bug: 162785447
Test: End-to-end test
Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest
Test: atest NetworkNotificationManagerTest
Change-Id: I4e77c3b6c01941b03c46ad32da70c77e0fecac64
This commit is contained in:
Hai Shalom
2021-02-04 19:34:06 -08:00
parent f3163aafec
commit 7c6ab4004a
6 changed files with 260 additions and 58 deletions

View File

@@ -54,12 +54,26 @@ class CaptivePortalDataTest {
}
.build()
private val dataFromPasspoint = CaptivePortalData.Builder()
.setUserPortalUrl(Uri.parse("https://tc.example.com/passpoint"),
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
.setVenueInfoUrl(Uri.parse("https://venue.example.com/passpoint"),
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT)
.setCaptive(true)
.apply {
if (SdkLevel.isAtLeastS()) {
setVenueFriendlyName("venue friendly name")
}
}
.build()
private fun makeBuilder() = CaptivePortalData.Builder(data)
@Test
fun testParcelUnparcel() {
val fieldCount = if (SdkLevel.isAtLeastS()) 8 else 7
val fieldCount = if (SdkLevel.isAtLeastS()) 10 else 7
assertParcelSane(data, fieldCount)
assertParcelSane(dataFromPasspoint, fieldCount)
assertParcelingIsLossless(makeBuilder().setUserPortalUrl(null).build())
assertParcelingIsLossless(makeBuilder().setVenueInfoUrl(null).build())
@@ -83,6 +97,27 @@ class CaptivePortalDataTest {
assertNotEqualsAfterChange { it.setVenueFriendlyName("another friendly name") }
assertNotEqualsAfterChange { it.setVenueFriendlyName(null) }
}
assertEquals(dataFromPasspoint, CaptivePortalData.Builder(dataFromPasspoint).build())
assertNotEqualsAfterChange { it.setUserPortalUrl(
Uri.parse("https://tc.example.com/passpoint")) }
assertNotEqualsAfterChange { it.setUserPortalUrl(
Uri.parse("https://tc.example.com/passpoint"),
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
assertNotEqualsAfterChange { it.setUserPortalUrl(
Uri.parse("https://tc.example.com/other"),
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT) }
assertNotEqualsAfterChange { it.setUserPortalUrl(
Uri.parse("https://tc.example.com/passpoint"),
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
assertNotEqualsAfterChange { it.setVenueInfoUrl(
Uri.parse("https://venue.example.com/passpoint")) }
assertNotEqualsAfterChange { it.setVenueInfoUrl(
Uri.parse("https://venue.example.com/other"),
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT) }
assertNotEqualsAfterChange { it.setVenueInfoUrl(
Uri.parse("https://venue.example.com/passpoint"),
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
}
@Test
@@ -130,6 +165,22 @@ class CaptivePortalDataTest {
assertEquals("venue friendly name", data.venueFriendlyName)
}
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
fun testGetVenueInfoUrlSource() {
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER,
data.venueInfoUrlSource)
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT,
dataFromPasspoint.venueInfoUrlSource)
}
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
fun testGetUserPortalUrlSource() {
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER,
data.userPortalUrlSource)
assertEquals(CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT,
dataFromPasspoint.userPortalUrlSource)
}
private fun CaptivePortalData.mutate(mutator: (CaptivePortalData.Builder) -> Unit) =
CaptivePortalData.Builder(this).apply { mutator(this) }.build()