Commit Graph

6241 Commits

Author SHA1 Message Date
lucaslin
a878f700d3 Fix flaky test - testPartialConnectivity
This timing issue is happened when test case already verified
NetworkMonitor#setAcceptPartialConnectivity() before
NetworkAgent send the CONNECTED state to ConnectivityService.
This test case expects that the
NetworkMonitor#setAcceptPartialConnectivity() will be invoked
when network state is CONNECTED in
ConnectivityService#updateNetworkInfo().

NetworkAgent communicates with ConnectivityService by
AsyncChannel. Before they connect to each other, the thread of
NetworkAgent is keeping idle, so waitForIdle cannot handle this
kind of case. Although they have connected to each other, but
they don't communicate with each other, waitForIdle() still
cannot handle this case. It means waitForIdle() can only handle
the case that NetworkAgent already connected to
ConnectivityService and NetworkAgent is communicating with
ConnectivityService. So, that's why waitForIdle() sometimes
doesn't work in this case, and the most simplest and right way
to fix this case is to wait the available callback then verify
the method.

Bug: 140306320
Test: atest FrameworksNetTests: \
      ConnectivityServiceTest#testPartialConnectivity \
      --generate-new-metrics 500

Change-Id: I64bfecbfe3c5776bd5c347a821f9127e79539c48
2019-09-05 11:39:20 +00:00
Treehugger Robot
ff69dc29d2 Merge "Mark 3 tests as flaky." 2019-09-02 18:44:24 +00:00
Guang Zhu
df1d1ebc2b Mark 3 tests as flaky.
Bug: 140306320
Bug: 140305589
Bug: 140305678
Test: apct/net/networking_framework_unit_test
Change-Id: I5a288d7d64b3e95e0025c2c1f4a64ffe85cc3cd6
2019-09-01 21:37:04 -07:00
Aurimas Liutikas
61789bab0c Merge "Add missing nullability annotations." 2019-08-30 18:30:39 +00:00
Paul Hu
09b6f14675 Merge "Fix flaky testTcpBufferReset" 2019-08-30 16:01:45 +00:00
paulhu
22e2195a8a Fix flaky testTcpBufferReset
If EVENT_NETWORK_INFO_CHANGED was handled after waitForIdle()
method done, this test will be failed due to
INetd#setTcpRWmemorySize() was not executed yet. Instead of
waiting for idle state, it's better to use NetworkCallback to
ensure events completely on ConnectivityService.

Bug: 140206578
Test: atest ConnectivityServiceTest#testTcpBufferReset\
      --generate-new-metrics 500

Change-Id: Iad77415db38038603881d9ebe0e37586b549a45c
2019-08-30 20:21:03 +08:00
junyulai
0c27ddf71b Fix LockdownVpnTracker deadlock when resetting legacy Always-On VPN
When resetting legacy Always-On VPN, the intent is handled by
main thread. And it will also initialize VPN shutdown process,
which will cause networkInfo changed event on
ConnectivityService internal thread. These two events need to
hold their corresponding lock and ask for the other one, which
causes the deadlock.

This patch move the event handling to the same thread to prevent
such deadlock, and cleanup some unused variables.

Change-Id: I5b656c0d0381acb4e33409a11f502db9b180296c
Fix: 139122208
Test: atest FrameworksNetTests, manual test
2019-08-30 19:56:59 +08:00
Treehugger Robot
08e1dae42f Merge "Run callbacks on ConnectivityService thread" 2019-08-30 10:18:28 +00:00
Aurimas Liutikas
07be422126 Add missing nullability annotations.
To prepare for enabling MissingNullability Metalava check this CL
works on adding missing nullability issues that metalava flags if
we tell it to flag new things since API 29.

This is not a complete CL, mostly addresses public api and
toString/equals for @SystemApi

Exempt-From-Owner-Approval: Large scale nullability clean up
Bug: 124515653
Test: make -j checkapi
Merged-In: I109260842cfc25f06e40694997fcbb4afa02c867
Change-Id: I109260842cfc25f06e40694997fcbb4afa02c867
2019-08-30 00:16:24 +00:00
Remi NGUYEN VAN
96521fb87d Run callbacks on ConnectivityService thread
Run MultinetworkPolicyTracker and DataConnectionStats callbacks on the
ConnectivityService handler thread.

