Commit Graph

939 Commits

Author SHA1 Message Date
Aaron Huang
438cad705c Merge "Remove debug log from NetworkStatsService" am: bd96778236 am: 2a9dae00ba
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2117037

Change-Id: I3221a0799dc86537fdff803a98e10103c253463e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-09 03:44:47 +00:00
Aaron Huang
bd96778236 Merge "Remove debug log from NetworkStatsService" 2022-06-09 02:37:42 +00:00
Treehugger Robot
f8ad5d6ca1 Merge "ClatCoordinator: improve file descriptor clean up in error handling" am: a58028e31a am: b15536a161
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2114854

Change-Id: I87af9b09aa79bc6224a4b8a75c2e5d3c70c55807
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-08 07:58:47 +00:00
Treehugger Robot
a58028e31a Merge "ClatCoordinator: improve file descriptor clean up in error handling" 2022-06-08 07:19:31 +00:00
Aaron Huang
de99c7a9f4 Remove debug log from NetworkStatsService
This change reverts aosp/1777887. The exception was used to get
the stack while the mMobileIfaces contains null interface, and
currently mMobileIfaces is protected by making it volatile so
it is fine to be removed.

Also, fix style error in NetworkStatsServiceTest

Test: build, FrameworksNetTests
Change-Id: I8435354f8cfd05589c0231f3bb8cbaa66c0525cf
2022-06-08 12:20:55 +08:00
Junyu Lai
093cd94972 Merge changes from topic "oom-fix"
* changes:
  Fix get summary does not include the latest bucket
  Add unit test for MultipathPolicyTracker
2022-06-07 09:26:09 +00:00
Aaron Huang
5804b5c5df Merge "Hold wifi and mobile interfaces since boot in NetworkStatsService" 2022-06-07 07:36:26 +00:00
Motomu Utsumi
aee69a63d8 Merge "Add 3rd deny firewall chain for OEM" am: 1259ebcb59 am: b80b5e5476
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2117038

Change-Id: I9bc36d8d1b3870d821a9440d7babfc7f9d20a727
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-07 06:14:35 +00:00
Junyu Lai
04b2cb2f2d Fix get summary does not include the latest bucket
In internalGetSummaryForNetwork, the history object will not
include the latest bucket because of the logic in
NetworkStatsHistory#recordHistory would only include buckets
that atomically occur in the inclusive time range.

This makes querySummaryForDevice callers who are also sensitive
to the latest bucket fails.

This CL revert the behavior back to S, in T this is temporarily
changed after aosp/1937268.

Also, for test purpose, this CL change System.currentTimeMillis to
use mClock when querying.

Test: NetworkStatsServiceTest#testGetLatestSummary
Bug: 233733267
Change-Id: I55e2a5d953622b68da36a9b8d3e57c88d57543b0
Merged-In: I55e2a5d953622b68da36a9b8d3e57c88d57543b0
  (pure cherry-picked from ag/18670248)
2022-06-07 11:07:46 +08:00
Junyu Lai
207b125a20 Add unit test for MultipathPolicyTracker
This CL adds unit test to test onThresholdReached event
would unregister and re-register usage callback.

Test: MultipathPolicyTrackerTest#testOnThresholdReached
Bug: 233733267
Change-Id: I6e43ae93055009d91b0795a4466f2c02f4403c0a
Merged-In: I6e43ae93055009d91b0795a4466f2c02f4403c0a
  (pure cherry-picked from ag/18579049)
2022-06-07 11:06:46 +08:00
Motomu Utsumi
1d9054ba5f Add 3rd deny firewall chain for OEM
Bug: 208371987
Test: atest
CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking
ConnectivityServiceTest

Change-Id: Ib521fa02f6a19270cb88a3d85321bda822516c78
2022-06-06 07:47:35 +00:00
Aaron Huang
f4f5de3993 Hold wifi and mobile interfaces since boot in NetworkStatsService
In current design, the interface will be removed from the list if
the network disconnected which will cause getUidStatsForTransport()
returns unexpected snapshot to caller since the list is empty.

This change also remove interface name from all entries before
the method returns the result.

Bug: 231514741
Test: FrameworksNetTests
      manual test
Change-Id: Ie60829a65d0d9b5b63ad353695a820c0586e3665
Merged-In: Ie60829a65d0d9b5b63ad353695a820c0586e3665
2022-06-06 13:19:11 +08:00
Treehugger Robot
5f5b94cfdf Merge "ClatCoordinatorTest: add test for startClat error handling" am: 6d0b34ecb3 am: d8031cf082
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2109965

