Commit Graph

866 Commits

Author SHA1 Message Date
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
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
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
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
James Mattis
4eff0efb57 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.

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I91e987d6b943a3c5986ab88553a6eef0d479b079
2022-05-18 22:18:14 -07:00
Xiao Ma
9cae3c8a99 Fix the ethernet setting API bug.
After turning off the ethernet settings via api, the ethernet service
can still be started when plugging-in the cable. Improve the api by
ignoring the upcoming interface unsolicited event listener callbacks
and register new interface observer once the ethernet setting is enabled
again.

Bug: 231933028
Test: atest testListenEthernetStateChange_unsolicitedEventListener
Change-Id: I1b1cb7d157f023fca82d75592168bd360a6fa6e1
(cherry picked from commit 94a00dfc64)
Merged-In: I1b1cb7d157f023fca82d75592168bd360a6fa6e1
2022-05-19 01:58:15 +00:00
Patrick Rohr
473b5411e2 Merge "Fix the ethernet setting API bug." am: 493ce14eaf am: 4fbfc8b270
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2099112

Change-Id: Ic998f930fcf57d04c04089ea5a7e919325b8acdf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 21:30:57 +00:00
Lorenzo Colitti
b36e57a004 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.

Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Test: manually verified this unbreaks the importer
Change-Id: Ic8647ff28fca78d579d5f759f96a864877f8158b
2022-05-18 23:51:03 +08:00
Remi NGUYEN VAN
3776d862e2 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.

