Commit Graph

552 Commits

Author SHA1 Message Date
Xiao Ma
b60e77f257 Unicast state of existing ethernet interfaces when registering new Ethernet Listener.
When adding a listener via the addInterfaceStateListener API, the
expectation is that ethernet service calls that listener immediately
with a list of all interfaces and their respective state. However,
this doesn't work as expectation due to the EthernetManager stores
all registered listeners within one global service listener class,
the new registered listener will be invoked until the state of any
interface has changed.

Instead of storing all registered listeners within one global service
listener class, associate each new registered listener to an instance
of IEthernetServiceListener, and pass it to the EthernetService, that
will be invoked when iterating the state of all existing interfaces.

In order to avoid the scanning of all registered listeners, that would
be slow if there are lots of registered callbacks, moving the service
listener to the ListenerInfo class, where the service listener can
access the executor and listener passed from the caller naturely,
unnecessary to iterate the whole list.

Bug: 229125889
Test: atest android.net.cts.EthernetManagerTest --iterations
Change-Id: I111eba78d1066794c414ab5fb4a31258ea311413
(cherry picked from commit bb9a49cf72)
Merged-In: I111eba78d1066794c414ab5fb4a31258ea311413
2022-04-30 14:42:45 +00:00
Xiao Ma
bb9a49cf72 Unicast state of existing ethernet interfaces when registering new Ethernet Listener.
When adding a listener via the addInterfaceStateListener API, the
expectation is that ethernet service calls that listener immediately
with a list of all interfaces and their respective state. However,
this doesn't work as expectation due to the EthernetManager stores
all registered listeners within one global service listener class,
the new registered listener will be invoked until the state of any
interface has changed.

Instead of storing all registered listeners within one global service
listener class, associate each new registered listener to an instance
of IEthernetServiceListener, and pass it to the EthernetService, that
will be invoked when iterating the state of all existing interfaces.

In order to avoid the scanning of all registered listeners, that would
be slow if there are lots of registered callbacks, moving the service
listener to the ListenerInfo class, where the service listener can
access the executor and listener passed from the caller naturely,
unnecessary to iterate the whole list.

Bug: 229125889
Test: atest android.net.cts.EthernetManagerTest --iterations
Change-Id: I111eba78d1066794c414ab5fb4a31258ea311413
2022-04-28 18:59:44 +09:00
Aaron Huang
d79f543df0 Merge "Fix NullPointerException happens in dumpCheckin" am: 6b7e457988 am: 44a02af11a am: a4d60dd2ad
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2059628

Change-Id: If9933b6aad05abf79e85f9172ba6eb6f8492d648
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-20 06:12:50 +00:00
Junyu Lai
57fc24937a Merge "Fix NetworkTemplate generates non-metered carrier template" am: 481b2649f7 am: d3a90fb206 am: e6616d1c7c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2064758

Change-Id: If215ccdeb8b7161939efb5d4bd3d9c7f994450bd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-20 06:08:16 +00:00
Aaron Huang
6b7e457988 Merge "Fix NullPointerException happens in dumpCheckin" 2022-04-19 11:43:21 +00:00
Junyu Lai
481b2649f7 Merge "Fix NetworkTemplate generates non-metered carrier template" 2022-04-19 10:18:26 +00:00
Aaron Huang
c3a43b4063 Fix NullPointerException happens in dumpCheckin
Currently dumpCheckin passes a null object to create
the contructor of NetworkStatsCollection.Key but the
constructor requires non-null object. Thus, it caused
the NPE in dumpCheckin. To fix this exception, create
an NetworkIdentitySet() object instead of using an
null object.

Bug: 225131008
Bug: 226539404
Test: dumpsys netstats --checkin is fine
      FrameworksNetTests
Change-Id: I7f2dadf0647b3f42e0f667d96291d2ae37e23faf
2022-04-19 17:49:30 +08:00
Junyu Lai
74f7c8c907 Fix NetworkTemplate generates non-metered carrier template
From current design, NetworkPolicyManagerService should only
creates metered carrier/mobile templates. However, if someone
calls the hidden API interface or the template was created
before NetworkTemplate#Builder is published. The caller may
create a non-metered carrier template and persist into the
storage.

This CL elimates this possibility and mark non-metered carrier
template non-persistable, so devices could auto-recover from
this symptom after reboot.

Fix: 222382637
Test: TH
Change-Id: I5265e371b0126ce65c32fb09a6e04223afb3d286
2022-04-18 16:41:54 +08:00
junyulai
0f54d64db2 Make some NetworkStats APIs system-current
Move iterator and NetworkStats.Entry getters to system-current
according to API council feedback. This reverts parts of
ag/17117903.

