Commit Graph

891 Commits

Author SHA1 Message Date
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
Chiachang Wang
c0b2b37faa Merge "Add test coverage for ConnectivityService.dump with arguments" 2022-06-01 05:41:50 +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
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
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
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
Junyu Lai
1190ea3eb7 Skip PersistentIntTest on S- device
This class is only used in the service runs on T+ devices.
Thus run this test on S- device does not make senses.

Bug: 230289468
Test: atest ConnectivityCoverageTests:PersistentIntTest
      on S device
Change-Id: I97a29df17ef9ee9ab373655f045cdb5c820e06ef
Merged-In: I97a29df17ef9ee9ab373655f045cdb5c820e06ef
  (pure cherry-picked from ag/18486287)
2022-05-24 11:38:20 +08:00
Lorenzo Colitti
ec2fbb7159 Don't clobber existing history entries.
Currently, adding a history to a NetworkStatsCollection.Builder
will overwrite any history that was previously passed in with the
same key. This breaks the importer (which is the primary/only
caller of this code), because the importer re-uses the same
NetworkStatsCollection object to import multiple files.

Instead, simply add any passed-in entries after the ones that
were already there. Require the caller to pass in entries in
order, because NetworkStatsHistory internally assumes that
entris are always sorted.

Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
Merged-In: Ic8647ff28fca78d579d5f759f96a864877f8158b
  (pure cherry-picked from ag/18453213)
2022-05-24 11:37:42 +08:00
Remi NGUYEN VAN
c62261f140 Ensure NetworkStats migrated snapshot is identical
Read migration snapshot both from the platform API and the legacy
method, and Log.wtf if they are different. Use the legacy method data if
they are.

This ensures that using the migration API is a no-op, and that errors
are reported (through Log.wtf) if it would not have been if used as-is.

Test: NetworkStatsServiceTest
Bug: 230289468
Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
Merged-In: I857ad18183d63d1aa16e89f89eb24009648720a2
  (pure cherry-picked from ag/18452103)
2022-05-24 11:37:12 +08:00
Junyu Lai
a388d4bf06 [MS82.1] Support network stats data migration process
This includes:
1. Provide NetworkStatsRecorder#importCollectionLocked to
   allow caller to write a NetworkStatsCollection object to
   a standalone file.
2. Do not clear the collection in NetworkStatsRecorder#
   CombiningRewriter, this is safe since pending set will
   still be cleared during forcePersistLocked.
3. Implement the migration process, including recovery and
   safety measures.

Test: NetworkStatsServiceTest NetworkStatsCollectionTest
Test: manual test with
      adb shell device_config put tethering \
      netstats_store_files_in_apexdata true
      adb shell device_config put tethering \
      netstats_import_legacy_target_attempts 1
Bug: 230289468
Change-Id: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
Merged-In: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
  (pure cherry-picked from ag/18367994)
2022-05-24 11:36:36 +08:00
Lorenzo Colitti
2ce66fc8e6 Add a PersistentInt class.
This implements a simple integer written to disk backed by
AtomicFile.

Bug: 230289468
Test: new unit test
Change-Id: I1c73c8ac2429f92153cfba3b006b4374e75e65df
Merged-In: I1c73c8ac2429f92153cfba3b006b4374e75e65df
  (pure cherry-picked from ag/18437645)
2022-05-24 11:35:58 +08:00
Patrick Rohr
826bdb3ec4 Merge changes I8e806b3b,I5e8e4673,Id2a078da
* changes:
  Add CTS tests for EthernetNetworkProvider changes
  Move EthernetNetworkFactory to using the NetworkProvider API
  Improve waiting for interface added or removed
2022-05-24 03:34:25 +00:00
Patrick Rohr
daca9ca74f 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
2022-05-23 15:07:36 -07:00
Yan Yan
3ca3e7cf2d Merge "Throw IAE when Network's LinkProperties is null" am: 5345fa1144 am: b5a6b0118a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2101892

