Refactor requestNetworkAndGenerateTraffic by using synchronized methods
This is a refactoring of the test to adopt synchronized methods.
This is needed for the follow-up changes to get attributes of
the network prior to generating the network traffic.
This change includes:
1. Use synchronized methods in AutoReleaseNetworkCallbackRule for
better managing request/release networks and also improves
readability.
2. Decouple the steps of requesting network, set attributes and
generating network traffic.
3. Clearer fail messages since the test can directly throw exceptions
to reflect the failures of a specific procedure.
4. Remove the global timeout, which makes the test more likely
to be flaky when individual steps take longer to complete.
5. Use capabilities in the callback instead of synchronous calls to
fetch attributes.
6. Use @RestoreDefaultNetwork annotation to enforce default network
restoration.
Test: atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest \
--rerun-until-failure 30
Bug: 368624224
Change-Id: I3effa3c032afb345f1c0c4b73b51397d18970a19
1 file changed