Revert "Verify the access to the mdnsd socket is blocked from Android U"
This reverts commit 7cdfc9099f.
Reason for revert: b/269587343
Change-Id: I8e0fbc7148b14d0df60ecd51cfd83f93986594d1
This commit is contained in:
parent
7cdfc9099f
commit
655ef33946
3 changed files with 15 additions and 106 deletions
22
TEST_MAPPING
22
TEST_MAPPING
|
|
@ -57,17 +57,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CtsNetTestCasesMaxTargetSdk33",
|
||||
"options": [
|
||||
{
|
||||
"exclude-annotation": "com.android.testutils.SkipPresubmit"
|
||||
},
|
||||
{
|
||||
"exclude-annotation": "androidx.test.filters.RequiresDevice"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "bpf_existence_test"
|
||||
},
|
||||
|
|
@ -154,17 +143,6 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CtsNetTestCasesMaxTargetSdk33[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]",
|
||||
"options": [
|
||||
{
|
||||
"exclude-annotation": "com.android.testutils.SkipPresubmit"
|
||||
},
|
||||
{
|
||||
"exclude-annotation": "androidx.test.filters.RequiresDevice"
|
||||
}
|
||||
]
|
||||
},
|
||||
// Test with APK modules only, in cases where APEX is not supported, or the other modules
|
||||
// were simply not updated
|
||||
{
|
||||
|
|
|
|||
|
|
@ -114,39 +114,34 @@ android_test {
|
|||
],
|
||||
}
|
||||
|
||||
java_defaults {
|
||||
name: "CtsNetTestCasesMaxTargetSdkDefaults",
|
||||
android_test {
|
||||
name: "CtsNetTestCasesMaxTargetSdk31", // Must match CtsNetTestCasesMaxTargetSdk31 annotation.
|
||||
defaults: [
|
||||
"CtsNetTestCasesDefaults",
|
||||
"CtsNetTestCasesApiStableDefaults",
|
||||
],
|
||||
target_sdk_version: "31",
|
||||
package_name: "android.net.cts.maxtargetsdk31", // CTS package names must be unique.
|
||||
instrumentation_target_package: "android.net.cts.maxtargetsdk31",
|
||||
test_suites: [
|
||||
"cts",
|
||||
"general-tests",
|
||||
"mts-tethering",
|
||||
"mts-networking",
|
||||
],
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "CtsNetTestCasesMaxTargetSdk33", // Must match CtsNetTestCasesMaxTargetSdk33 annotation.
|
||||
defaults: ["CtsNetTestCasesMaxTargetSdkDefaults"],
|
||||
target_sdk_version: "33",
|
||||
package_name: "android.net.cts.maxtargetsdk33",
|
||||
instrumentation_target_package: "android.net.cts.maxtargetsdk33",
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "CtsNetTestCasesMaxTargetSdk31", // Must match CtsNetTestCasesMaxTargetSdk31 annotation.
|
||||
defaults: ["CtsNetTestCasesMaxTargetSdkDefaults"],
|
||||
target_sdk_version: "31",
|
||||
package_name: "android.net.cts.maxtargetsdk31", // CTS package names must be unique.
|
||||
instrumentation_target_package: "android.net.cts.maxtargetsdk31",
|
||||
}
|
||||
|
||||
android_test {
|
||||
name: "CtsNetTestCasesMaxTargetSdk30", // Must match CtsNetTestCasesMaxTargetSdk30 annotation.
|
||||
defaults: ["CtsNetTestCasesMaxTargetSdkDefaults"],
|
||||
defaults: [
|
||||
"CtsNetTestCasesDefaults",
|
||||
"CtsNetTestCasesApiStableDefaults",
|
||||
],
|
||||
target_sdk_version: "30",
|
||||
package_name: "android.net.cts.maxtargetsdk30", // CTS package names must be unique.
|
||||
instrumentation_target_package: "android.net.cts.maxtargetsdk30",
|
||||
test_suites: [
|
||||
"cts",
|
||||
"general-tests",
|
||||
"mts-networking",
|
||||
],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ import android.app.compat.CompatChanges
|
|||
import android.net.ConnectivityManager
|
||||
import android.net.ConnectivityManager.NetworkCallback
|
||||
import android.net.LinkProperties
|
||||
import android.net.LocalSocket
|
||||
import android.net.LocalSocketAddress
|
||||
import android.net.Network
|
||||
import android.net.NetworkAgentConfig
|
||||
import android.net.NetworkCapabilities
|
||||
|
|
@ -65,7 +63,6 @@ import android.platform.test.annotations.AppModeFull
|
|||
import android.util.Log
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import com.android.compatibility.common.util.PollingCheck
|
||||
import com.android.net.module.util.ArrayTrackRecord
|
||||
import com.android.net.module.util.TrackRecord
|
||||
import com.android.networkstack.apishim.NsdShimImpl
|
||||
|
|
@ -75,12 +72,10 @@ import com.android.testutils.DevSdkIgnoreRule
|
|||
import com.android.testutils.TestableNetworkAgent
|
||||
import com.android.testutils.TestableNetworkCallback
|
||||
import com.android.testutils.filters.CtsNetTestCasesMaxTargetSdk30
|
||||
import com.android.testutils.filters.CtsNetTestCasesMaxTargetSdk33
|
||||
import com.android.testutils.runAsShell
|
||||
import com.android.testutils.tryTest
|
||||
import com.android.testutils.waitForIdle
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.net.ServerSocket
|
||||
import java.nio.charset.StandardCharsets
|
||||
import java.util.Random
|
||||
|
|
@ -768,65 +763,6 @@ class NsdManagerTest {
|
|||
}
|
||||
}
|
||||
|
||||
private fun checkConnectSocketToMdnsd(shouldFail: Boolean) {
|
||||
val discoveryRecord = NsdDiscoveryRecord()
|
||||
val localSocket = LocalSocket()
|
||||
tryTest {
|
||||
// Discover any service from NsdManager to enforce NsdService to start the mdnsd.
|
||||
nsdManager.discoverServices(serviceType, NsdManager.PROTOCOL_DNS_SD, discoveryRecord)
|
||||
discoveryRecord.expectCallback<DiscoveryStarted>()
|
||||
|
||||
// Checks the /dev/socket/mdnsd is created.
|
||||
val socket = File("/dev/socket/mdnsd")
|
||||
val doesSocketExist = PollingCheck.waitFor(
|
||||
TIMEOUT_MS,
|
||||
{
|
||||
socket.exists()
|
||||
},
|
||||
{ isSocketExist ->
|
||||
isSocketExist
|
||||
},
|
||||
)
|
||||
|
||||
// If the socket is not created, then no need to check the access.
|
||||
if (doesSocketExist) {
|
||||
// Create a LocalSocket and try to connect to mdnsd.
|
||||
assertFalse("LocalSocket is connected.", localSocket.isConnected)
|
||||
val address = LocalSocketAddress("mdnsd", LocalSocketAddress.Namespace.RESERVED)
|
||||
if (shouldFail) {
|
||||
assertFailsWith<IOException>("Expect fail but socket connected") {
|
||||
localSocket.connect(address)
|
||||
}
|
||||
} else {
|
||||
localSocket.connect(address)
|
||||
assertTrue("LocalSocket is not connected.", localSocket.isConnected)
|
||||
}
|
||||
}
|
||||
} cleanup {
|
||||
localSocket.close()
|
||||
nsdManager.stopServiceDiscovery(discoveryRecord)
|
||||
discoveryRecord.expectCallback<DiscoveryStopped>()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting from Android U, the access to the /dev/socket/mdnsd is blocked by the
|
||||
* sepolicy(b/265364111).
|
||||
*/
|
||||
@DevSdkIgnoreRule.IgnoreUpTo(Build.VERSION_CODES.TIRAMISU)
|
||||
@Test
|
||||
fun testCannotConnectSocketToMdnsd() {
|
||||
val targetSdkVersion = context.packageManager
|
||||
.getTargetSdkVersion(context.applicationInfo.packageName)
|
||||
assumeTrue(targetSdkVersion > Build.VERSION_CODES.TIRAMISU)
|
||||
checkConnectSocketToMdnsd(shouldFail = true)
|
||||
}
|
||||
|
||||
@Test @CtsNetTestCasesMaxTargetSdk33("mdnsd socket is accessible up to target SDK 33")
|
||||
fun testCanConnectSocketToMdnsd() {
|
||||
checkConnectSocketToMdnsd(shouldFail = false)
|
||||
}
|
||||
|
||||
@Test @CtsNetTestCasesMaxTargetSdk30("Socket is started with the service up to target SDK 30")
|
||||
fun testManagerCreatesLegacySocket() {
|
||||
nsdManager // Ensure the lazy-init member is initialized, so NsdManager is created
|
||||
|
|
|
|||
Loading…
Reference in a new issue