Commit Graph

266 Commits

Author SHA1 Message Date
Kweku Adams
66c5773f79 Ensure airplane mode is off.
If the device is put into airplane mode before the network tests run,
the tests fail. This ensures that airplane mode is off before the tests
run.

Bug: 150788500
Test: atest CtsHostsideNetworkTests
Change-Id: I7a84be751e5e9efb534d48c6d8ff457875ebe716
2020-05-15 10:09:41 -07:00
lucaslin
63203afe0e Refine NetworkCallbackTest
In R, to avoid data overages due to apps not detecting a
meteredness change, when a wifi network changes from unmetered
to metered the network will go down and will be replaced with a
new network. It will make NetworkCallbackTest fail because the
original design is getting the active network in setUp(). So once
the wifi reconnects, the network which is got in setUp() will be
meaningless and make the test fail due to network mismatches.
The new changes are:
1. Moving some initial pre-configurations into setUp().
2. Override the onCapabilitiesChanged() to check if network has
   changed to metered or not.
3. Add unregisterNetworkCallback() into iMyService.aidl so that
   NetworkCallbackTest can call it to unregister the network
   callback.
4. Enlarge the timeout of connecting network and receiving
   callback to prevent network cannot reconnect in time or
   callback cannot be received in a short time.

Bug: 153485744
Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideNetworkCallbackTests
Change-Id: I1aa0e107cf6797b06dee4a15896c63321d822156
2020-05-08 11:02:46 +08:00
Kweku Adams
627f2b69ef Merge "Test that idle apps get network when device charges." into rvc-dev 2020-05-07 01:25:28 +00:00
Hai Zhang
9c3108c681 Merge "Declare MANAGE_EXTERNAL_STORAGE for test apps." into rvc-dev 2020-05-04 23:33:47 +00:00
Kweku Adams
efb1857443 Test that idle apps get network when device charges.
This is a partial revert of the change that removed the parole
(Icd7b6eff8777f9b53a10eca521b73988f58f2d84).

Bug: 151802309
Test: atest --rerun-until-failure 10 com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Change-Id: I65f5ff20cdd342905e1afd1f4897017aa60682d3
2020-05-04 13:34:29 -07:00
Dominic Lemire
e4a9287bfe Fix error message in RestrictBackgroundNetworkTest
Fixed the error message when the expected number of broadcasts is exceeded.

Bug: 147139427
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I7e69dca81abdb29a9eb7d110266edbe483e17a01
Merged-In: I7e69dca81abdb29a9eb7d110266edbe483e17a01
2020-04-30 19:38:34 -07:00
Hai Zhang
59b9da9907 Declare MANAGE_EXTERNAL_STORAGE for test apps.
That has requested legacy external storage and targets R or
beyond. TestDevice automatically grants the app op during test app
installation but the permission declaration should still be there.

Also added some other missing app op permission declarations according
to test failure.

Fixes: 149765004
Test: Ensure the same set of tests pass with the following command:
Test: atest ExternalStorageHostTest StorageHostTest
Test: Ensure apps printed in the following command targets below R:
Test: find . -type f -exec grep -q 'android:requestLegacyExternalStorage' {} \; -not -exec grep -q 'MANAGE_EXTERNAL_STORAGE' {} \; -print
Test: presubmit
Exempt-From-Owner-Approval: This CL just adds a <uses-permission> line
                            across a number of test apps. Storage team
                            and most owners have approved this change.
Change-Id: I839a23b28b29118baae7a8c309f7bd4de698419b
2020-04-22 21:20:40 +00:00
Sudheer Shanka
643abc73d9 Ensure location is enabled before getting SSID.
When location is disabled, Wi-Fi scan results and SSID are not available
to apps.