Change-Id: I4de6014183413c6f44e239b2ba0dcca198d309f4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 15:51:39 +00:00
Treehugger Robot
0a4c675372 Merge "ClatCoordinatorTest: add testDump" am: 1076248194 am: 70e1fd1cc2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2110085

Change-Id: I4690dfb0dda3decc4b7e335679c1fbda4b206b91
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 15:51:29 +00:00
Treehugger Robot
6d0b34ecb3 Merge "ClatCoordinatorTest: add test for startClat error handling" 2022-06-03 15:17:10 +00:00
Treehugger Robot
1076248194 Merge "ClatCoordinatorTest: add testDump" 2022-06-03 15:17:06 +00:00
Lorenzo Colitti
266e3cc123 Merge changes from topic "remove-ethernet-shims" am: 337d512081 am: 293129ca50
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2114378

Change-Id: I557bc2835c6aa75af895466585424fd0587bfcb0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 12:23:56 +00:00
Lorenzo Colitti
337d512081 Merge changes from topic "remove-ethernet-shims"
* changes:
  ethernet: add test for tethered interface callbacks
  ethernet: stop using EthernetManager shims
  ethernet: broadcast state change for server interfaces
  ethernet: increase timeout to deflake tests
2022-06-03 11:51:58 +00:00
Motomu Utsumi
78319c9f6d Merge "Add deny firewall chain for OEM" am: 181f7c85fc am: 7731ca47f9
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2114533

Change-Id: I9bfb2edc9bded9e895f291385ebdb16218fe05a2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 11:46:43 +00:00
Motomu Utsumi
181f7c85fc Merge "Add deny firewall chain for OEM" 2022-06-03 11:06:02 +00:00
Aaron Huang
ab097b28d5 Hold wifi and mobile interfaces since boot in NetworkStatsService am: a2f1cf3576
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18710006

Change-Id: Ie53afd7a2c6cfdd46a1ed3954a1aceac9bd120eb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 09:25:50 +00:00
Motomu Utsumi
d980149817 Add deny firewall chain for OEM
Bug: 207773349
Bug: 208371987
Test: atest
CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testFirewallBlocking
--iterations 50 && atest ConnectivityServiceTest --iterations 10

Change-Id: I60d5540821abcced03356f366775f16ee369d7f9
2022-06-03 09:10:57 +00:00
Patrick Rohr
f33f276b29 ethernet: broadcast state change for server interfaces
Also update the test to ensure mFactory.hasInterface is mocked to match
mFactory.getInterfaceState: previously it would be called by the factory
in the mocked getInterfaceState, but the new code calls it directly.

Bug: 171872016
Test: atest EthernetManagerTest
Change-Id: I9ac959f181c88a7992991923b98a836f2833fa88
2022-06-03 16:56:39 +09:00
Aaron Huang
a2f1cf3576 Hold wifi and mobile interfaces since boot in NetworkStatsService
In current design, the interface will be removed from the list if
the network disconnected which will cause getUidStatsForTransport()
returns unexpected snapshot to caller since the list is empty.

This change also remove interface name from all entries before
the method returns the result.

Ignore-AOSP-First: non-AOSP CL is included in the same topic
Bug: 231514741
Test: FrameworksNetTests
      manual test
Change-Id: Ie60829a65d0d9b5b63ad353695a820c0586e3665
2022-06-03 15:51:19 +09:00
Benedict Wong
d0f327bad8 Merge "Verify if the VPN app has been added into power save whilte list" am: 70e2da5c75 am: de5882675b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2115075

Change-Id: Ibd455acdd683f89d5feaf9416924f4632fee5ff5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-03 06:16:48 +00:00
lucaslin
802fa5d0ec Verify if the VPN app has been added into power save whilte list
Bug: 234104087
Test: atest FrameworksNetTests:VpnTest
Change-Id: I2aa99b8ea8dbe668a45782f50a4a0ac82e72b7a2
2022-06-02 20:19:09 +00:00
TreeHugger Robot
3caf95c8fc Merge changes from topic "cherrypicker-L15200000954882986:N47600001270136565" into tm-dev
* changes:
  Temporarily disable NsdService unit tests
  Fix service resolve on tethering downstreams
2022-06-02 10:49:33 +00:00
Hungming Chen
b7bbdbebc6 ClatCoordinator: improve file descriptor clean up in error handling
- Make the file descriptor clean up better when an error happens.
- Remove unused TODO for iptables because it has been
  implemented by another approach. See b/218407445.