Test: TH
Fix: 225168182
  (cherry-picked from ag/17397294)
Change-Id: Ia7fdf8d31a96a26b0bf1682f462292b051560477
Merged-In: Ia7fdf8d31a96a26b0bf1682f462292b051560477
2022-04-11 18:45:36 +08:00
junyulai
44e61e2140 [MS83.1] Make some APIs module-lib instead of system current
Some of the internal classes are not available for priv-apps.
Thus, make them module-lib instead.

This change also adds some nullability annotations for existing
APIs according to go/android-api-guidelines.

Test: m
Test: m frameworks-base-api-system-current-compat
Fix: 217479745
  (cherry-picked from ag/17117903)
Change-Id: I18de46b11df7232ab82b9465856fdde621283156
Merged-In: I18de46b11df7232ab82b9465856fdde621283156
Merged-In: Ief3f2304f11b7940a18b98b8533fbca85ffa4dc1
2022-04-11 18:44:20 +08:00
Paul Hu
ac780d3bd0 Merge changes from topic "MDns_AIDL" am: 09475308b7 am: 06e59627bb
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2049246

Change-Id: I16b7ec71fbfee1dd0de84b1f64d5e9fbbd62f4e3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-07 03:10:55 +00:00
Paul Hu
09475308b7 Merge changes from topic "MDns_AIDL"
* changes:
  Use MDns aidl on NsdService
  Add MDnsManager
2022-04-07 02:06:35 +00:00
Maciej Żenczykowski
8a43622447 Merge changes Iafa8979d,I44eac159,I27ad3298 am: 6097358382 am: ec84e33d10
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2042596

Change-Id: I8f6867128057d092e916515049078c1d68b427a4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-06 01:20:45 +00:00
paulhu
2b9ed95ae5 Use MDns aidl on NsdService
- Use MDns aidl to communicate with mdns service and register
  event listener to receive callback.
- Remove all NDC relevant code on NsdService.
- Use MDns aidl on NsdServiceTest.

Bug: 209894875
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I65929dee3838fef753396e86c665abd66b6fec81
2022-04-04 15:18:27 +00:00
paulhu
541b72d03b Add MDnsManager
- Have MDnsManager to manage mdns native service binder call.
- Register it as a system service for NsdService.
- NsdService will use aidl to communicate with mdns, so add the
  relevant lib to framework-connectivity
- Add jarjar rule for mdns-aidl-interface classes.

Bug: 209894875
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: Ibc8b726c01a15015b450caf94d0afed570117b7f
2022-04-04 15:02:17 +00:00
Patrick Rohr
50c470e308 Address EthernetManager javadoc review comments
Test: TH
Change-Id: Iafa8979d8e96ea4d078b017e56ee61334d33b5f5
2022-04-04 14:59:42 +02:00
Patrick Rohr
0f2cbe92f1 Update javadoc to match expectation for UnsupportedOperationException
Test: builds
Change-Id: I44eac15972ed099fc12599a78a71557a7b16d593
2022-04-04 14:59:42 +02:00
junyulai
6801690383 Make some NetworkStats APIs system-current
Move iterator and NetworkStats.Entry getters to system-current
according to API council feedback. This reverts parts of
ag/17117903.

Ignore-AOSP-First: Parent CLs does not exist in aosp yet.
Test: TH
Fix: 225168182
Change-Id: Ia7fdf8d31a96a26b0bf1682f462292b051560477
2022-03-30 09:38:11 +00:00
Patrick Rohr
e38626a4a2 Merge "Add getInterfaceList module-lib API in EthernetManager." 2022-03-24 06:15:43 +00:00
Patrick Rohr
95738f7c18 Merge "Fix ethernet enable / disable API" 2022-03-24 06:09:28 +00:00
Xiao Ma
1edd4554e5 Add getInterfaceList module-lib API in EthernetManager.
Bug: 171872016
Test: m
Merged-In: Ib0e6c8f67c6ded7d17bb9e0ff49e7ff495c8819d
Change-Id: I94fd147d0f8cf09cb7445fd2b5bc8e4528e8390e
2022-03-22 13:59:40 +00:00
markchien
5912ab6906 Add setEthernetEnabled and its listener API
Bug: 171872016
Test: atest EthernetServiceTests