Fixes: 153850762
Fixes: 153396893
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I05285811d7131e116d5e1d072137ed2cf9576d05
2020-04-14 21:31:40 +00:00
Sudheer Shanka
9eb1424bcf Merge "Dump debug logs after a test failure before running tearDown()s." into rvc-dev 2020-04-06 19:20:19 +00:00
Sudheer Shanka
1f4e465b5a Dump debug logs after a test failure before running tearDown()s.
Bug: 145420790
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I19516046f05bd4564c57542ae82a82a1cc362f48
2020-04-05 01:57:55 -07:00
Dan Shi
d4bff6cd28 Remove tests from vts suite
After vts-core is renamed to vts, the CTS tests won't be needed in vts
suite.

Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL removes all CTS tests in vts suite,
as vts is renamed to vts10. This CL won't change test logic or behavior.

Change-Id: Idc9e9cc1d1080ff689823671a736bbb78bd7a740
2020-04-01 13:30:00 -07:00
Dan Shi
67de87eed0 Add vts10 suite to existing vts tests
This is to prepare renaming vts to vts10.

Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL adds all tests in vts to a new
suite vts10. vts10 will be the new name of existing vts suite. This CL
won't change test logic or behavior.

Change-Id: Ia9af1fbddc66d3c94976a58c36d274425f1fe461
2020-03-23 09:34:13 -07:00
Sudheer Shanka
97da47d0dd Merge "Enable verbose logging for the test app." 2020-02-21 18:48:39 +00:00
Sudheer Shanka
bae482a772 Enable verbose logging for the test app.
Bug: 145420790
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I8ba31a365e66bd199f19de1ff77cdf01df89602b
2020-02-17 13:34:09 -08:00
Sudheer Shanka
05f62e1986 Dump usagestats of helper app as well.
Bug: 145420790
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Change-Id: I8dc78cc33900dcb6aa423cc5a7dc2b27d8d4c1ef
2020-02-16 22:34:15 -08:00
Sudheer Shanka
6291996513 Allow network policy test app to query info about the helper app.
Bug: 149569765
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Change-Id: Id01bb6b0ee6fd45d001c75a4dfc8328667c61554
2020-02-14 18:09:01 -08:00
Sudheer Shanka
9a1e3be614 Fix a regression in how required properties are collected.
+ Enable app standby mode before running the tests.

Fixes: 147459100
Fixes: 117169751
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Test: cts-tradefed run singleCommand cts-on-gsi --skip-device-info \
      --skip-preconditions -m CtsHostsideNetworkTests \
      -t com.android.cts.net.HostsideRestrictBackgroundNetworkTests

Change-Id: I782f8a06922622d28f9a9d5c9f2afa2b12f8aa80
2020-02-05 18:09:08 -08:00
Colin Cross
f7d2ff895e Fix Error Prone errors
Soong wasn't including android_app or android_test sources in the
javac-check target used for the Error Prone build, which allowed
some Error Prone errors to get in.  Fix them so Error Prone can be
re-enabled for these targets.

Fixes:
cts/hostsidetests/net/app/src/com/android/cts/net/hostside/RequiredPropertiesRule.java:61: error: [CollectionIncompatibleType] Argument '~requiredProperty.getValue()' should not be passed to this method; its type int is not compatible with its collection's type argument Property
cts/tests/location/location_fine/src/android/location/cts/fine/CriteriaTest.java:199: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.
cts/tests/location/location_fine/src/android/location/cts/fine/LocationManagerFineTest.java:948: error: [TryFailThrowable] Catching Throwable/Error masks failures from fail() or assert*() in the try block
cts/tests/location/location_fine/src/android/location/cts/fine/LocationTest.java:402: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.
cts/tests/tests/assist/src/android/assist/cts/AssistTestBase.java:613: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue
cts/tests/tests/assist/src/android/assist/cts/AssistTestBase.java:616: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue
cts/tests/tests/media/src/android/media/cts/AudioRecordTest.java:1661: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.
cts/tests/tests/media/src/android/media/cts/AudioRecordTest.java:1681: error: [JUnit4TestNotRun] This looks like a test method but is not run; please add @Test and @Ignore, or, if this is a helper method, reduce its visibility.