Test: atest com.android.server.connectivity.ClatCoordinatorTest
Change-Id: Ib8bfa8875ae774769ab7e416fa7e5fde140f58da
2022-06-02 18:37:15 +08:00
Lorenzo Colitti
9b4d5b7f9e Merge changes from topic "vpnmanager-events-T" into tm-dev
* changes:
  Test VpnManager event for CATEGORY_EVENT_NETWORK_ERROR
  Test VpnManager event for CATEGORY_EVENT_IKE_ERROR
2022-06-02 10:12:53 +00:00
Remi NGUYEN VAN
a3ce8f8438 Temporarily disable NsdService unit tests
The unit tests cannot pass before a newer prebuilt of Tethering is used,
as bootclasspath classes that it tests would be outdated.

This change is not merged in downstreams that build from source (changes
in the merged-in tags are not related changes, however).

Bug: 234099453
Test: atest

Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
Change-Id: I5b0cb131fcb5feb6b3cfd70e95ba7c5e54fa2294
2022-06-02 17:45:00 +09:00
Hungming Chen
171377450f ClatCoordinatorTest: add test for startClat error handling
Used to increase mainline test code coverage for startClat()
which has bunches of code for unwinding the native method failure.

For now, code coverage for startClat(): 51.89% (55/106 lines)

Test: atest com.android.server.connectivity.ClatCoordinatorTest
Change-Id: I398d5863359ff329b06966488053edd9006f17aa
2022-06-02 15:20:14 +08:00
Hungming Chen
af5c235cfc ClatCoordinatorTest: add testDump
Used for verifying the dump content and increasing test coverage.

The test coverage for now:
dump:           0% (0/7 lines)
dumpBpfEgress:  0% (0/13 lines)
dumpBpfIngress: 0% (0/13 lines)

Test: atest com.android.server.connectivity.ClatCoordinatorTest
Change-Id: I5e444e95d50f7ca266555139b3639723773fd83d
2022-06-02 15:20:09 +08:00
Junyu Lai
c24c82e9d4 Merge changes from topic "increment-crash" into tm-dev am: 2a21ffa679
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18670248

Change-Id: Iba174a8bb7e180ae50bf471153f2f2dc9f192b88
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 10:16:16 +00:00
Junyu Lai
2a21ffa679 Merge changes from topic "increment-crash" into tm-dev
* changes:
  Fix get summary does not include the latest bucket
  Add unit test for MultipathPolicyTracker
2022-06-01 09:45:05 +00:00
Xiao Ma
06680aaad4 Merge "Add IpConfigStore testcase to improve the code coverage." am: c0e80ee9f9 am: 07be3f5bb8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2110092

Change-Id: I0a06b984f658a6451ab5a5723e67de0d4b80f328
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 09:09:00 +00:00
Xiao Ma
c0e80ee9f9 Merge "Add IpConfigStore testcase to improve the code coverage." 2022-06-01 07:47:07 +00:00
Chiachang Wang
621b1dec27 Merge "Add test coverage for ConnectivityService.dump with arguments" am: c0b2b37faa am: 5e2a2a0a73
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2112804

Change-Id: Icf7ea1de2c67ae2ff4f15e29d998bca0f2ce7df6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 06:09:21 +00:00
Remi NGUYEN VAN
2bd25cdc84 Merge "Fix service resolve on tethering downstreams" am: 5eaefa21bf am: d0a31d8e08
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2110084

Change-Id: I14bf75238dd36a9d5c834f26964d1e861d1e714e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-01 06:09:12 +00:00
Xiao Ma
b4a8fd534a Add IpConfigStore testcase to improve the code coverage.
Add new testcase in IpConfigStoreTest to cover the readIpConfiguration
usage, improve the code coverage for connectivity module.

To reduce the flakyness of test, this cl refactors DelayedDiskWriter
constructors by allowing to pass in a Dependencies instance, then
waitForIdle can be used to check if the delayed write operation
associated with the passed-in HandlerThread has completed in tests.

Bug: 234315786
Test: atest com.android.server.net.IpConfigStoreTest
Change-Id: I57c8bd02a771f1cca815252ba502cda0210d1385
2022-06-01 14:47:47 +09:00
Chiachang Wang
c0b2b37faa Merge "Add test coverage for ConnectivityService.dump with arguments" 2022-06-01 05:41:50 +00:00
Remi NGUYEN VAN
0102c9440a Fix service resolve on tethering downstreams
Tethering downstreams do not have NetworkAgents, and although they have
a netid of 99, Networks with netId 99 are not usable by apps for most
connectivity APIs.

Recent refactoring in NsdService adds the Network of a found service
into its NsdServiceInfo, and uses that network to resolve the service.
In that case the Network has netId 99 and resolving the service fails.

