Commit Graph

3778 Commits

Author SHA1 Message Date
Paul Hu
0ce97e66c6 Merge "Address aosp/1740740 leftover comments" am: 1975a57e83 am: 1e594fa4db
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1775928

Change-Id: Ia63b7b3720e73378ccb509116ce5366913392526
2021-07-26 10:21:28 +00:00
Paul Hu
1975a57e83 Merge "Address aosp/1740740 leftover comments" 2021-07-26 09:49:27 +00:00
TreeHugger Robot
26848924ea Merge "Change the url in testDownloadWithDownloadManagerDisallowed" into sc-dev 2021-07-26 09:04:54 +00:00
Paul Hu
deaebe4818 Merge "Rename PREFERENCE_PRIORITY_* to PREFERENCE_ORDER_*" am: 0e3b1e0b57 am: 02c83293d6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764732

Change-Id: I59b79a72ae8237997eae4b23b1a91e2cb40674a8
2021-07-26 08:35:49 +00:00
Paul Hu
0e3b1e0b57 Merge "Rename PREFERENCE_PRIORITY_* to PREFERENCE_ORDER_*" 2021-07-26 08:12:42 +00:00
paulhu
fa2f7171af Address aosp/1740740 leftover comments
- Use SystemClock.sleep instead.
- Shorten the waiting time.

Bug: 185149952
Test: atest ConnectivityManagerTest#testUidsAllowedOnRestrictedNetworks
Change-Id: I82221a61bdddf6dc8147b3a29c873ca6c8b05e93
2021-07-23 15:20:06 +08:00
Luke Huang
227f003cbe Merge "Modify Nsd{Service,Manager}Test to conform to its change" into sc-dev am: 3c20df39d0
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15320525

Change-Id: Ifd8002745d97881414c29faa05820328e4833ae6
2021-07-22 03:26:43 +00:00
Luke Huang
3c20df39d0 Merge "Modify Nsd{Service,Manager}Test to conform to its change" into sc-dev 2021-07-22 03:00:35 +00:00
Paul Hu
92c911da01 Change the url in testDownloadWithDownloadManagerDisallowed
In China, "https://www.google.com" will redirect to url
"http://www.google.cn" but cleartext traffic is default disabled
for an app. So the testDownloadWithDownloadManagerDisallowed
would failed by cleartext traffic is not permitted. Thus, change
the url in the test which is reachable in China.

Bug: 192978910
Test: atest HostsideVpnTests#testDownloadWithDownloadManagerDisallowed
Original-Change: https://android-review.googlesource.com/1771008
Merged-In: I992c3240f0e133f5b00468cbe85d1545bcf786b0
Change-Id: I992c3240f0e133f5b00468cbe85d1545bcf786b0
2021-07-21 10:17:38 +00:00
Luke Huang
952a55c62d Modify Nsd{Service,Manager}Test to conform to its change
Test: atest NsdManagerTest NsdServiceTest
Bug: 191844585
Change-Id: I3cf658498bef5755dcb01127a94fff913b6e6298
Ignore-AOSP-First: To avoid the side effect caused by automerger.
2021-07-21 08:02:26 +00:00
Paul Hu
be402a2c9d Merge "Change the url in testDownloadWithDownloadManagerDisallowed" am: 42cbf4ebab am: ca4a4a1b86
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1771008

Change-Id: I8544d24607cdab4d2e786d3a3c5646909a0e34f5
2021-07-21 07:29:01 +00:00
Aaron Huang
9a2f096870 Move battery unplug command to the beginning of the test
The test failed because the test generated traffic
before the unplug command really done.

The unplug command will eventually have onBattery changed
to true. If the traffic is generated before onBattery changed
to true, then the cellular stats won't be updated. And then,
when BatteryStatsService schedules a sync task to update the
stats which will get no delta because the stats on cellular
has already added to mLastModemNetworkStats. Thus, the test
will finally get failed.

Currently, the battery unplug command is executed after connecting
to cellular network and making sure wifi is disconnected which may
trigger battery stats service schedules sync tasks. If there are
too many tasks need to run, then change onBattery to true would
be later. Thus, move the unplug command to the beginning of the
test and add "dumpsys batterystats --write" which will wait for the
worker to finish the task before continuing. Thus, it can make sure
the batterystats are synced.