Merged-In: Iefd24d955572589c5bd3ca9a8139ea6e44979e8a
Change-Id: Iefd24d955572589c5bd3ca9a8139ea6e44979e8a
2022-03-22 13:58:14 +00:00
Aaron Huang
286f4e2c88 Merge "Fix proto invalid write type" 2022-03-22 12:18:39 +00:00
Patrick Rohr
3879cf1a78 Fix ethernet enable / disable API
The ethernet APIs connectNetwork() / disconnectNetwork() are
inaccurately named. Physical link state cannot be changed by calling an
API. This change renames these functions to enableInterface and
disableInterface, respectively, to better reflect their intention and
behavior.

Test: atest EthernetManagerPermissionTest
Merged-In: I3361ad0e01e761ffd77faf6c55924fa4612ede90
Change-Id: I3361ad0e01e761ffd77faf6c55924fa4612ede90
2022-03-22 12:12:48 +00:00
Patrick Rohr
4e6570c359 Merge "Revert^2 "Change Ethernet API to use OutcomeReceiver"" 2022-03-22 10:00:08 +00:00
Remi NGUYEN VAN
d12566508b Merge "Add Executors to NSD callbacks" am: 009094b070 am: 34759d1685 am: 801152830c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2027063

Change-Id: Ief40c29dce0484983f95d66d8506a24b35a46b30
2022-03-22 09:46:03 +00:00
Remi NGUYEN VAN
8d0fa1c2ad Merge "Add Executors to NSD callbacks" 2022-03-22 08:33:48 +00:00
Remi NGUYEN VAN
009094b070 Merge "Add Executors to NSD callbacks" 2022-03-22 08:33:48 +00:00
Xiao Ma
3abd1033d2 Merge "Add getInterfaceList module-lib API in EthernetManager." into tm-dev 2022-03-18 13:00:01 +00:00
Mark Chien
7fd5a98d6a Merge "Add setEthernetEnabled and its listener API" into tm-dev 2022-03-18 11:43:52 +00:00
Remi NGUYEN VAN
c7aa9e3c62 Add Executors to NSD callbacks
Add Executor variants to all methods with callbacks.

Bug: 218752665
Test: atest NsdManagerTest
Change-Id: I4c31e2d7ae601ea808b1fd64df32d116c6fff97f
2022-03-18 09:26:11 +00:00
Remi NGUYEN VAN
1d36db9653 Add Executors to NSD callbacks
Add Executor variants to all methods with callbacks.

Bug: 218752665
Test: atest NsdManagerTest
Change-Id: I4c31e2d7ae601ea808b1fd64df32d116c6fff97f
2022-03-18 09:26:11 +00:00
Xiao Ma
217c99da20 Add getInterfaceList module-lib API in EthernetManager.
Bug: 171872016
Test: m
Change-Id: Ib0e6c8f67c6ded7d17bb9e0ff49e7ff495c8819d
2022-03-18 17:18:54 +09:00
markchien
db9e89aa7b Add setEthernetEnabled and its listener API
Bug: 171872016
Test: atest EthernetServiceTests

Change-Id: Iefd24d955572589c5bd3ca9a8139ea6e44979e8a
2022-03-18 17:12:56 +09:00
Patrick Rohr
dceb895995 Fix ethernet enable / disable API
The ethernet APIs connectNetwork() / disconnectNetwork() are
inaccurately named. Physical link state cannot be changed by calling an
API. This change renames these functions to enableInterface and
disableInterface, respectively, to better reflect their intention and
behavior.

Test: atest EthernetManagerPermissionTest
Ignore-AOSP-First: CP to make automerger happy.
Change-Id: I3361ad0e01e761ffd77faf6c55924fa4612ede90
2022-03-18 07:24:01 +00:00
Patrick Rohr
58b2dffa1c Change Ethernet API to use OutcomeReceiver
This change addresses API review feedback. In addition, it changes the
returned result from Network to the interface name. The current API
returning a Network object is racy and cannot be implemented correctly.
Users should instead use the ConnectivityManager#requestNetwork() API to
get hold of the Network for a given interface.

Bug: 220017952
Test: TH
Ignore-AOSP-First: CP to make automerger happy.
Change-Id: I7c46545a47034be409071c2ec007d9e1480c6ed0
2022-03-18 12:19:52 +08:00
Patrick Rohr
d6156a930e Revert^2 "Change Ethernet API to use OutcomeReceiver"
369c79bca4

Merged-In: I7c46545a47034be409071c2ec007d9e1480c6ed0
Change-Id: If9b055e0862755f1d33b5ba6e026fd827bc1d0ea
2022-03-18 12:06:27 +08:00
Quentin Perret
eac786e2ff Merge "Revert "Change Ethernet API to use OutcomeReceiver"" am: 8efc170b0b am: 4f24e69879 am: 8ee0c2bbc4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2030086