Avoid that problem by:
 - Keeping the Network field null when a service is found on a tethering
   downstream; this avoids giving apps a confusing and unusable Network
   with netId 99
 - Using the interface index found during discovery to resolve the
   service, if the app uses the NsdServiceInfo that was obtained from
   discovery to resolve. If not, all interfaces will be used to resolve,
   as per legacy APIs.

Bug: 233979892
Test: atest NsdServiceTest
      Also manual test with 2 devices connected via hotspot
Change-Id: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
(cherry picked from commit 1a8ee102d3)
Merged-In: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
2022-06-01 05:35:36 +00:00
Remi NGUYEN VAN
5eaefa21bf Merge "Fix service resolve on tethering downstreams" 2022-06-01 05:31:14 +00:00
chiachangwang
9673c4ddad Add test coverage for ConnectivityService.dump with arguments
Test: atest FrameworksNetTests
Change-Id: I389ef6e89a7570cb3e7f8cedab48517c25c4c0b0
2022-06-01 03:58:25 +00:00
Natasha Lee
bcdb3c12ee Merge changes from topic "stats-migration"
* changes:
  Skip PersistentIntTest on S- device
  Don't clobber existing history entries.
  Ensure NetworkStats migrated snapshot is identical
  [MS82.1] Support network stats data migration process
  Add a PersistentInt class.
2022-06-01 03:03:02 +00:00
Junyu Lai
e971f15288 Fix get summary does not include the latest bucket
In internalGetSummaryForNetwork, the history object will not
include the latest bucket because of the logic in
NetworkStatsHistory#recordHistory would only include buckets
that atomically occur in the inclusive time range.

This makes querySummaryForDevice callers who are also sensitive
to the latest bucket fails.

This CL revert the behavior back to S, in T this is temporarily
changed after aosp/1937268.

Also, for test purpose, this CL change System.currentTimeMillis to
use mClock when querying.

Ignore-AOSP-First: Urgent fix
Test: NetworkStatsServiceTest#testGetLatestSummary
Bug: 233733267
Change-Id: I55e2a5d953622b68da36a9b8d3e57c88d57543b0
2022-06-01 09:34:30 +08:00
Remi NGUYEN VAN
1a8ee102d3 Fix service resolve on tethering downstreams
Tethering downstreams do not have NetworkAgents, and although they have
a netid of 99, Networks with netId 99 are not usable by apps for most
connectivity APIs.

Recent refactoring in NsdService adds the Network of a found service
into its NsdServiceInfo, and uses that network to resolve the service.
In that case the Network has netId 99 and resolving the service fails.

Avoid that problem by:
 - Keeping the Network field null when a service is found on a tethering
   downstream; this avoids giving apps a confusing and unusable Network
   with netId 99
 - Using the interface index found during discovery to resolve the
   service, if the app uses the NsdServiceInfo that was obtained from
   discovery to resolve. If not, all interfaces will be used to resolve,
   as per legacy APIs.

Bug: 233979892
Test: atest NsdServiceTest
      Also manual test with 2 devices connected via hotspot
Change-Id: Idd176153b67ccbd1d4f1b1fd66dafaa2f3a9e27a
2022-05-31 13:06:22 +09:00
Junyu Lai
9fc333024f Add unit test for MultipathPolicyTracker
This CL adds unit test to test onThresholdReached event
would unregister and re-register usage callback.

Ignore-AOSP-First: Urgent fix
Test: MultipathPolicyTrackerTest#testOnThresholdReached
Bug: 233733267
Change-Id: I6e43ae93055009d91b0795a4466f2c02f4403c0a
2022-05-30 22:16:42 +08:00
lucaslin
affb72d2b8 Test VpnManager event for CATEGORY_EVENT_NETWORK_ERROR
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Idffd5f5f8fc6614281f3fb0884228a797d783fe3
(cherry picked from commit cfec723ef9)
Merged-In: Idffd5f5f8fc6614281f3fb0884228a797d783fe3
2022-05-28 06:01:17 +00:00
lucaslin
744c8967e5 Test VpnManager event for CATEGORY_EVENT_IKE_ERROR
Bug: 191413541
Test: atest FrameworksNetTests:VpnTest
Change-Id: Iebc0ac281eb03fac9626c64e44cdd14be1462d89
(cherry picked from commit 827b44daea)
Merged-In: Iebc0ac281eb03fac9626c64e44cdd14be1462d89
2022-05-28 06:01:13 +00:00
Paul Hu
8ecfaa7ea7 Add some non-connectivity-module-test back to ConnectivityCoverageTests am: 516d5dc0ea am: 68eb8042a6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2108067

Change-Id: Idb25eaa0d9a5b53b31b272951bd17a0af23ff9f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-27 10:25:37 +00:00