Also, the stats will be reset when the devices are unplugging after
the battery was last full or the level is 100, or have gone through
a significant charge. So, enable no-auto-reset to avoid the stats
getting reset during the test.

Bug: 192808200
Test: atest CtsNetTestCases:BatteryStatsManagerTest
Original-Change: https://android-review.googlesource.com/1769295
Merged-In: I08b38d9955c8cbb2d680e268c29368a4c0a7d144
Change-Id: I08b38d9955c8cbb2d680e268c29368a4c0a7d144
2021-07-21 07:25:55 +00:00
Paul Hu
42cbf4ebab Merge "Change the url in testDownloadWithDownloadManagerDisallowed" 2021-07-21 06:59:15 +00:00
Aaron Huang
0d80b279fe Merge "Move battery unplug command to the beginning of the test" am: 7691152162 am: ef23d08eed
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1769295

Change-Id: Ib85a821e6391b6b984d852ca79f2443f418de9c5
2021-07-21 06:44:14 +00:00
Junyu Lai
d92c090c61 Temporarily disable the test since prebuilt module is not updated am: c42a54f2a7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15328937

Change-Id: I46fb4cad43fee89a6d4453c84db867cfc6374493
2021-07-21 03:04:50 +00:00
Aaron Huang
a3debae1eb Move battery unplug command to the beginning of the test
The test failed because the test generated traffic
before the unplug command really done.

The unplug command will eventually have onBattery changed
to true. If the traffic is generated before onBattery changed
to true, then the cellular stats won't be updated. And then,
when BatteryStatsService schedules a sync task to update the
stats which will get no delta because the stats on cellular
has already added to mLastModemNetworkStats. Thus, the test
will finally get failed.

Currently, the battery unplug command is executed after connecting
to cellular network and making sure wifi is disconnected which may
trigger battery stats service schedules sync tasks. If there are
too many tasks need to run, then change onBattery to true would
be later. Thus, move the unplug command to the beginning of the
test and add "dumpsys batterystats --write" which will wait for the
worker to finish the task before continuing. Thus, it can make sure
the batterystats are synced.

Also, the stats will be reset when the devices are unplugging after
the battery was last full or the level is 100, or have gone through
a significant charge. So, enable no-auto-reset to avoid the stats
getting reset during the test.

Bug: 192808200
Test: atest CtsNetTestCases:BatteryStatsManagerTest
Change-Id: I08b38d9955c8cbb2d680e268c29368a4c0a7d144
2021-07-21 02:14:03 +08:00
paulhu
971c5fc0f8 Change the url in testDownloadWithDownloadManagerDisallowed
In China, "https://www.google.com" will redirect to url
"http://www.google.cn" but cleartext traffic is default disabled
for an app. So the testDownloadWithDownloadManagerDisallowed
would failed by cleartext traffic is not permitted. Thus, change
the url in the test which is reachable in China.

Bug: 192978910
Test: atest HostsideVpnTests#testDownloadWithDownloadManagerDisallowed
Change-Id: I992c3240f0e133f5b00468cbe85d1545bcf786b0
2021-07-20 17:44:26 +08:00
Junyu Lai
c42a54f2a7 Temporarily disable the test since prebuilt module is not updated
This CL is subject to be reverted in a few days when the prebuilt
Connectivity module is updated.

Ignore-AOSP-First: This is for sc-dev and its downstreams only
Test: android.net.NetworkProviderTest
Bug: 189074532
Change-Id: I512552400960668c0ba91a8d997d1e2747209538
2021-07-20 05:58:08 +00:00
Junyu Lai
135f50679f Consider NetworkOffer is unneeded if it cannot satisfy the request
Currently, to prevent from network connect-teardown-loops that
caused by inaccurate reports, e.g. the provider always provides
a better network than the offer, the NetworkOffer is considered
needed if its provider is currently serving the request. This
is because there is no accurate way to know whether the offer is
corresponding to the network that is currently serving the
request.

However, if the offer cannot even satisfies the request, consider
the offer is needed does not make any sense. Since it can
never be the one that currently serving the request, nor be
the one that might beat current satisfier.