Bug: 146455923
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I48b1ccb61c807d0b41a165298ef5981258d6656e
2019-12-31 09:40:49 -08:00
Automerger Merge Worker
0fdd1ee38b Merge "Add a CTS test for private DNS on VPNs." into qt-dev am: 17311d9af6 am: fe44dd21ba am: 523cc30322 am: b29ba93dcd
Change-Id: I20a4d12beb846fa0d192e6426719c762ffb0c187
2019-12-13 02:27:54 +00:00
Automerger Merge Worker
b29ba93dcd Merge "Add a CTS test for private DNS on VPNs." into qt-dev am: 17311d9af6 am: fe44dd21ba am: 523cc30322
Change-Id: If38d0c7e8b878e76ff4a52fcdd441b002ce9ddf0
2019-12-13 01:41:48 +00:00
Lorenzo Colitti
3b160e2385 Add a CTS test for private DNS on VPNs.
Bug: 122652057
Test: atest com.android.cts.net.HostsideVpnTests passes with fix, fails without it
Change-Id: Ifa2710aed7e773a24786cc3e4912f126547dfe0b
2019-12-12 19:41:01 +09:00
Kweku Adams
1881bc644f Change network parole while charging tests.
The periodic parole window is the 10 minute window that occurs every
24 hours to let RARE apps run. Now that we have the quota system in
place, there's no need to have the periodic parole window. Alarms and
jobs will still be allowed to run when charging. Network will continue
to be restricted for RARE apps even when charging. JobScheduler requests
an exception for RARE jobs in quota, so they will still be able to run.
With this change, idle apps should still not get network when charging
unless JobScheduler requests it, so we have to update the tests.

Bug: 136184981
Test: atest AppStandbyControllerTests
Test: atest CtsAlarmManagerTestCases
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Test: atest com.android.server.AlarmManagerServiceTest
Test: atest com.android.server.AppStateTrackerTest
Test: atest com.android.server.job.controllers.QuotaControllerTest
Change-Id: Icd7b6eff8777f9b53a10eca521b73988f58f2d84
2019-10-14 11:37:43 -07:00
Jeffrey Vander Stoep
31e0d78ed5 Merge "getConnectionOwnerUid: add test for b/141603906" am: e8a8d9a26f am: ab361a6fbd am: 90190f2e14
am: 5a8999451e

Change-Id: I94d01773e64292a7e8ce7612fb2bd0dac686b860
2019-10-08 03:45:26 -07:00
Jeff Vander Stoep
c9068f1b87 getConnectionOwnerUid: add test for b/141603906
Test: on Marlin and Blueline run
    cts-tradefed run cts -m CtsHostsideNetworkTests \
    -t com.android.cts.net.HostsideVpnTests#testB141603906
Bug: 141603906
Change-Id: I759bc2295b2060e4575d61718c551d201a6455be
2019-10-08 10:41:45 +02:00
Sudheer Shanka
09ae6d2645 Pull service dumps to help debug test failures.
+ Convert tests to use Junit4
+ Add annotations to specify required conditions for the test to run.

Bug: 137859686
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Test: atest hostsidetests/net/src/com/android/cts/net/HostsideNetworkCallbackTests.java
Change-Id: I93317c201a0ea06732e29154ab7e140735381f59
2019-08-20 10:19:32 -07:00
Julien Desprez
7b48d84ed5 Merge "[Cherry pick] Mark module as "secondary_user" since it uncovered bug before" am: 9c9dde65ba
am: d30bab3710

Change-Id: I86f7186964eb9dd70cd7b442768095fc806afb7a
2019-06-25 01:00:59 -07:00
Julien Desprez
14fae15d0a [Cherry pick] Mark module as "secondary_user" since it uncovered bug before
This will allow running this module against a secondary
user in continuous infra to uncover bugs.

Test: run cts-unit-tests
Bug: 130892086
Change-Id: I063a0d29163567ec2cf97d2e4469e88e7203e852
Merged-In: Ic8af2e3e77e24db340b2894c2d36e3501962952c
2019-06-24 09:15:51 -07:00
Julien Desprez
bd43e6d4fb Mark module as "secondary_user" since it uncovered bug before
This will allow running this module against a secondary
user in continuous infra to uncover bugs.