Previously the callbacks would be using the SystemServer foreground
thread (Looper.myLooper()), or the broadcast thread for the
MultinetworkPolicyTracker BroadcastReceiver. This is error-prone, can
cause threading issues and makes it difficult to test the components.

Test: atest FrameworksNetTests
Change-Id: I189213dd363004abed294659165bf5430d153bba
2019-08-28 10:10:04 +09:00
wangmingming1
478ba7a6d9 notify netd about uid internet permission changes when package replaced
1. If a previous version of an app doesn't declare internet permission;
2. The User upgraded it to a new version and the new one does declare the
internet permission;
3. The new app are not allowed to access the internet until next boot

Bug: 137864893
Test: Manual, just make sure the onPackageChanged would be executed on package changes
Change-Id: I69cdbb16a027a9c4e974b32371b1f64a23a51a23
Signed-off-by: wangmingming1 <wangmingming1@xiaomi.com>
2019-08-26 09:30:59 +09:00
Oscar Shu
464e1b5e6f Merge "avoid generating reserved local MACs" 2019-08-21 17:45:00 +00:00
xshu
8438a85683 avoid generating reserved local MACs
Avoid generating WifiInfo.DEFAULT_MAC_ADDRESS as a randomized MAC
address since it's being used for another purpose.

Bug: 137796328
Test: atest MacAddressTest
Change-Id: Ia7beef0d0af5d7b39845e662cd343d81aef97702
2019-08-16 10:20:22 -07:00
Chiachang Wang
5fed8d9ee3 Get resource based on subId for multi-SIM
The resource loading is done based on the last SIM to come up
which is not a deterministic design. Thus, update the way to get
the resource based on the subId.

Test: atest FrameworksNetTests
Test: manually test with avoid bad wifi feature supported sim
Bug: 138956509
Change-Id: Ib5b085d97103889600773d269e03b939c29ca47d
2019-08-14 13:56:37 +08:00
Treehugger Robot
ecaff61c4b Merge "Extract test utilities for ConnectivityService" 2019-08-06 11:04:36 +00:00
Chalard Jean
95d62d8e55 Merge "Fix null pointer exception of calling NetworkInfo.mState.name()" 2019-08-02 19:56:10 +00:00
Remi NGUYEN VAN
0d0eb15091 Extract test utilities for ConnectivityService
The utilities help using ConnectivityService in tests, and will be used
to write integration tests for ConnectivityService.

Test: atest FrameworksNetTests
Change-Id: Ie895ad05139cd5768d3d8a9bd5589d72571f47e6
2019-08-01 16:32:30 +09:00
Yintang Gu
5014b52a5f Fix null pointer exception of calling NetworkInfo.mState.name()
Remove setting nai.networkInfo as null temporarily to identify the new
created NetworkAgent, avoiding timing issue triggered by constructor
NetworkInfo(null).

Bug: 135569043
Test: Mannual test, network can work normally
Change-Id: I123ef9e97df2bccdd9528c0e894283c66d053890
2019-07-31 11:07:37 +08:00
Xin Li
1354864491 DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master
Bug: 136196576
Change-Id: I481d824726ae0260b42cd7a4acc1c6fce593c324
2019-07-09 15:13:36 -07:00
Fedor Kudasov
2559cb3953 Revert "Cherry-pick the relevant parts of master change"
This reverts commit 5a4844e307.

Reason for revert: multiple build breakages b/137069068

Change-Id: If48bfa2d2cab0877a053743b3ec53820d0c4ed6b
2019-07-09 09:29:17 +00:00
Fedor Kudasov
496a313f47 Revert "Remove providesRoutesToMostDestinations."
This reverts commit 92bd90fa0b.

Reason for revert: multiple build breakages b/137069068

Change-Id: I60a4f71e13fe82f970b177a07c0b58439cbc64ff
2019-07-09 09:23:25 +00:00
android-build-team Robot
468cc3a375 Snap for 5622519 from b869620327dabaebe715a7d8fb3d12cdddd5a221 to pi-platform-release
Change-Id: I77f90a13ae9a3897eeffcc49b91ab9088f5d8001
2019-07-08 23:28:48 +00:00
Chalard Jean
92bd90fa0b Remove providesRoutesToMostDestinations.
This function is not used any more.