Test: android.net.NetworkProviderTest
Bug: 189074532
Original-Change: https://android-review.googlesource.com/1731452
Merged-In: Ie3ea59f980c3767782b8e6b03e401c02f664f9bd
Change-Id: Ie3ea59f980c3767782b8e6b03e401c02f664f9bd
2021-07-20 05:43:44 +00:00
Chiachang Wang
795d0c3574 Merge "Specify which callback is unexpected in tests" am: 5251171b75 am: 12a042be77
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1769289

Change-Id: I48948a8f04a2053cd24f153e1322df00fcedbf64
2021-07-20 01:49:11 +00:00
Chiachang Wang
c79dce9599 Merge "Deflake test to ensure system default network as expected" am: 575fa2f103 am: 250cf2af8a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764308

Change-Id: I34d1a75250faed18b734c68d9a0326ac46c645b4
2021-07-20 01:49:05 +00:00
Chiachang Wang
5251171b75 Merge "Specify which callback is unexpected in tests" 2021-07-20 01:20:16 +00:00
Chiachang Wang
575fa2f103 Merge "Deflake test to ensure system default network as expected" 2021-07-20 01:20:07 +00:00
Treehugger Robot
19eaa44e9f Merge "Fix a flake with mocking." am: 527f040944 am: ec050a37ab
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762391

Change-Id: Ie146448d14695a88688a37e5993504d527de9404
2021-07-19 12:51:20 +00:00
Treehugger Robot
527f040944 Merge "Fix a flake with mocking." 2021-07-19 12:16:18 +00:00
Chiachang Wang
6c80c3806d Specify which callback is unexpected in tests
Tests may be flaky due to the usage for assertNoCallback().
The method expects no any callback received. Based on the usage,
tests expect to not to receive certain callback, such as
onAvailable(). The network may update its linkproperties during
the test and trigger onLinkPropertiesChanged(). These callbacks
are ignorable in the tests. They should not fail the tests.

Replace the assertNoCallback to new assertNoCallbackThat with
callback type specified to deflake tests.

Bug: 192239030
Test: atest android.net.cts.ConnectivityManagerTest\
      --iterations 20
Change-Id: I1643c1ff15215c07e174dbcb664cfac2a38d5840
2021-07-19 18:41:53 +08:00
Chiachang Wang
ac059de6ad Deflake test to ensure system default network as expected
CtsNetUtils.toggleWifi() expects to receive a CONNECTIVITY_ACTION
broadcast after disconnecting from wifi if wifi is enabled.
The wifi may be connected but not validated since wifi just
turns back to connected from the previous test. In this case,
the system default netwok will not be wifi, so there is no
CONNECTIVITY_ACTION broadcast after disconnecting wifi. It
should ensure the wifi is system default network first before
proceeding with other verifications.

Bug: 192213759
Test: atest CtsNetTestCases --iterations 20
Change-Id: I82f0634883362e35b88854aae28e61b75a3cd7cc
2021-07-19 18:38:31 +08:00
Remi NGUYEN VAN
0e526cd506 Merge "Wait for next network in waitForAvailable" am: e9f65535e0 am: f38d076a83
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760698

Change-Id: Iafeca4e8049214af7871da406c2e2ddfe1c18df8
2021-07-19 10:25:11 +00:00
Remi NGUYEN VAN
800eff01d0 Merge changes from topic "sdk_int_cp"
* changes:
  Fix testSocketKeepaliveLimitTelephony on R
  Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity
2021-07-19 09:47:21 +00:00
Remi NGUYEN VAN
e9f65535e0 Merge "Wait for next network in waitForAvailable" 2021-07-19 09:47:12 +00:00
Remi NGUYEN VAN
354f5cf7d0 Merge "Skip BatteryStatsManagerTest on Q" am: e2067816e9 am: 4bcefe111a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764310

Change-Id: I4168b127b63517c80aebbf270ecd0ec0b2f122cb
2021-07-19 09:39:21 +00:00
Remi NGUYEN VAN
e2067816e9 Merge "Skip BatteryStatsManagerTest on Q" 2021-07-19 09:11:54 +00:00
Treehugger Robot
fa45b598d5 Merge "No-op cleanup" am: 21592b0d93 am: 866b9c4480
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1769285