Test: run cts-unit-tests
Bug: 130892086
Change-Id: Ic8af2e3e77e24db340b2894c2d36e3501962952c
2019-06-19 15:25:08 -07:00
Sudheer Shanka
9677c19c12 Merge "Skip battery saver related tests on unsupported devices." into qt-dev am: f8eb2722ff
am: bec485ec90

Change-Id: I4423117a8636ce63431873f4f5edf0fe2832f97e
2019-06-14 10:46:35 -07:00
Sudheer Shanka
b357138cb6 Merge "Skip battery saver related tests on unsupported devices." into qt-dev
am: f8eb2722ff

Change-Id: Ibc940cd7806bada010838ea09989fa1a1c05233b
2019-06-14 10:35:32 -07:00
Sudheer Shanka
802549c8de Skip battery saver related tests on unsupported devices.
Bug: 133761301
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Change-Id: Ifec84425febf38d732367fae6b43fa80c427c79f
2019-06-07 10:14:08 -07:00
Hui Yu
a6bb88ebc1 Merge "Make sure app_idle_constants is set during setup." into qt-dev
am: dc7e2bb71c

Change-Id: Id524c3206efbc09ecf422b837b92891c8baafde5
2019-05-03 09:34:37 -07:00
Kweku Adams
eb7b9bab13 Merge "Testing Data Saver changed broadcast on unsupported devices." into qt-dev
am: 42f325acb9

Change-Id: If94305b8d2a8b877af585f0c209538b2b2827a7a
2019-05-03 07:52:00 -07:00
Hui Yu
dc7e2bb71c Merge "Make sure app_idle_constants is set during setup." into qt-dev 2019-05-02 22:51:17 +00:00
Sasha Smundak
153173af0b Merge "Convert hostsidetests/net/**/Android.mk file to Android.bp" am: 9bca8f5c35
am: 69de989faf

Change-Id: I9a37e90afe4f6682187f9c5937cc552067ab9f7c
2019-04-30 10:36:46 -07:00
Sasha Smundak
b3af5c95b2 Convert hostsidetests/net/**/Android.mk file to Android.bp
See build/soong/README.md for more information.

Bug: 122332514
Test: atest CtsHostsideNetworkTests
(same failures as in baseline)
Change-Id: I5b6a22263331b19570b42f156d7ad5d59f8208b4
2019-04-29 13:18:42 -07:00
Kweku Adams
3a88dd4732 Testing Data Saver changed broadcast on unsupported devices.
Bug: 114131539
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Change-Id: I3e8f9297ca49ee86bd26bb3d7a094c38b6203118
2019-04-29 11:25:14 -07:00
Hui Yu
022058ec74 Make sure app_idle_constants is set during setup.
Set app_idle_constants in NetPolicyTestsPreparer is not always successful(suspect timing issue).
Set app_idle_constants in AbstractRestrictBackgroundNetworkTestCase again to make sure.

Bug: 115393390
Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests#testAppIdleMetered_whenCharging

Change-Id: I41148bc7eea0825537133f0471ceefeb5b05d763
2019-04-26 17:07:34 -07:00
Lorenzo Colitti
5abd1ff346 Add instant and ABI XML tags for hostside networking tests.
These are not multi-ABI because the behaviour does not depend on
the ABI of the app. Some of the APIs are ultimately backed by JNI
code in the system server, but that only depends on the system
server's ABI, not the app's.

Enable instant mode because these applications are subject to the
same network restrictions as other apps.

Fix: 123364589
Test: atest CtsHostsideNetworkTests
Test: cts-tradefed run commandAndExit cts --enable-parameterized-modules --module-parameter instant_app -m CtsHostsideNetworkTests
Change-Id: Ib3c4cd365ffe95889d51a236f035ea84516f0abd
(cherry picked from commit ad17ee9e92)
2019-04-26 12:52:28 -07:00
Varun Anand
5d3ac8f9e1 CTS tests related to VPN meteredness.
(cherry picked from commit d1008aa730)

Tests cover scenarios related to whether VPN has explicitly declared its
underlying networks plus whether it is an always metered VPN.