Test: FrameworksNetTests
Change-Id: Ia43f8811cb9d575e16735b0f4b76d91e7cd42ebc
2019-07-08 20:36:33 +09:00
Chalard Jean
5a4844e307 Cherry-pick the relevant parts of master change
I566437e4fe10e1346858149120c50b3c20ca073f to avoid a conflict

Test: atest FrameworksNetTests
Change-Id: I7de4f67234bf97d58bddffa22272c7670398f56d
2019-07-08 20:25:45 +09:00
Chalard Jean
9ce1e28788 Refactor TestNetworkCallback out of ConnectivityServiceTest.
TestableNetworkCallback will become a standard tool. This patch
and its companion in packages/modules/NetworkStack mostly move
it out of ConnectivityServiceTest, but also applies a few
cleanups like reordering arguments for standard order, renaming
...Like to ...That to match Mockito namings, and introduces
stonger static typing on some callbacks, which allows to remove
some unchecked casts.

Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I808a95ac33ec0c81a8829cad36a6917524297574
2019-07-04 16:12:40 +09:00
paulhu
a1dbf5b964 Correct FrameworksNetTests-jni-defaults lib
FrameworksNetTests-jni-defaults lib should only contain jni
dependencies. Remove static_libs/libs from it and update
FrameworksNetTests/FrameworksNetSmokeTests libs as well.

Bug: NA
Test: atest FrameworksNetSmokeTests FrameworksNetTests
Change-Id: I705e949e4c00035c9734b6a240529d1c2216eb6b
2019-07-01 09:29:13 +00:00
Lorenzo Colitti
f255e047b7 Unit tests for new explicitlySelected behaviour.
ag/7905088 added the ability to pass in acceptUnvalidated without
passing in explicitlySelected. Add unit tests for that code.

While I'm at it, convert a couple of "== 1"s to toBool(), and
update the comments in NetworkAgent.

Bug: 130766237
Test: atest FrameworksNetTests
Change-Id: I6b550bd621e3596975f83464c7b4b8a14269120b
2019-06-28 23:57:22 +09:00
Chalard Jean
763d449493 Merge "Simplify Exception expressions in CSTest" 2019-06-28 07:19:20 +00:00
Chalard Jean
484c4219d9 Simplify Exception expressions in CSTest
Test: CSTest
Change-Id: Ie9b9fc334b85836bf156bda71e54e8d30885b82a
2019-06-28 14:22:30 +09:00
Lorenzo Colitti
c75633460e Remove all static members from NetworkStatsFactory.
NetworkStatsFactory is owned by NetworkStatsService, and any
accesses to NSF data should go through NSS.

Test: atest FrameworksNetTests
Change-Id: Idbd0dbbaeb11313f63474e7ec0e01f974349fc89
2019-06-27 17:39:05 +09:00
Chalard Jean
0fd0e96a40 Merge "Revert "Simplify Exception expressions in CSTest"" 2019-06-27 08:30:57 +00:00
Chalard Jean
de6bb3e852 Revert "Simplify Exception expressions in CSTest"
This reverts commit d209586554.

Reason for revert: Breaks the build because it removes an unused method that was used by a change intervening in the mean time

Bug: 136143444
Change-Id: Id3a17e0b16ec03276609ca96fb7b582188ed1077
2019-06-27 08:30:05 +00:00
Lorenzo Colitti
c657dd301f Merge "Transfer ownership of NetworkStatsFactory to NetworkStatsService." 2019-06-27 07:53:30 +00:00
Chalard Jean
afbf997ad5 Merge "Simplify Exception expressions in CSTest" 2019-06-27 07:09:36 +00:00
Chalard Jean
0272942bca Merge "Unify assertThrows" 2019-06-27 07:08:59 +00:00
Lorenzo Colitti
f5af7fcf16 Transfer ownership of NetworkStatsFactory to NetworkStatsService.
NetworkStatsService is the only consumer of the data coming from
NetworkStatsFactory, but the factory itself is instantiated and
owned by NetworkManagementService.

Move it into NetworkStatsService instead.

