Commit Graph

36905 Commits

Author SHA1 Message Date
Chalard Jean
4da146bd2f Fix a flake in ConnectivityDiagnostics
Bug: none
Test: ConnectivityServiceTest
Change-Id: I9242226be976e7c346addcbaf7e2b0154a3829f7
2021-08-16 16:05:06 +09:00
Chiachang Wang
93bda73970 Merge "Retry and ignore ConcurrentModificationException" 2021-07-27 09:02:56 +00:00
Chiachang Wang
eb25674b5c Retry and ignore ConcurrentModificationException
The flaky callstack shows that it hits the exception in the
initialization of HashSet. The mNetworkRequests is accessed in
the ConnectivityService handler thread except dump(). The
ConcurrentModificationException should not happen in the other
flow. Thus, retry to get the current requests when the dump()
hits the ConcurrentModificationException to prevent flaky test.

Bug: 188373832
Test: atest ConnectivityServiceTest#testDumpDoesNotCrash\
      --iteration 100
Change-Id: I9625919faf947c9488764b92093ed8105271c927
2021-07-27 15:13:52 +08:00
Chalard Jean
51176d0a67 Merge "Fix a possible system server crash" 2021-07-27 04:37:43 +00:00
Chalard Jean
5bcc838f4e Fix a possible system server crash
The scenario is as follows : an app registers a network callback,
then unregisters it and dies immediately after. In this scenario,
the system server will receive a notification of the binder death
and enqueue a call to handleRemoveNetworkRequest. If the callback
unregister message has been process first, this call would result
in unlinkToDeath being called twice on the same Binder, crashing.
This patch fixes the problem by using handleReleaseNetworkRequest
instead of Remove, which looks up the NRI in a map on the handler
thread before calling Remove, returning without doing anything if
the NRI has already been removed.

Test: ConnectivityServiceTest
Test: New test for this
Bug: 194394697
Change-Id: I82a28c37450146838410bf5a059aac295a985fca
2021-07-27 04:37:29 +00:00
Chalard Jean
c486f0248b Merge "Remove a useless comment" 2021-07-27 02:59:41 +00:00
Chalard Jean
f126170e98 Remove a useless comment
b/145383354 is obsolete and this works as is (or we'd have found
out by now). Also min SDK version is set in the bp file and
would be overridden anyway.

Test: comment-only change
Change-Id: I6ad3263557ef67aa642672863eed82a312c2ab40
2021-07-27 02:59:11 +00:00
Chiachang Wang
9ad8acd76e Merge "Remove DISCONNECTING check from handleReportNetworkConnectivity" 2021-07-26 10:58:58 +00:00
Paul Hu
1975a57e83 Merge "Address aosp/1740740 leftover comments" 2021-07-26 09:49:27 +00:00
Treehugger Robot
94ef708b7d Merge "Add TetheringPrivilegedTests to postsubmit" 2021-07-26 08:50:07 +00:00
Paul Hu
0e3b1e0b57 Merge "Rename PREFERENCE_PRIORITY_* to PREFERENCE_ORDER_*" 2021-07-26 08:12:42 +00:00
markchien
911cf8fecd Add TetheringPrivilegedTests to postsubmit
Also ignore DadProxyTest before S because it is only enabled from S.

To using ignore test rule, replace AndroidJunit with DevSdkIgnoreRunner.
It is fine because the we don't use the test UI (e.g. running test in UI
thread).

Test: atest TetheringPrivilegedTests
Change-Id: I701ee877520f78ded2394adbae1f4d9dd612d700
2021-07-26 02:17:19 +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
Treehugger Robot
02d7eb2abe Merge "Use appId for looking up allowed on restricted networks uids list" 2021-07-22 01:48:45 +00:00
paulhu
25094906ff Use appId for looking up allowed on restricted networks uids list
aosp/1770606 change uid to appId when filling allowed on
restricted networks uids list. So add UserHandle.getAppId() to
ensure that uses appId for looking up the list.