For each of these scenarios, we ensure VPN meteredness based on its
capabilities and ConnectivityManager#isActiveNetworkMetered matches.

Bug: 123727651
Test: atest HostsideVpnTests

Change-Id: I2dea70c1c432d05b1a22c945f1e3e17166e4132d
Merged-In: I3030e5468a55bbc32be2a753f098dcf7f0256af8
2019-04-15 07:55:58 -07:00
Varun Anand
7973b17dd7 Merge "CTS tests related to VPN meteredness." am: 1806a7da53
am: dd6406d69d

Change-Id: I87ddf706b507fc0c9f8004b130b555c3905d99b1
2019-04-15 07:11:29 -07:00
Varun Anand
1806a7da53 Merge "CTS tests related to VPN meteredness." 2019-04-15 13:45:57 +00:00
Lorenzo Colitti
72914e4469 Merge "Add instant and ABI XML tags for hostside networking tests." am: 75c73cda26
am: c40bdf2fce

Change-Id: I82ad420b23f4c332d0463e154c135e19081cba98
2019-04-12 05:44:24 -07:00
Varun Anand
d1008aa730 CTS tests related to VPN meteredness.
Tests cover scenarios related to whether VPN has explicitly declared its
underlying networks plus whether it is an always metered VPN.

For each of these scenarios, we ensure VPN meteredness based on its
capabilities and ConnectivityManager#isActiveNetworkMetered matches.

Bug: 123727651
Test: atest HostsideVpnTests
Change-Id: I3030e5468a55bbc32be2a753f098dcf7f0256af8
2019-04-11 14:32:21 -07:00
Lorenzo Colitti
ad17ee9e92 Add instant and ABI XML tags for hostside networking tests.
These are not multi-ABI because the behaviour does not depend on
the ABI of the app. Some of the APIs are ultimately backed by JNI
code in the system server, but that only depends on the system
server's ABI, not the app's.

Enable instant mode because these applications are subject to the
same network restrictions as other apps.

Fix: 123364589
Test: atest CtsHostsideNetworkTests
Test: cts-tradefed run commandAndExit cts --enable-parameterized-modules --module-parameter instant_app -m CtsHostsideNetworkTests
Change-Id: Ib3c4cd365ffe95889d51a236f035ea84516f0abd
2019-04-11 20:43:59 +09:00
Lorenzo Colitti
f0d0a9e352 Merge "Add test coverage for ICMP echo constants." am: 718025ed2c am: 0f6be092bb
am: b452497881

Change-Id: Ic0189e07e2745b721a307754a7bcc6574878ac32
2019-04-01 09:11:18 -07:00
Lorenzo Colitti
950e10572b Add test coverage for ICMP echo constants.
Bug: 129251251
Test: atest android.net.ipv6.cts.PingTest com.android.cts.net.HostsideVpnTests
Change-Id: Icca18e0870588ca250225ce79cf30dbd8c361e84
2019-03-30 02:11:46 +09:00
Junyu Lai
06db529877 Merge changes Ic19b3b64,I26ca370f am: c5ceda2354 am: f29182d403
am: 6188ebe70d

Change-Id: I7aa0abf2308ede2025bb8bfdf044fd37275f6afb
2019-03-24 19:30:34 -07:00
junyulai
27e1316c33 Add cts test cases for NetworkCallback.onBlockedStatusChanged
Bug: 118862340
Test: atest HostsideNetworkCallbackTests

Change-Id: Ic19b3b648a94adf4449393beb9b30ad7a7dc2283
2019-03-22 19:17:01 +08:00
junyulai
d05db41eb7 Export API of listening for network change events in app2
Currently, due to foreground app will never get blocked by
NetworkPolicyManagerService, so onBlockedStatusChanged cannot be
tested under cts net app.

Thus, listen for network change events in app2 allows subsequent
tests on NetworkCallbacks.

Bug: 118862340
Test: m -j cts
Change-Id: I26ca370fc6ae4dd3f32ce6cf448bae83f3fbfbcc
2019-03-22 10:19:38 +08:00