Commit Graph

1320 Commits

Author SHA1 Message Date
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
Remi NGUYEN VAN
87a9bc7edb Temporarily disable testUidStatsForTransport
The test cannot pass in branches that use an old prebuilt tethering
module.

Bug: 234099453
Test: atest NetworkStatsServiceTest
Merged-In: Ib1d180cc799dde94ada642ce752623b4b65f1e31
Merged-In: I44dda14cae265e600010c6f8efe1471ac481c6ea
Merged-In: I702a75e91be0bb582f9cbd7b4a23e1286f8252cf
Change-Id: I7ce44dac1b5d730f84f882ba8ae1b741a633e765
2022-06-03 15:52:32 +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
dd9b794e5c Verify if the VPN app has been added into power save whilte list
Bug: 234104087
Test: atest FrameworksNetTests:VpnTest
Change-Id: I2aa99b8ea8dbe668a45782f50a4a0ac82e72b7a2
(cherry picked from commit 802fa5d0ec)
Merged-In: I2aa99b8ea8dbe668a45782f50a4a0ac82e72b7a2
2022-06-03 05:49:21 +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
Treehugger Robot
019e6eb2d7 Merge "Fix crash when decrementing data usage request" 2022-05-27 10:02:33 +00:00
Junyu Lai
a1970dafa1 Fix crash when decrementing data usage request
When unregistering, if the caller process is dead. The system
can unregsiter for the caller. But the request decrement should
be counted onto the caller uid instead of system uid.

Test: NetworkStatsObserversTest#testUnregister_knownRequest_invalidUid_doesNotUnregister
Bug: 233580307
Change-Id: I85aee8f395739929bc7086883ace81ac1ecd0730
Merged-In: I85aee8f395739929bc7086883ace81ac1ecd0730
  (pure cherry-picked from ag/18579047)
2022-05-27 09:50:52 +00:00
Paul Hu
516d5dc0ea Add some non-connectivity-module-test back to ConnectivityCoverageTests
In S, the tests are listed in the non-connectivity-module-test
where their testing files are not in the connectivity module.
But some files move into the connectivity module in T. So some
tests can be removed from non-connectivity-module-test and will
be running on ConnectivityCoverageTests to count their code
coverage.

Also update some tests to make them compatible with
mockito-extended and ignore some tests which need to test with
T apis.

Bug: 234000451
Test: atest FrameworksNetTests ConnectivityCoverageTests
Change-Id: I47fb59334d00ae7fee91c5694548b3cf89b09b2d
2022-05-27 07:16:46 +00:00
Patrick Rohr
d84c99cad2 Merge changes from topics "cherrypicker-L37800000954756398:N06400001268122372", "cherrypicker-L61200000954646707:N00900001267167505", "cherrypicker-L64000000954631044:N08200001267145803" into tm-dev
* changes:
  Temporarily ignore ethernet tests until prebuilts are updated
  Add CTS tests for EthernetNetworkProvider changes
  Move EthernetNetworkFactory to using the NetworkProvider API
  Add NetworkOfferCallback to NetworkInterfaceState
  Change NetworkInterfaceState to hold NetworkProvider instance
  Improve waiting for interface added or removed
  Always wait for interface to be up in EthernetManagerTest
  Assume all Ethernet interfaces have an MTU of 1500.
2022-05-25 23:31:09 +00:00
Patrick Rohr
14f45a3e98 Temporarily ignore ethernet tests until prebuilts are updated
Using Merged-In line of commit that adds the CTS tests to prevent this
change from going anywhere it should not.

Unfortunately, the test runner does not properly parse tests ignored at
the class level.

Test: TH
Bug: 233824546
Ignore-AOSP-First: only needed on tm-dev
Change-Id: Ia911cdfc39614ccda5f2cf8bfd1d913cf80a60ae
Merged-In: I8e806b3b884f2e0b6c1a1d2fffdb9a99c5dd60e8
2022-05-25 11:54:36 -07:00
Patrick Rohr
0ccff8a30b Move EthernetNetworkFactory to using the NetworkProvider API
This CL makes EthernetNetworkFactory inherit from NetworkProvider rather
than NetworkFactory. The name of the class is purposefully unchanged to
make the code review easier (it will be changed to
EthernetNetworkProvider in a follow up).

As part of the conversion, NetworkInterfaceState now registers a
NetworkOffer when the link comes up and unregisters it when the link
goes down. It updates the existing offer when capabilities change (by
calling registerNetworkOffer with an already registered
NetworkOfferCallback).