Ignore-AOSP-First: in a topic with internal-only changes
Test: NetworkStatsServiceTest
Bug: 230289468
Change-Id: I857ad18183d63d1aa16e89f89eb24009648720a2
2022-05-18 23:51:03 +08:00
Junyu Lai
27e0a9833e [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
Ignore-AOSP-First: in a topic with internal-only changes
Bug: 230289468
Change-Id: Ic2002cbfd5a6b3c2226fa8dab22481f8ce656574
2022-05-18 23:34:30 +08:00
Lorenzo Colitti
76c0f6f0e8 Add a PersistentInt class.
This implements a simple integer written to disk backed by
AtomicFile.

Bug: 230289468
Test: new unit test
Ignore-AOSP-First: in a topic with internal-only changes
Change-Id: I1c73c8ac2429f92153cfba3b006b4374e75e65df
2022-05-18 20:54:50 +08:00
Xiao Ma
94a00dfc64 Fix the ethernet setting API bug.
After turning off the ethernet settings via api, the ethernet service
can still be started when plugging-in the cable. Improve the api by
ignoring the upcoming interface unsolicited event listener callbacks
and register new interface observer once the ethernet setting is enabled
again.

Bug: 231933028
Test: atest testListenEthernetStateChange_unsolicitedEventListener
Change-Id: I1b1cb7d157f023fca82d75592168bd360a6fa6e1
2022-05-18 17:23:32 +09:00
Treehugger Robot
caf8c958ed Merge changes I03e7cda7,I675c4ef5 am: af7101ff0f am: ec586c6cdb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2072767

Change-Id: I7e55796d79e6a88ae2a43f7851ef8bccc6ccea04
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 04:07:26 +00:00
Lorenzo Colitti
327eb4d6ca Merge changes from topics "cherrypicker-L31300000954565189:N38500001265926579", "cherrypicker-L33500000954572563:N23000001265907389", "cherrypicker-L61500000954569605:N47200001265868358" into tm-dev
* changes:
  Block incoming packets in VPN Lockdown mode.
  Refactor VPN interface filtering necessity check
  Support 32 match types in UidOwnerValue rule
2022-05-17 23:40:57 +00:00
James Mattis
46491d7546 Allow ethernet on automotive to set allowed UIDs
Allow ethernet factories on automotive devices to set the allowed UIDs
on NetworkCapabilities.

Bug: 229419469
Test: atest FrameworksNetTests
Change-Id: I03e7cda75f1c530e0d0e4a756330bc9847a96668
2022-05-17 15:32:13 -07:00
Junyu Lai
9a0f148675 Merge "Limit data usage request per uid" into tm-dev 2022-05-17 09:57:16 +00:00
Motomu Utsumi
966ff7f82a Block incoming packets in VPN Lockdown mode.
Currently, even when VPN Lockdown mode is enabled, incoming packets are
not dropped if VPN is not connected.

This commit fixed this issue.
After this commit, If VPN Lockdown mode is enabled, incoming packets
are dropped regardless of the VPN connectivity.

Bug: 206482423
Test: atest TrafficControllerTest ConnectivityServiceTest PermissionMonitorTest
Change-Id: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d
(cherry picked from commit b08654ca04)
Merged-In: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d
2022-05-17 09:35:28 +00:00
Motomu Utsumi
1f96b8833d Merge changes If52ece61,Iedf344f6 am: f6131c483b am: 9d6decd77f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2095365

Change-Id: I6b73daf579d926f693ccb741615092b69200b82f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-17 02:45:29 +00:00
Motomu Utsumi
b08654ca04 Block incoming packets in VPN Lockdown mode.
Currently, even when VPN Lockdown mode is enabled, incoming packets are
not dropped if VPN is not connected.

This commit fixed this issue.
After this commit, If VPN Lockdown mode is enabled, incoming packets
are dropped regardless of the VPN connectivity.

Bug: 206482423
Test: atest TrafficControllerTest ConnectivityServiceTest PermissionMonitorTest
Change-Id: If52ece613c8aac1073355e43b6fb9cb3fcc87d1d
2022-05-16 10:40:59 +00:00
Junyu Lai
108d20f84a [MS81] Support remove history before cutoff timestamp
This is needed to ensure corrupted data can be clean up if
the data migration process dones't go well.

Test: NetworkStatsCollectionTest
Bug: 197717846
Change-Id: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
(cherry picked from commit 306a00316c)
Merged-In: Ic76ad6f3e96f03791b48988fb2622c9c647ffc7c
2022-05-16 05:53:02 +00:00
Junyu Lai
165be7bf70 Merge "[MS81] Support remove history before cutoff timestamp" am: ac557274c1 am: 97dbe871a5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2061368

Change-Id: I32f548eeb154ab3182b56d2c490325fa7c3f4648
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-14 00:01:24 +00:00
Junyu Lai
ac557274c1 Merge "[MS81] Support remove history before cutoff timestamp" 2022-05-13 22:40:32 +00:00
Junyu Lai
702e0f3deb Merge "Limit data usage request per uid" am: fc938cf026 am: 26acc088a5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2085772

Change-Id: I8a9bee88f0f8ddec5f19b8bf5ce05d110d3f5aca
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-13 10:20:59 +00:00
Junyu Lai
6621705f83 Limit data usage request per uid
Currently, there is no limtation for an app to request
data usage callback, which is dangerous if the app fire
hundreds of thousands requests and potientially this might
cause OOM if the apps don't free them.

Test: atest NetworkStatsObserversTest#testRegister_limit
Bug: 229103088
Change-Id: I8299f46fd47a82ec9b25ba2e0d3c95db5512c331
(cherry picked from commit f3c946278c)
Merged-In: I8299f46fd47a82ec9b25ba2e0d3c95db5512c331
2022-05-13 10:01:07 +00:00
Junyu Lai
fc938cf026 Merge "Limit data usage request per uid" 2022-05-13 09:06:41 +00:00
Chiachang
bc65e7e992 Address leftover comments
This is a follow-up commit from aosp/2076483. Mainly to update:
1. Update the hex string to human understandable code instead of
   byte code.
2. Use IgnoreUpTo() to do the SDK check
3. Avoid relying on the code being tested

Bug: 192078259
Test: atest FrameworksNetTests
Change-Id: I8973d248a1d30fdcb597677dbf051e146041f905
(cherry picked from commit a023f88193)
Merged-In: I8973d248a1d30fdcb597677dbf051e146041f905
2022-05-13 03:01:50 +00:00
chiachangwang
f2897b8a93 Test [set|get]AppExclusionList
Bug: 192078259
Test: atest FrameworksNetTests
Change-Id: Iee81d84b4127420121ce2d5a7defc3dbe34b6cde
(cherry picked from commit 218d5652de)
Merged-In: Iee81d84b4127420121ce2d5a7defc3dbe34b6cde
2022-05-13 02:47:56 +00:00
Hungming Chen
2a1430893e Revert "Open and close clat bpf map while clat is starting and stoping" am: b135921ed7 am: e5f50f95d3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2092304

Change-Id: I0f95fbb9cddd7b63c2569c954ea2d35ee8614e48
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 14:28:40 +00:00
Hungming Chen
6f2fa97132 Revert "ClatCoordinator: replace BpfMap with IBpfMap" am: 9416307fa1 am: c88f684b8f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2092303

Change-Id: I55dfa80bc07273f797a506510ecf43b71788ec1b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 14:28:34 +00:00