Change-Id: I7f2663d1a67141b652204d6fcc97f936c2f68b33
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-23 17:59:34 +00:00
Yan Yan
5345fa1144 Merge "Throw IAE when Network's LinkProperties is null" 2022-05-23 17:24:07 +00:00
Junyu Lai
bfc68ac08a Persisting status int on the device if fallback happened
This CL also stop from incresing "successes" counter if the
importer finishes with fallback.

Ignore-AOSP-First: in a topic with internal-only changes
Test: manual
Bug: 230289468
Change-Id: I88fce1b2d0dea3772a8b31df8f8fa93bf13bffad
2022-05-23 17:48:55 +08:00
Yan Yan
be3eb3d56a Throw IAE when Network's LinkProperties is null
Improve the setUnderlyingNetwork method by throwing IAE
when Network's LinkProperties is null. Also update the
API doc to give caller more guidance in using this API

Bug: 232309601
Test: UT: IpSecServiceParameterizedTest, IpSecServiceTest,
      IpSecServiceRefcountedResourceTest, IpSecManagerTest, VpnTest
Test: CTS: IpSecManagerTest, IpSecManagerTunnelTest, Ikev2VpnTest
Test: make doc-comment-check-docs
Change-Id: Idab4706b0db42ed2222fb48b168589ed005d2f2f
2022-05-20 17:03:07 -07:00
TreeHugger Robot
b1dea19099 Merge "Move ipconfig file inside apex data directory" into tm-dev am: 9f57db4bda
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18514356

Change-Id: Ibb2d1c50fb68622d38f9c5db319de13f40147e96
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-20 12:54:13 +00:00
Patrick Rohr
64468d1494 Move ipconfig file inside apex data directory
In order to support rollbacks, the ethernet ipconfig file needs to be
written to the data apex's data directory. We still need to support
reading from the legacy location to be backwards compatible.

If the apex file path already exists, then read the IP configuration
from there directly, otherwise, check if the legacy file path exists,
if yes, read the legacy IP configuration and copy it to the new apex
file path.

Support for default IpConfiguration is also being removed in this CL.
The default IpConfiguration (configuration entry for interface "0")
was a way to transition from supporting a single interface to
supporting multiple interfaces and was introduced in P. Every device
that has used such a configuration and has connected to an ethernet
network since upgrading to P+ has already removed the "0" config and
has assigned it to the first interface (probably "eth0"). There has
never been an API to set this, but if someone wanted to install a
default IpConfiguration, they could just configure "eth0" instead.

Bug: 224919694
Test: atest EthernetConfigStoreTest --iterations
Test: manually test
      - adb push <fake ipconfig.txt> /data/misc/ethernet/
      - adb reboot
      - read the IP config from legacy path and the same config
        file is created in the apex file path
      - adb reboot
      - read the IP config from the apex file path directly
Change-Id: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a
(cherry picked from commit 47641d75d9)
Merged-In: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a
2022-05-20 07:50:55 +00:00
Xiao Ma
56c6392586 Merge "Move ipconfig file inside apex data directory" 2022-05-20 05:43:40 +00:00
TreeHugger Robot
0657071494 Merge changes I91e987d6,I03e7cda7 into tm-dev
* changes:
  Changing automotive ethernet allowed UIDs check
  Allow ethernet on automotive to set allowed UIDs
2022-05-20 03:29:14 +00:00
Patrick Rohr
47641d75d9 Move ipconfig file inside apex data directory
In order to support rollbacks, the ethernet ipconfig file needs to be
written to the data apex's data directory. We still need to support
reading from the legacy location to be backwards compatible.

If the apex file path already exists, then read the IP configuration
from there directly, otherwise, check if the legacy file path exists,
if yes, read the legacy IP configuration and copy it to the new apex
file path.