Change-Id: Ib19a5d93e0b4e2f305a80ccf8841a36a5e7bda74
2021-07-16 16:38:19 +00:00
Chalard Jean
6d8f2fbf99 No-op cleanup
Test: atest ConnectivityServiceTest
Change-Id: Ic07c94785d97bd654ffce960e8bc2652c2dbc3d6
2021-07-16 12:02:22 +09:00
Remi NGUYEN VAN
c595c6461c Merge "Fix jarjar-related failures in coverage tests" am: e9f7f1e3d4 am: c6bf1e19a4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764731

Change-Id: If9fb707bf6e80b8937a41eb6306b2e2e0589a626
2021-07-15 09:28:55 +00:00
Remi NGUYEN VAN
1e79e9322b Merge "Use TRANSPORT_USB from the SDK" am: ca688d62d3 am: 048ef34b88
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1764734

Change-Id: I7ff0480df0d7997ea68422d1fe315fa94c5a0556
2021-07-15 09:02:04 +00:00
paulhu
48291863d7 Rename PREFERENCE_PRIORITY_* to PREFERENCE_ORDER_*
Follow up aosp/1719390, change PREFERENCE_PRIORITY_* to
PREFERENCE_ORDER_*.

Bug: 171872461
Test: atest FrameworksNetTests
Change-Id: Ic96ac7bc3dba74a2020014fb83e1cb302520888c
2021-07-15 14:22:41 +08:00
Remi NGUYEN VAN
e9f7f1e3d4 Merge "Fix jarjar-related failures in coverage tests" 2021-07-15 05:19:18 +00:00
Remi NGUYEN VAN
732584bcb8 Use TRANSPORT_USB from the SDK
Stop using the stopgap TRANSPORT_USB from NetworkCapabilitiesUtil, which
is being removed.

Bug: 184158327
Test: atest NetworkCapabilitiesTest
Change-Id: I6bbb35d39ff67d6f53b389689dc9f1067e64f962
2021-07-14 16:35:11 +09:00
lucaslin
eadb0add66 Ignore checking TRANSPORT_USB when Android version is older than S
There is a new transport type - TRANSPORT_USB(8) in Android S,
so when the test tries to add this new transport type in older
Android version, it cannot pass the transport type validation and
make test fail.

(clean cherry-pick of change in downstream branch history)
Original change ID before project move:
I38816173b04ea198d99f64f45e9271ac2641e4ac

Bug: 184158327
Test: run CtsNetTestCasesLatestSdk on Android R & Q
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ib0368241771d287c09c0e4463f91122533f85a27
2021-07-14 16:28:58 +09:00
Remi NGUYEN VAN
ed8efa75b4 Fix jarjar-related failures in coverage tests
Instead of jarjaring the whole com.android.internal.util package, apply
the jarjar rules per-class. Jarjaring the whole package causes problems
in tests, as for example ConnectivityServiceTest depends on Vpn that
uses other internal utils as hidden API, and these should not be
jarjared.

Also avoid jarjaring INetdUnsolicitedEventListener which is used by
NetdEventListenerServiceTest, and ensure KeepalivePacketDataUtilTest
expects the right package name in toString.

Generally the problems appear because ConnectivityCoverageTests also
includes tests for classes that are not part of the connectivity module,
and use hidden APIs that refer to classes that should not be jarjared.
Some of the tests could be excluded from the coverage suite instead, but
keeping them is helpful for future modularization efforts.

Test: Build service-connectivity, dexdump classes and verify jarjared
      atest ConnectivityCoverageTests
Change-Id: Id6b7e6833d49fa03d9442d7c1c3e4dc16fb48dfc
2021-07-14 15:22:56 +09:00
Remi NGUYEN VAN
4ba3adc4e5 Skip BatteryStatsManagerTest on Q
BatteryStatsManager did not exist on Q, so it cannot and should not be
tested there.

