The SparseArray.indexOfValue() uses == to compare values,
MulticastRoutingCoordinator uses SparseArray with String type values,
and the indexOfValue function would sometimes return -1 when looking for
a value in the SparseArray.
Added a helper function getIndexForValue in CollectionUtils to get index
by comparing values with equals, and used this function in MulticastRoutingCoordinator.
Updated
MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc
test case to use copies of interface names when updating the multicast
configs, so the test would fail without this fix.
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.CollectionUtilsTest#testGetIndexForValue
atest android.net.connectivity.com.android.server.connectivity.MulticastRoutingCoordinatorServiceTest#testMulticastRouting_applyConfigNone_removesMfc
Change-Id: I862242d6be01b8552cdd6af6c9691948a9f0bfe0
testReadWriteProgram is annotated with IgnoreUpTo(U), but because the
class does not use the rule, that has no effect.
Fix that by adding the rule.
Note that DevSdkIgnoreRunner only affects running the whole class
(having IgnoreUpTo at the class level), not annotated individual tests.
Test: atest
Bug: 333208995
Change-Id: I56b9c0775c3f39bb0f133705e57a41717a7d777b
standard:comment-wrapping does not allow annotating function argument
literals inline (since block comments must not be surrounded by code).
So the following annotations are not allowed in ktlint:
foo(1 /* bar */)
Unfortunately, there are not good alternatives. Named arguments can only
be used to call Kotlin functions and are not a general solution.
Instead, disable this linter rule for the entire file.
This also adds a suppress annotation further down in the file, since
ktlint does not like the extra space required to make the comments line
up horizontally...
Test: repo upload --dry-run
Change-Id: I62fdb0347965ee3fc43783eb07af47e95af882a5
APF is supposed to run when the screen is off. This change turns the
screen off as part of setUp() and turns it back on in tearDown() (since
apparently CTS is run with the screen on as some tests rely on it).
turnScreenOn() / turnScreenOff() also acquire / release a partial
wakelock to prevent the CPU from suspending during the test.
Test: atest ApfIntegrationTest
Change-Id: I31f04f4d39284be387006fdd9d0a7c0e27feddb5
Technically, this does not matter. If the network goes away before
resume is called, then resume will fail. But the network is going away
anyway... In any case, tearing down the test in opposite order of setup
is good practice.
Test: TH
Change-Id: I21f95499dbddb6003ac12c51a67a7638058e20e3
Validates that reading and writing APF memory behaves as expected across
the entire range of usable memory.
Before V, APF integration is broken in many different ways, so this test
only runs on V+ for now. A separate test will be added for pre-V
devices.
Test: atest ApfIntegrationTest
Change-Id: I3002c03b51bedd23a8cfb2513f5ae01a200445a4
setUp() / tearDown() run on devices that might not support APF in which
case they should not cause a test failure.
Tests will be appropriately guarded by checking the APF capabilities.
Test: TH
Change-Id: I8689f96ecac0a21dfb4ab8786fec11c01f30d1c2
NsdServiceInfo may contain an interface index if it was obtained from a
previous discovery callback which found a service on an interface that
does not belong to any Network.
In that case, subsequent resolve or registerServiceInfoCallback queries
using that NsdServiceInfo should only be done on the matching interface.
Apps may otherwise receive replies from other networks, with different
interface addresses.
As a simple fix, still request sockets from all interfaces in that case,
but only create the MdnsServiceTypeClients on matching sockets.
The sockets are created / cleaned up based on the lifecycle of the
requests, which does not change.
Fixes: 332262554
Test: atest
Change-Id: I2bbb498d4a0d37725f019a4cf5e367fef76fa0e8
Checking that the network was successfully restricted before starting
the activities in ConnOnActivityStartTest. This avoids races between uid
state changes and device state changes in NPMS code that lead to
unpredictable UnknownHostException flakes in the first iteration.
Moving the java cache clearing to happen immediately before the check,
so no side effect from different code can impact the DNS query.
Increasing the socket-timeout to mitigate socket timeout failures.
Changing the default test URL to generate a 204 to avoid any extraneous
errors that may arise in doing other I/O, and switching to the canonical
connectivity check URL on the android.com domain.
Enabling support for passing down a custom url to use for testing
network connectivity using the runner options. This will enable easily
switching between different URLs for debugging when required.
Using a dedicated data class to encapsulate information to be returned
from test app to the instrumentation app.
This makes the logic more resilient, readable and maintainable.
Test: atest CtsHostsideNetworkTests:HostsideConnOnActivityStartTest --\
--test-arg com.android.compatibility.common.tradefed.testtype.JarHostTest:\
set-option:com.android.cts.net.HostsideConnOnActivityStartTest:\
custom-url:"https\://www.example.com"
Bug: 330406935
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:04c638ee3a5bab7895817ebfc0d3f6a69b1ee26d)
Merged-In: I139408fc0a9ffa21d7bd2f3f249d45a7b25243b4
Change-Id: I139408fc0a9ffa21d7bd2f3f249d45a7b25243b4
Suprabh Shuklaauthored and Android Build Cherrypicker Workercommited 2024-04-02 05:51:41 +00:00
* changes:
Grant prohr temporary ownership of ApfIntegrationTests
Pause APF filter before starting test
Enable new ApfFilter experiment in CTS test
Move retrieving APF capabilities into helper function
Maciej Żenczykowskiauthored and Gerrit Code Reviewcommited 2024-04-02 03:41:31 +00:00
Developers often forget to unregister requests in tests, and cleanup
code also makes tests more verbose.
Add a rule that unregisters callbacks automatically when after each test
method.
Replace current usage of connectToCell with this rule, as well as
network callback usage in CaptivePortalTest (which is one example that
did not unregister its callback).
Test: atest
Change-Id: Ie3b9c5cf529004b7b3af04bc13a7e69acfbbaa18
After reconnectWifiIfSupported is called, it is possible that
ConnectivityManager#getAllNetworks does not return the Network, as this
is mixing network callbacks and synchronous calls which is racy (as per
ConnectivityManager javadoc).
Ensure that networks that are reconnected in the test, wifi and
cellular, are obtained through network callbacks through CtsNetUtils.
Other networks are still obtained through the synchronous call, as they
should not change during the test, and there would be no non-racy way to
obtain them otherwise anyway as they are not guaranteed to be connected.
Bug: 328331492
Test: atest
Change-Id: I5a511c87c64fde0276aecd6ff6599815fa08e437
The BACKGROUND firewall chain has been recently added. We want to
be able to turn it off in case of contingencies with a device-config
flag flip.
The flag is assumed to be boot-stable and its value is read at boot.
When the flag is off, we ignore any operation on this firewall chain.
Additionally, this chain is always considered disabled on versions
upto UPSIDE_DOWN_CAKE.
Note: All firewall chains are in disabled state at boot by default.
Test: atest FrameworksNetTests
Test: Manually, using adb shell device_config commands.
Bug: 331484830
Change-Id: I9ccc483e02e27a584da6714931466a9f2ec95ca9
With satellite transport supported at device and satellite
network to appear under type mobile, considers cellular or
satellite, or combination of both interfaces under mobile interfaces.
Note: getUidStatsForTransport(TRANSPORT_SATELLITE) is not supported,
considering the same interface name could be used by cellular as well,
supporting this might lead to double counting problem.
Bug: 329003473
Test: atest FrameworksNetTests
Change-Id: I85465cedcc5550fa0555dc36b3be364ac90aade1
add tests for ServiceManagerWrapper.java to coverage native NDK APIs
used in this module.
Bug: 330417869
Change-Id: Ibeb277fe1fea361b4e0fca58f3291d7fa925ab7f
- Handle onRoleHoldersChanged is not triggered even if the user has a
default app setup and gets deleted scenario.
- Adding ACTION_USER_REMOVED intent filter, to monitor for User
removal. This to used to update satellite fallback uid list
and to keep allowed uid range updated at multi layer request
of track default and satellite transport with Internet
restricted capability
Bug: 326373613
Test: atest FrameworksNetTests
Change-Id: I1f30cd129309486bccbc61802ed600c142077411
In order to make fast progress on developing some initial APF
integration tests, grant prohr@ temporary ownership. Changes will be
reviewed with lorenzo@ out-of-band before release.
Test: n/a
Change-Id: Ic4b586aeb95902717d8e0e57f063cd7302f9b70c
APF adb commands are not implemented in LegacyApfFilter. Enable the
experiment flag for all tests.
Test: atest ApfIntegrationTest
Change-Id: I468ef54498a6f780dff22d25119732b42b404199
Retrieving the capabilities will be required for every test, so move it
to a helper function.
Also includes two more minor improvements:
- Use runShellCommandOrThrow() instead of runShellCommand() so we
correctly fail the test if the shell command returns an error.
- Use truth for all assertions because it creates better error messages.
See truth.dev for more details.
Test: builds && TH
Change-Id: I61b6263eac9bf70eae4e1841baae9e3fa8ca4d6d
* changes:
Rename wifiIfaceName to ifname
Remove unnecessary null check
Unregister network callback in tearDown
Don't run test in instant app mode
Revert^2 "Introduce initial CTS test for APF functionality"
Treehugger Robotauthored and Gerrit Code Reviewcommited 2024-03-28 19:29:50 +00:00
Renames wifiIfaceName to ifname and capabilities to caps to make
the shell command fit on one line.
Test: TH
Change-Id: I253a0f6d99c8ce869795958503db4db4008455b6
wifiIfaceName is guaranteed to not be null when this null check is
executed, as otherwise eventuallyExpect<LinkPropertiesChanged>() has
failed or threw an assertion error a couple of lines above.
Test: TH
Change-Id: Ibc566fae7cf153dcc2976e4d6d3b208e8fa3448c
Representing networkCallback as a non-null lateinit var and using
property isInitialized seems more appropriate than making
networkCallback nullable. Making networkCallback nullable would require
null checks / safe calls for every use. However, from the tests'
perspective networkCallback cannot be null; the only concern is
tearDown() which has to deal with early exits from setUp() due to
assumption / assertion failures and therefore partially initialized
state.
networkCallback can only be initialized when requestNetwork() is called
as unregisterNetworkCallback() will throw an exception if the callback
was never registered.
Test: TH
Change-Id: I2aad7d781e6955b29d505e670181209c33db7680