Bug: 192116643
Test: atest FrameworksNetTests
Change-Id: I04fe3a77464d4cb02e7d53026f8f9a10bd0829e1
2021-07-21 17:45:38 +08:00
Paul Hu
42cbf4ebab Merge "Change the url in testDownloadWithDownloadManagerDisallowed" 2021-07-21 06:59:15 +00:00
Mark Chien
7d36391ba4 Merge "Replace throwErrnoException with JNIHelp jniThrowException" 2021-07-21 06:30:23 +00:00
Aaron Huang
7691152162 Merge "Move battery unplug command to the beginning of the test" 2021-07-21 06:18:08 +00:00
Chiachang Wang
58644b1f70 Remove DISCONNECTING check from handleReportNetworkConnectivity
ConnectivityService doesn't use it, and the NetworkAgent API
never set it. This case does not happen in pratice, so remove
the check.

Bug: 192611346
Test: atest FrameworksNetTests
Change-Id: I1f114c9b65050527378ee73bc86e4cda8868bca9
2021-07-21 10:28:54 +08: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
Treehugger Robot
1004c23b35 Merge changes I6e6b40b0,I6a0d93e0,Ie26f6e52
* changes:
  Revert "[CTT-5] Stop update TCP conntrack entry timeout"
  Revert "[CTT-6] Update TCP conntrack entry timeout while adding rules"
  Revert "[CTT-7] Delete the rules while half-closing tcp state entered"
2021-07-20 10:49:18 +00:00
markchien
083606292b Replace throwErrnoException with JNIHelp jniThrowException
Rather than adding throwErrnoException local function, using standard
jniThrowException in JNIHelp.h.

Also improve the readability:
1. Use throwIOException for
    jniThrowExceptionFmt(env, "java/io/IOException", ...);
2. Use throwSoecktException for
    jniThrowExceptionFmt(env, "java/net/SocketException", ...);
then the code can fit to one line.

Test: atest TetheringPrivilegedTests (ErrnoException is
test in BpfMapTest)
Change-Id: I396771e2c68e319f510d7a4ea5f263d18d7fad9d
2021-07-20 10:15:01 +00: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
Remi NGUYEN VAN
8b3213f38e Merge "Bump Tethering apex version code for S" 2021-07-20 09:00:45 +00:00
Remi NGUYEN VAN
5bd49caf78 Merge "Bump Tethering apex version code for R" 2021-07-20 09:00:37 +00:00
Nucca Chen
199e86dcb3 Revert "[CTT-5] Stop update TCP conntrack entry timeout"
This reverts commit a5c742be69.

Reason for revert:
Stop releasing this commit because it needs more test coverage.

Bug: 190783768
Bug: 192804833
Change-Id: I6e6b40b0f6207ed197d01bfabb616f1afa31fb70
Test: atest TetheringCoverageTests
2021-07-20 08:52:38 +00:00
Nucca Chen
254ba6b235 Revert "[CTT-6] Update TCP conntrack entry timeout while adding rules"
This reverts commit 299a81157c.

Reason for revert:
Stop releasing this commit because it needs more test coverage.

Bug: 190783768
Bug: 192804833
Change-Id: I6a0d93e04814ae73e1ec7d6fd4df19e1d2787207
Test: atest TetheringCoverageTests
2021-07-20 08:50:49 +00:00
Nucca Chen
7abf514272 Revert "[CTT-7] Delete the rules while half-closing tcp state entered"
This reverts commit 118b5b578a.

Reason for revert: 
Stop releasing this commit because it needs more test coverage.

Bug: 190783768
Bug: 192804833
Change-Id: Ie26f6e528999da42cfa66a5f6c1f187ad2276ae1
Test: atest TetheringCoverageTests
2021-07-20 08:47:13 +00:00
Treehugger Robot
913dba8be3 Merge "Correct log" 2021-07-20 08:20:37 +00:00
Chiachang Wang
525b07d28a Correct log
Log should print the taken parameter instead of the value of
current variable