Change-Id: I063096a6502f8b8536e797ab30b0be09ae7401b8
2022-03-17 17:02:48 +00:00
Quentin Perret
369c79bca4 Revert "Change Ethernet API to use OutcomeReceiver"
Revert "Change network management listener to outcome receiver"

Revert submission 2028203-ethernet-outcomereceiver

Reason for revert: BuildMonitor investigating b/225169800
Reverted Changes:
I4c204a848:Change Ethernet API to use OutcomeReceiver
I7c46545a4:Change Ethernet API to use OutcomeReceiver
Id8fadfed9:Change network management listener to outcome rece...

Change-Id: I45af594f7233ed89113f4cf7f977092271980672
2022-03-17 15:20:53 +00:00
Quentin Perret
7844d41513 Revert "Change Ethernet API to use OutcomeReceiver"
Revert "Change network management listener to outcome receiver"

Revert submission 2028203-ethernet-outcomereceiver

Reason for revert: BuildMonitor investigating b/225169800
Reverted Changes:
I4c204a848:Change Ethernet API to use OutcomeReceiver
I7c46545a4:Change Ethernet API to use OutcomeReceiver
Id8fadfed9:Change network management listener to outcome rece...

Change-Id: I45af594f7233ed89113f4cf7f977092271980672
2022-03-17 15:20:53 +00:00
Patrick Rohr
a5a7bd70c7 Merge "Change Ethernet API to use OutcomeReceiver" am: a7b1911815 am: b12e08bdfe am: 7e9fe04fb9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2028164

Change-Id: I3161e6e7022eaa30e89e3322bcf6298f48753f00
2022-03-17 14:53:24 +00:00
Patrick Rohr
8d59ceeb28 Merge "Add Nullable IpConfiguration to ethernet update request" am: bc1479af8f am: f95355f826 am: d520904a20
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2025283

Change-Id: Ib2e58c9e451b51ed80136bba585a098bc0ddb45a
2022-03-17 08:13:57 +00:00
Patrick Rohr
cf01b8a4f7 Change Ethernet API to use OutcomeReceiver
This change addresses API review feedback. In addition, it changes the
returned result from Network to the interface name. The current API
returning a Network object is racy and cannot be implemented correctly.
Users should instead use the ConnectivityManager#requestNetwork() API to
get hold of the Network for a given interface.

Bug: 220017952
Test: TH
Change-Id: I7c46545a47034be409071c2ec007d9e1480c6ed0
2022-03-17 08:20:45 +01:00
Patrick Rohr
77a3a8408b Change Ethernet API to use OutcomeReceiver
This change addresses API review feedback. In addition, it changes the
returned result from Network to the interface name. The current API
returning a Network object is racy and cannot be implemented correctly.
Users should instead use the ConnectivityManager#requestNetwork() API to
get hold of the Network for a given interface.

Bug: 220017952
Test: TH
Change-Id: I7c46545a47034be409071c2ec007d9e1480c6ed0
2022-03-17 08:20:45 +01:00
Junyu Lai
7a01fb6c68 Merge "[MS83.1] Make some APIs module-lib instead of system current" into tm-dev 2022-03-17 01:50:14 +00:00
Patrick Rohr
746d082279 Add Nullable IpConfiguration to ethernet update request
This is not currently used by anyone, but will allow us to only update
NetworkCapabilities in the future. This could be useful for testing.

Test: atest EthernetServiceTests
Bug: 220017952
Change-Id: I9697399bad2bfe66c6f328064be75f4dfa10af81
2022-03-16 20:28:45 +01:00
Patrick Rohr
7215598852 Add Nullable IpConfiguration to ethernet update request
This is not currently used by anyone, but will allow us to only update
NetworkCapabilities in the future. This could be useful for testing.

Test: atest EthernetServiceTests
Bug: 220017952
Change-Id: I9697399bad2bfe66c6f328064be75f4dfa10af81
2022-03-16 20:28:45 +01:00
Patrick Rohr
112f3762bb Merge "Split out the ethernet API surface and use framework-connectivity-t" 2022-03-16 16:03:30 +00:00
Patrick Rohr
cbcf21833f Merge "Split out the ethernet API surface and use framework-connectivity-t" 2022-03-16 16:03:30 +00:00
Frank Li
a89e379e00 Merge "[DU04-2]Appropriate changes to the NetworkPolicyManager API" am: 73c476d79d am: 8c4e592d2e am: f946d59035
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2007132

Change-Id: I7e5dc71e1705a7c205c0fd6a7cb57e75cae5a4fc
2022-03-16 13:20:10 +00:00