Support for default IpConfiguration is also being removed in this CL.
The default IpConfiguration (configuration entry for interface "0")
was a way to transition from supporting a single interface to
supporting multiple interfaces and was introduced in P. Every device
that has used such a configuration and has connected to an ethernet
network since upgrading to P+ has already removed the "0" config and
has assigned it to the first interface (probably "eth0"). There has
never been an API to set this, but if someone wanted to install a
default IpConfiguration, they could just configure "eth0" instead.

Bug: 224919694
Test: atest EthernetConfigStoreTest --iterations
Test: manually test
      - adb push <fake ipconfig.txt> /data/misc/ethernet/
      - adb reboot
      - read the IP config from legacy path and the same config
        file is created in the apex file path
      - adb reboot
      - read the IP config from the apex file path directly
Change-Id: Ifb82a5d7fa13d17ea8fd3a42a19cd020cb95e26a
2022-05-20 09:20:54 +09:00
James Mattis
a2ea68df28 Changing automotive ethernet allowed UIDs check
Updating the automotive allowed UIDs check to only work if the
capabilities have a single transport equal to ethernet.

CP of https://r.android.com/2101472

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I91e987d6b943a3c5986ab88553a6eef0d479b079
Merged-In: I91e987d6b943a3c5986ab88553a6eef0d479b079
2022-05-19 09:13:31 -07:00
Junyu Lai
f397add671 Merge changes from topic "stats-migration" into tm-dev am: ac6213123a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18486287

Change-Id: Ic8527bf901cb2a2ade80a623a363a27644ac5d32
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 14:55:26 +00:00
Lorenzo Colitti
6b98db3000 Don't clobber existing history entries. am: b36e57a004
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18453213

Change-Id: Ibc9975485b6b1a7d5240aefa9366e1f39b856450
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 14:55:25 +00:00
Remi NGUYEN VAN
7d5660982e Ensure NetworkStats migrated snapshot is identical am: 3776d862e2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18452103

Change-Id: I0266b4e2eea0e783db15024027efab1b16a7b13c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 14:55:24 +00:00
Junyu Lai
2eefcdcf0c [MS82.1] Support network stats data migration process am: 27e0a9833e
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18367994

Change-Id: I3e81555cd0871883571d925422b82d8fd7bdd10b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 14:55:21 +00:00
Lorenzo Colitti
e30044bb1f Add a PersistentInt class. am: 76c0f6f0e8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/18437645

Change-Id: I9497d4812ab9cafb42e2b6a0653f6094cbc18cfa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 14:55:19 +00:00
Junyu Lai
ac6213123a Merge changes from topic "stats-migration" into tm-dev
* 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-05-19 14:54:01 +00:00
James Mattis
45f3e41a6a Allow ethernet on automotive to set allowed UIDs
Allow ethernet factories on automotive devices to set the allowed UIDs
on NetworkCapabilities.

CP of https://r.android.com/2072767

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I03e7cda75f1c530e0d0e4a756330bc9847a96668
Merged-In: I03e7cda75f1c530e0d0e4a756330bc9847a96668
2022-05-19 07:48:05 -07:00
Treehugger Robot
e7f85a6d71 Merge "Changing automotive ethernet allowed UIDs check" am: 36cae536f0 am: fe4f42ff48
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2101472

Change-Id: I280093a80cdbc7add7bbeaf20bcb5adf09c90f9b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-19 14:17:46 +00:00
Treehugger Robot
36cae536f0 Merge "Changing automotive ethernet allowed UIDs check" 2022-05-19 13:29:16 +00:00
Junyu Lai
c3f7cabe59 Skip PersistentIntTest on S- device
This class is only used in the service runs on T+ devices.
Thus run this test on S- device does not make senses.

Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Test: atest ConnectivityCoverageTests:PersistentIntTest
      on S device
Change-Id: I97a29df17ef9ee9ab373655f045cdb5c820e06ef
2022-05-19 15:09:42 +08:00