Test: m
Bug: 192149168
Change-Id: Ia3b9e607fe8b661a7faea3b46b9697fa85016440
2021-07-20 13:16:57 +08: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
1e4d4001f4 Merge "Temporarily change uid to appId" 2021-07-19 13:47:18 +00:00
Treehugger Robot
527f040944 Merge "Fix a flake with mocking." 2021-07-19 12:16:18 +00:00
paulhu
0433dd20b7 Temporarily change uid to appId
Due to b/192431153, PermissionMonitor only apply permission to
app id which is listed in settings. Thus, temporarily change uid
to appId.

Bug: 192116643
Test: atest ConnectivityManagerTest#testUidsAllowedOnRestricted\
      Networks with system & secondary user.
Change-Id: Iadec66344d88bd80170cd5441270b768cdbe0917
2021-07-19 18:51:03 +08: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
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
e2067816e9 Merge "Skip BatteryStatsManagerTest on Q" 2021-07-19 09:11:54 +00:00
Remi NGUYEN VAN
1d6e7d5117 Bump Tethering apex version code for S
The version code in the manifest is only used for development
builds, as release builds dynamically replace it.

319999900 is appropriate as it indicates that the module is compatible
with S and earlier, and allows installing development versions on any
S build, which use 31xxxxxxx versions. It will also still allow installing
production T modules (32xxxxxxx) on a development S build. This is
convenient for local testing.

The same convention is also used for other modules including
NetworkStack.

Bug: 193853555
Test: m com.google.android.tethering, check version code

Change-Id: Ib8905a641780bed490a38327facee4a76e7770a3
2021-07-19 18:09:20 +09:00
Remi NGUYEN VAN
13b8b17b11 Bump Tethering apex version code for R
The version code in the manifest is only used for development
builds, as release builds dynamically replace it.

Tethering should have been using 309999900 during S development. That
version was used in many downstream branches, so make it consistent so
it can be bumped for S in all branches.

Bug: 193853555
Test: m com.google.android.tethering, check version code
Merged-In: Ia3d5f2201ce67308df8e2689f6c99e28049a4877
Merged-In: I0d4bd06e79adedbf582d2fed551d9f1bde521fd1
Merged-In: Ie3a058b904cb2e3704c3a0725c8f720f81bb235e
Change-Id: I644f0d801efb491be45c3dc29fa1058476282772
2021-07-19 18:07:23 +09:00
Treehugger Robot
21592b0d93 Merge "No-op cleanup" 2021-07-16 16:08:05 +00:00
Remi NGUYEN VAN
0909afc08a Merge "Add ConnectivityCoverageTests to presubmit" 2021-07-16 06:20:00 +00:00
Remi NGUYEN VAN
7d4ab94bc6 Merge "Move ConnectivityCoverageTests to mainline-presubmit" 2021-07-16 06:19:10 +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
48c68886ee Add ConnectivityCoverageTests to presubmit
The tests are now consistently green in postsubmit.

Bug: 187935317
Change-Id: Ib04e5de8e57bd9cca0c9244f12a9668f97ba46f9
Test: Need TH to test
2021-07-16 01:36:16 +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
5a1f2f7108 Move ConnectivityCoverageTests to mainline-presubmit
Recent runs have been passing in mainline-postsubmit.

Non-mainline presubmit will be added later, after it has been passing
consistently for some time.

Bug: 187935317
Change-Id: I20e3d6f11458f00ff75f32419b964c97635995b1
Test: TH needs to test
2021-07-15 05:25:58 +00:00
Remi NGUYEN VAN
e9f7f1e3d4 Merge "Fix jarjar-related failures in coverage tests" 2021-07-15 05:19:18 +00:00