Test: atest FrameworksNetTests
Change-Id: I52df1e545c646927952579da22845a12d1d7563b
2019-06-26 19:29:51 +09:00
Remi NGUYEN VAN
5c28780629 Merge "Only show "Connected" note after opening portal" 2019-06-25 15:20:33 +00:00
Chalard Jean
d209586554 Simplify Exception expressions in CSTest
Test: CSTest
Change-Id: I2c7d9e3092497526ab7d87b40a508f2d4bc3d7a2
2019-06-25 20:40:41 +09:00
Chalard Jean
045d5fca24 Unify assertThrows
Test: atest FrameworksTestsNet NetworkStackTests
Change-Id: Ib6d5d2577a5b95f90857d8d146b00af516e9944d
2019-06-25 20:40:39 +09:00
Remi NGUYEN VAN
705b46b900 Only show "Connected" note after opening portal
The "Connected" notification would be shown every time a network
validates after being identified as a captive portal. This causes issues
on networks that have auto-login mechanisms, as a high priority
notification would be shown even though the user was not interacting
with the phone.

The "Connected" notification is intended to confirm to the user that
they successfuly logged in (manually), so only show it after the user
opens the portal on the network.

Bug: 134124044
Test: Flashed, connected to portal: notification shown
      Opened portal from command line + revalidate: no notification
      Tests passing with change, failing without

Change-Id: I89e7a7f49019bd7e4686712c56e00bd786eb3ef3
2019-06-25 19:18:16 +09:00
Lorenzo Colitti
f7d14dba58 Merge "NetworkStats: Fix race condition causing system server crashes" 2019-06-25 07:54:17 +00:00
Hugo Benichi
5c8f9cf7ed NetworkStats: Fix race condition causing system server crashes
NetworkStatsService uses an internal boolean to know when it has
started for the purpose of preventing access to other internal
variables before they are initialized.

However that boolean is set to true in systemReady() non-atomically
with respect to the initialization of the other variables it guards,
which can cause the system server to crash.

This patch fixes this concurrency bug by moving setting the internal
boolean flag and the variable it guards in one atomic synchronized
block.

This patch also removes code checking if bandwidth control is enabled,
because this is now always true.

Bug: 132767673
Test: Compiled.
Change-Id: Ia089b5767ce271d669879c975508654d4dd03429
2019-06-25 10:51:51 +09:00
Lorenzo Colitti
df2b6ea27c Merge "Don't auto-connect to networks that have no/limited connectivity." 2019-06-24 10:45:51 +00:00
Lorenzo Colitti
2f2b961176 Don't auto-connect to networks that have no/limited connectivity.
Auto-reconnecting to a network with no or limited Internet
connectivity is not useful. This is because such networks cannot
be used unless the user taps the notification and interacts with
the resulting dialog. But the notification is only shown if the
user manually connects to the network, not if the system
auto-connects to it.

Bug: 130683832
Bug: 130766237
Test: atest FrameworksNetTests
Change-Id: I5413393529c4bad3a707df229307542486bcff33
Merged-In: I5413393529c4bad3a707df229307542486bcff33
2019-06-24 11:39:18 +09:00
Chalard Jean
af718367c2 Factorize custom asserts.
Also a few utilities that were in the way, and some opportunistic
cleanups.

Test: FrameworksNetTest NetworkStackTest
Change-Id: I385070e2044fd967cb18f1ffea9a86a4627b742e
2019-06-20 16:24:25 +09:00
Junyu Lai
c961e03526 Merge "Move the test of minimum supported keepalive slots to CTS" 2019-06-19 14:08:31 +00:00
Junyu Lai
7423873ac8 Merge "Correct value of supported keepalive count for cellular" 2019-06-19 14:08:31 +00:00
junyulai
5b3b486b8f Move the test of minimum supported keepalive slots to CTS
This change also enables log when keepalive is started.

Bug: 134352656
Test: 1. atest android.net.cts.ConnectivityManagerTest#testSocketKeepaliveLimitTelephony
      2. atest FrameworksNetTests
Change-Id: I408750fa0bceb0c1c26afb5fead4e44fb824fbc1
2019-06-19 16:25:19 +08:00
Paul Hu
37377069ba Merge "Add SocketUtils CTS tests" 2019-06-18 10:46:30 +00:00
Varun Anand
2ce04660f6 Merge changes Ieb8645ac,I6466ec14,I87deb82b,I995b108e,Ib6521459
* changes:
  Remove VPN info arrays from NetworkStats(Observer|Recorder)
  NetworkStatsFactory: Take VPNs into account for network/battery stats
  Remove duplicate line in clat_simple test file
  Remove unused lastStats parameter
  Revert "Revert "Take all VPN underlying networks into account when migrating traffic for""
2019-06-17 15:56:24 +00:00