Bug: 193586822
Test: atest CtsNetTestCasesLatestSdk on Q
Change-Id: Ia9bef7c3438c25e1a4cb403b27cb0084bbd4f824
2021-07-14 12:06:51 +09:00
Remi NGUYEN VAN
30311abb87 Wait for next network in waitForAvailable
Tests using CtsNetUtils.TestNetworkCallback would generally assume that
waitForAvailable would return a non-null Network if onAvailable was
called after it was registered. However this is not true if a network
was available, then lost before waitForAvailable is called. This
can typically happen if wifi was disconnected just before calling
ensureWifiConnected (so wifi is being toggled).

In case onUnavailable was called, always wait for the next onAvailable
callback, so that waitForAvailable always waits for a network to be
available. So:

Old behavior:
 1) registerNetworkCallback called
 2) onAvailable called
 3) onLost called
 4) waitForAvailable called -> returns null immediately
 5) onAvailable called -> unused

New behavior:
 1) registerNetworkCallback called
 2) onAvailable called
 3) onLost called
 4) waitForAvailable called -> blocks
 5) onAvailable called -> waitForAvailable returns the network

Bug: 190913510
Test: atest CtsNetTestCases
Change-Id: I6bde82ad787371ecffd6caa950b52d90a29ab20b
2021-07-14 10:08:45 +09:00
Remi NGUYEN VAN
b240e2a86e Jarjar all classes in service-connectivity
This ensures classes are used from the service-connectivity jar, instead
of using classes from the system_server bootclasspath when there is a
name conflict.
Any developer adding a future class should do so in a subpackage of
com.android.connectivity (such as com.android.connectivity.server).
Otherwise, jarjar rules need to be added manually until b/180995093 is
fixed.

Also update current jarjar rules so that classes are jarjared to
com.android.connectivity.[original name], making it easier to find the
original source. This is consistent with the wifi module.

Bug: 193086215
Test: atest CtsNetTestCases
      dexdump on service-connectivity.jar shows no classes outside of
      com.android.connectivity and com.android.server
Original-Change: https://android-review.googlesource.com/1759589
Merged-In: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
Change-Id: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
2021-07-13 04:42:07 +00:00
Remi NGUYEN VAN
bfb22a0a0a Merge "Jarjar all classes in service-connectivity" am: 23c627b090 am: 793a4424d7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1759589

Change-Id: I7a55b08af6efb311af1c5385b63a450e9c343fd7
2021-07-12 23:53:14 +00:00
Remi NGUYEN VAN
23c627b090 Merge "Jarjar all classes in service-connectivity" 2021-07-12 23:29:25 +00:00
Remi NGUYEN VAN
0755183fae Jarjar all classes in service-connectivity
This ensures classes are used from the service-connectivity jar, instead
of using classes from the system_server bootclasspath when there is a
name conflict.
Any developer adding a future class should do so in a subpackage of
com.android.connectivity (such as com.android.connectivity.server).
Otherwise, jarjar rules need to be added manually until b/180995093 is
fixed.

Also update current jarjar rules so that classes are jarjared to
com.android.connectivity.[original name], making it easier to find the
original source. This is consistent with the wifi module.

Bug: 193086215
Test: atest CtsNetTestCases
      dexdump on service-connectivity.jar shows no classes outside of
      com.android.connectivity and com.android.server
Change-Id: I2aadeca32751267b74d4fd2fd93bb3e8c62e46c0
2021-07-12 19:33:33 +09:00
Chalard Jean
6519c179bd Fix a flake with mocking.
The hypothesis here is that some other thread is using
the mock between the call to when() and the call to
.thenReturn() a few lines above the failure. It's not
clear this is really the reason, but using this syntax
is safer anyway, so whether it fixes the issue or not
this is a good change.

Test: m FrameworksNetTests
Change-Id: I501d2ec8e794c67a53d7c84e290e4cc63481472d
2021-07-12 15:30:21 +09:00
Remi NGUYEN VAN
92b099b4e7 Merge "Remove hidden ArrayUtils usage in test" am: 946da61e70 am: 3c5a0f7de9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760689

Change-Id: I9a96b7cbef135a86d13171cd5b1edfc69b68c2e0
2021-07-12 02:50:20 +00:00
Remi NGUYEN VAN
946da61e70 Merge "Remove hidden ArrayUtils usage in test" 2021-07-12 02:21:12 +00:00