This change should fix existing refCount issues. When a NetworkOffer is
first registered, it receives callbacks for all existing requests. This
is the main problem with the NetworkFactory implementation where only
one NetworkOffer is registered when the factory is first created; so
when interfaces come up, they do not receive callbacks for existing
requests.

Test: atest EthernetNetworkTest
Bug: 197548738
Change-Id: I5e8e4673d2ed04bc1a0c8d232a8772edfff65b5d
Merged-In: I5e8e4673d2ed04bc1a0c8d232a8772edfff65b5d
2022-05-25 11:50:30 -07:00
Lucas Lin
81f05b9011 Merge changes from topics "CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED", "CATEGORY_EVENT_DEACTIVATED_BY_USER" into tm-dev
* changes:
  Test VpnManager event for CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED
  Test VpnManager event for CATEGORY_EVENT_DEACTIVATED_BY_USER
2022-05-25 10:20:18 +00:00
Patrick Rohr
268e1c6d2e Merge "Remove automotive restriction from enable/disableInterface" am: 345655f7bc am: 1d0e33db3a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2103746

Change-Id: Iaa4e13f6babe0074c7123c6a8728102b9d29b8a3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 02:51:26 +00:00
Motomu Utsumi
df08c582e7 Merge "Skip VPN filtering tests on unsupported versions" am: badf2ebed7 am: 5be13c52e3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2103111

Change-Id: I84f2508afc3f47f95a7b143332e3d96d055182da
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 02:05:14 +00:00
Patrick Rohr
345655f7bc Merge "Remove automotive restriction from enable/disableInterface" 2022-05-25 02:00:51 +00:00
Motomu Utsumi
badf2ebed7 Merge "Skip VPN filtering tests on unsupported versions" 2022-05-25 01:22:16 +00:00
TreeHugger Robot
2e873fe421 Merge "Fix crash when decrementing data usage request" into tm-dev am: 898a5f9acc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18579047

Change-Id: I18592135ed75480e5b6603aa7cbc7a42e3b77a12
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 00:05:19 +00:00
TreeHugger Robot
4aab8634c6 Merge changes Id91fabb4,I6d117032,I88fce1b2 into tm-dev am: fae0ef515c
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18579048

Change-Id: Ie495cb9e4454dc9c56271aae4f95c6d204da598b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-25 00:04:27 +00:00
TreeHugger Robot
898a5f9acc Merge "Fix crash when decrementing data usage request" into tm-dev 2022-05-24 23:52:30 +00:00
Junyu Lai
ecec6d9350 Address comment at ag/18491259 and ag/18486388
Ignore-AOSP-First: in a topic with internal-only changes
Test: TH
Bug: 230289468
Change-Id: Id91fabb47b542d8526d6aa787b5947238c3934fb
2022-05-25 00:41:49 +08:00
Junyu Lai
a69db7de03 Fix crash when decrementing data usage request
When unregistering, if the caller process is dead. The system
can unregsiter for the caller. But the request decrement should
be counted onto the caller uid instead of system uid.

Ignore-AOSP-First: Urgent fix
Test: NetworkStatsObserversTest#testUnregister_knownRequest_invalidUid_doesNotUnregister
Bug: 233580307
Change-Id: I85aee8f395739929bc7086883ace81ac1ecd0730
2022-05-24 23:41:05 +08:00
Motomu Utsumi
ca314e7f77 Skip VPN filtering tests on unsupported versions
Lockdown filtering rule and interface filtering rule with null interface
were introduced to T+ devices.
So, skip related tests in pre-T devices.

Bug: 232902954
Test: atest ConnectivityServiceTest
Change-Id: I9ee76096c1bd04c9333bc561ffc8064a14780ce5
2022-05-24 13:41:36 +00:00
Patrick Rohr
a64347b982 Merge changes I8e806b3b,I5e8e4673,Id2a078da am: 826bdb3ec4 am: f2d3148059
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2101321

Change-Id: I16f8c71752b5e323062b276cc1ad5414e67d546e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-24 05:14:13 +00:00
Patrick Rohr
fd829a5cb2 Remove automotive restriction from enable/disableInterface
Allow calling enable/disableInterface on non-automotive devices. Also,
fixing the naming of these functions to be consistent with the API.

Test: atest EthernetManagerTest
Bug: 171872016
Bug: 225317990
Change-Id: Ic20185a855d0e639582132bf1103e0183f6f78c3
2022-05-24 03:54:38 +00:00