Revert "Implement opt-in to custom tabs in captive portals."
This reverts commit f2cb190a73.
Reason for revert: This is the integration test CL, it will break due to ag/34545776 reverted.
Change-Id: I5fc66fab409989479078dfcffea7793b9d6dd749
This commit is contained in:
parent
f2cb190a73
commit
5177b0b6b4
3 changed files with 26 additions and 132 deletions
|
|
@ -50,9 +50,7 @@ public final class CaptivePortalData implements Parcelable {
|
|||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(prefix = {"CAPTIVE_PORTAL_DATA_SOURCE_"}, value = {
|
||||
CAPTIVE_PORTAL_DATA_SOURCE_OTHER,
|
||||
CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT,
|
||||
CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN
|
||||
})
|
||||
CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT})
|
||||
public @interface CaptivePortalDataSource {}
|
||||
|
||||
/**
|
||||
|
|
@ -65,17 +63,6 @@ public final class CaptivePortalData implements Parcelable {
|
|||
*/
|
||||
public static final int CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT = 1;
|
||||
|
||||
// TODO : Remove this, replace with an explicit boolean for opting in. Better yet, when the
|
||||
// feature is publicly rolled out, remove without a replacement. Because the network stack and
|
||||
// connectivity modules are not yet merged, adding anything in this class would require
|
||||
// public API, which would have to be maintained forever and would force very long time-to-
|
||||
// market timelines, so this is used instead.
|
||||
/**
|
||||
* Source of information : Capport, and capport opts in to custom tabs.
|
||||
* @hide
|
||||
*/
|
||||
public static final int CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN = 2;
|
||||
|
||||
private CaptivePortalData(long refreshTimeMillis, Uri userPortalUrl, Uri venueInfoUrl,
|
||||
boolean isSessionExtendable, long byteLimit, long expiryTimeMillis, boolean captive,
|
||||
CharSequence venueFriendlyName, int venueInfoUrlSource, int userPortalUrlSource) {
|
||||
|
|
|
|||
|
|
@ -57,35 +57,20 @@ class CaptivePortalDataTest {
|
|||
.apply {
|
||||
if (SdkLevel.isAtLeastS()) {
|
||||
setVenueFriendlyName("venue friendly name")
|
||||
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
|
||||
)
|
||||
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)
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
||||
private val optInData = CaptivePortalData.Builder().apply {
|
||||
setCaptive(true)
|
||||
if (SdkLevel.isAtLeastS()) {
|
||||
setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN
|
||||
)
|
||||
}
|
||||
}.build()
|
||||
|
||||
private fun makeBuilder() = CaptivePortalData.Builder(data)
|
||||
|
||||
@Test
|
||||
fun testParcelUnparcel() {
|
||||
assertParcelingIsLossless(data)
|
||||
assertParcelingIsLossless(dataFromPasspoint)
|
||||
if (SdkLevel.isAtLeastS()) assertParcelingIsLossless(optInData)
|
||||
|
||||
assertParcelingIsLossless(makeBuilder().setUserPortalUrl(null).build())
|
||||
assertParcelingIsLossless(makeBuilder().setVenueInfoUrl(null).build())
|
||||
|
|
@ -111,35 +96,24 @@ class CaptivePortalDataTest {
|
|||
|
||||
assertEquals(dataFromPasspoint, CaptivePortalData.Builder(dataFromPasspoint).build())
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/passpoint")
|
||||
) }
|
||||
Uri.parse("https://tc.example.com/passpoint")) }
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER
|
||||
) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
|
||||
assertNotEqualsAfterChange { it.setUserPortalUrl(
|
||||
Uri.parse("https://tc.example.com/other"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT
|
||||
) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_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/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN
|
||||
) }
|
||||
Uri.parse("https://tc.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
|
||||
assertNotEqualsAfterChange { it.setVenueInfoUrl(
|
||||
Uri.parse("https://venue.example.com/passpoint")
|
||||
) }
|
||||
Uri.parse("https://venue.example.com/passpoint")) }
|
||||
assertNotEqualsAfterChange { it.setVenueInfoUrl(
|
||||
Uri.parse("https://venue.example.com/other"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT
|
||||
) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT) }
|
||||
assertNotEqualsAfterChange { it.setVenueInfoUrl(
|
||||
Uri.parse("https://venue.example.com/passpoint"),
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER
|
||||
) }
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -190,32 +164,18 @@ class CaptivePortalDataTest {
|
|||
|
||||
@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
|
||||
)
|
||||
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
|
||||
)
|
||||
if (SdkLevel.isAtLeastS()) {
|
||||
assertEquals(
|
||||
CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN,
|
||||
optInData.userPortalUrlSource
|
||||
)
|
||||
}
|
||||
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) =
|
||||
|
|
@ -224,4 +184,4 @@ class CaptivePortalDataTest {
|
|||
private fun assertNotEqualsAfterChange(mutator: (CaptivePortalData.Builder) -> Unit) {
|
||||
assertNotEquals(data, data.mutate(mutator))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,10 +24,7 @@ import android.content.Context.BIND_AUTO_CREATE
|
|||
import android.content.Context.BIND_IMPORTANT
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
import android.net.CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN
|
||||
import android.net.CaptivePortalData.CAPTIVE_PORTAL_DATA_SOURCE_OTHER
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.IDnsResolver
|
||||
import android.net.INetd
|
||||
|
|
@ -239,7 +236,7 @@ class ConnectivityServiceIntegrationTest {
|
|||
}
|
||||
|
||||
private inner class TestConnectivityService(deps: Dependencies) : ConnectivityService(
|
||||
context,
|
||||
context,
|
||||
dnsResolver,
|
||||
log,
|
||||
netd,
|
||||
|
|
@ -256,7 +253,7 @@ class ConnectivityServiceIntegrationTest {
|
|||
override fun getBpfNetMaps(
|
||||
context: Context?,
|
||||
netd: INetd?,
|
||||
interfaceTracker: InterfaceTracker?
|
||||
interfaceTracker: InterfaceTracker?
|
||||
) = mock(BpfNetMaps::class.java)
|
||||
.also {
|
||||
doReturn(PERMISSION_INTERNET).`when`(it).getNetPermForUid(anyInt())
|
||||
|
|
@ -287,7 +284,7 @@ class ConnectivityServiceIntegrationTest {
|
|||
tm: TelephonyManager,
|
||||
requestRestrictedWifiEnabled: Boolean,
|
||||
listener: BiConsumer<Int, Int>,
|
||||
handler: Handler,
|
||||
handler: Handler
|
||||
): CarrierPrivilegeAuthenticator {
|
||||
return CarrierPrivilegeAuthenticator(
|
||||
context,
|
||||
|
|
@ -366,44 +363,8 @@ class ConnectivityServiceIntegrationTest {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getModuleVersion(): Long {
|
||||
val captivePortalActivity = Intent(ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN)
|
||||
.resolveActivity(context.packageManager)
|
||||
val captivePortalInfo = context.packageManager.getPackageInfo(
|
||||
captivePortalActivity.packageName,
|
||||
PackageManager.GET_ACTIVITIES
|
||||
)
|
||||
return captivePortalInfo.longVersionCode
|
||||
}
|
||||
|
||||
val OPT_IN = true
|
||||
var OPT_OUT = false
|
||||
|
||||
@Test
|
||||
fun testCapportApiWithoutOptInToCustomTabs() = testCapportApi(
|
||||
optInToCustomTabsString = null,
|
||||
expectedOptIn = OPT_OUT
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testCapportApiWithFullOptInToCustomTabs() = testCapportApi(
|
||||
optInToCustomTabsString = "true",
|
||||
expectedOptIn = OPT_IN
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testCapportApiWithHighVersionOptInToCustomTabs() = testCapportApi(
|
||||
optInToCustomTabsString = (getModuleVersion() + 10).toString(),
|
||||
expectedOptIn = OPT_OUT
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testCapportApiWithLowVersionOptInToCustomTabs() = testCapportApi(
|
||||
optInToCustomTabsString = (getModuleVersion() - 10).toString(),
|
||||
expectedOptIn = OPT_IN
|
||||
)
|
||||
|
||||
fun testCapportApi(optInToCustomTabsString: String?, expectedOptIn: Boolean) {
|
||||
fun testCapportApi() {
|
||||
val request = NetworkRequest.Builder()
|
||||
.clearCapabilities()
|
||||
.addCapability(NET_CAPABILITY_INTERNET)
|
||||
|
|
@ -412,17 +373,11 @@ class ConnectivityServiceIntegrationTest {
|
|||
val apiUrl = "https://capport.android.com"
|
||||
|
||||
cm.registerNetworkCallback(request, testCb)
|
||||
val optInString = if (optInToCustomTabsString != null) {
|
||||
"\"x-android-use-custom-tabs\": $optInToCustomTabsString,"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
nsInstrumentation.addHttpResponse(HttpResponse(
|
||||
apiUrl,
|
||||
"""
|
||||
|{
|
||||
| "captive": true,
|
||||
| $optInString
|
||||
| "user-portal-url": "https://login.capport.android.com",
|
||||
| "venue-info-url": "https://venueinfo.capport.android.com"
|
||||
|}
|
||||
|
|
@ -457,14 +412,6 @@ class ConnectivityServiceIntegrationTest {
|
|||
Uri.parse("https://venueinfo.capport.android.com"),
|
||||
capportData.venueInfoUrl
|
||||
)
|
||||
assertEquals(
|
||||
if (expectedOptIn == OPT_IN) {
|
||||
CAPTIVE_PORTAL_DATA_SOURCE_CAPPORT_WITH_CUSTOM_TABS_OPTIN
|
||||
} else {
|
||||
CAPTIVE_PORTAL_DATA_SOURCE_OTHER
|
||||
},
|
||||
capportData.userPortalUrlSource
|
||||
)
|
||||
|
||||
testCb.expectCaps(na, TEST_TIMEOUT_MS) {
|
||||
it.hasCapability(NET_CAPABILITY_CAPTIVE_PORTAL) &&
|
||||
|
|
|
|||
Loading…
Reference in a new issue