Commit Graph

93 Commits

Author SHA1 Message Date
Chiachang Wang
a03cf172bb Add null check for the taken callback am: c57eb8c6ad
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1802597

Change-Id: I8fe9b5918e2af72d6edd7ae334f6062e32bbfdad
2021-08-20 05:13:41 +00:00
Chiachang Wang
c57eb8c6ad Add null check for the taken callback
The requestTetheredInterface() and releaseTetheredInterface() in
EthernetManager is annotated as @NonNull. Basically, the taken
callback parameter to the service implementation should also be
@NonNull. However, it still possible to use native commands to
call the method in the aidl. If a null callback is taken, it may
cause unexpected results and cause crashes. Add a null check and
throw NPE as a warning.

Bug: 190058445
Test: adb commands
Change-Id: I18fd63aba3f7326597fc3a8c93ba8c9097bf7348
2021-08-20 03:40:29 +00:00
Ady Abraham
089b5546c3 Merge "Revert "Set EthernetNetworkSpecifier on each ethernet network for multi-ethernet"" 2021-08-12 18:16:07 +00:00
Ady Abraham
7a4fecc3de Revert "Set EthernetNetworkSpecifier on each ethernet network for multi-ethernet"
This reverts commit b94c4e7453.

Reason for revert: b/196387077

Change-Id: I8e27ce915b6069b642c614a018aa5e1788ae07af
2021-08-12 17:16:51 +00:00
Treehugger Robot
f7059e69ba Merge "Set EthernetNetworkSpecifier on each ethernet network for multi-ethernet" 2021-08-12 03:13:50 +00:00
Patrick Rohr
3ed5c3997b Remove Unused Code From EthernetNetworkFactory am: 698b59510f am: e7048826ba
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1722876

Change-Id: I2a4f5caa041f6b0e6f950e536ab74be71a5a2a53
2021-07-29 09:27:55 +00:00
Milim Lee
b94c4e7453 Set EthernetNetworkSpecifier on each ethernet network for multi-ethernet
Bug: 175199512
Test: Build and test multi-ethernet
Change-Id: I6ec50b42bee89520f6f27d40e0d2b0d774b8e2e5
2021-07-29 13:41:18 +09:00
Patrick Rohr
98958bbabf Add Tests for EthernetNetworkFactory am: e78e8828d6 am: f5e25fcc5d
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1486182

Change-Id: Id09046b501b7b280830e51d5b82f2d5e8f7fa6d7
2021-07-28 14:18:22 +00:00
Patrick Rohr
698b59510f Remove Unused Code From EthernetNetworkFactory
Test: atest EthernetNetworkFactoryTest
Change-Id: Ibe0190b3108dca644da2d67bd107954cb26f41ce
2021-07-28 14:22:41 +02:00
Patrick Rohr
e78e8828d6 Add Tests for EthernetNetworkFactory
Test: atest EthernetNetworkFactoryTest
Bug: 191635995
Change-Id: I1c07bb6d30706c4e13002eb402fadfecb97b36d1
2021-07-28 14:22:41 +02:00
Lorenzo Colitti
e30816d4ed Merge "Stop using LinkPropertiesParcelableUtil." am: 0b58e409a1 am: a04fb395b6
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1733473

Change-Id: I51829f89466e518712f117675eef40792577ece3
2021-06-21 10:34:48 +00:00
Lorenzo Colitti
0e077cb1d5 Stop using LinkPropertiesParcelableUtil.
Its methods are all no-ops. Stop using them.

Test: m
Bug: 151052811
Change-Id: Iace3ba898bec2940ec3c3323c5bf8a13627d545f
2021-06-12 00:42:24 +09:00
Chiachang Wang
bbd8b43c93 Replace clearAll with withoutDefaultCapabilities in NC#Builder
Update the naming and usgae according to API review feedback.

Bug: 184735772
Test: atest EthernetTrackerTest
Change-Id: Ie8dc0bcdf46ceebda5d6062231b48c1f63b250f6
Merged-In: Ie8dc0bcdf46ceebda5d6062231b48c1f63b250f6
2021-05-14 10:36:56 +00:00
Chiachang Wang
6d8141caa1 Replace clearAll with withoutDefaultCapabilities in NC#Builder
Update the naming and usgae according to API review feedback.

Bug: 184735772
Test: atest EthernetTrackerTest
Change-Id: Ie8dc0bcdf46ceebda5d6062231b48c1f63b250f6
2021-05-14 14:24:21 +08:00
lucaslin
fe134fbd9c Add transport type in capabilities filter of EthernetNetworkFacotry
Bug: 167544279
Test: atest EthernetServiceTests
Change-Id: Ie64e3cff0ace413f14682736de7a1b65fa93e705
Merged-In: Ie64e3cff0ace413f14682736de7a1b65fa93e705
    (Cherry-picked from ag/14031548)
2021-05-05 05:11:49 +00:00
paulhu
3056b7418b Enforce ACCESS_NETWORK_STATE to getAvailableInterfaces()
getAvailableInterfaces() will return available ethernet
interfaces which are the information about networks. So it should
enforce ACCESS_NETWORK_STATE permission check to ensure the
applications are allowed to access the information.

Bug: 174573778
Test: TetheringTests
Test: CtsTetheringTest
Change-Id: I7aaa5225d56f2feecc51ba263489ed0ce02fd651
2021-04-26 06:05:39 +00:00
lucaslin
4450c1542b Add transport type in capabilities filter of EthernetNetworkFacotry
Bug: 167544279
Test: atest EthernetServiceTests
Change-Id: Ie64e3cff0ace413f14682736de7a1b65fa93e705
2021-03-30 16:54:45 +08:00
lucaslin
19b7b3dfbd Use public API instead of hidden API in EthernetTracker
- Use public API of StaticIpConfiguration.Builder to set
ipaddress, domains, gateway and dnsServers.
- Use public constructor to create an instance of IpConfiguration
and set IpAssignment, ProxySettings, StaticIpConfiguration and
HttpProxy by public API.

Bug: 182963415
Test: m ethernet-service
Change-Id: Idce8bfe7afc31baa644c816afa1f8004987e8c6e
Merged-In: Idce8bfe7afc31baa644c816afa1f8004987e8c6e
2021-03-23 09:45:57 +00:00
Lucas Lin
06e1c17103 Merge "Use public API instead of hidden API in EthernetTracker" into sc-dev 2021-03-19 11:23:01 +00:00
lucaslin
4a0cbe98c1 Use public API instead of hidden API in EthernetTracker
- Use public API of StaticIpConfiguration.Builder to set
ipaddress, domains, gateway and dnsServers.
- Use public constructor to create an instance of IpConfiguration
and set IpAssignment, ProxySettings, StaticIpConfiguration and
HttpProxy by public API.

Bug: 182963415
Test: m ethernet-service
Change-Id: Idce8bfe7afc31baa644c816afa1f8004987e8c6e
2021-03-19 15:14:23 +08:00
junyulai
c439eae5b4 Replace reference of NetworkAgent#setLegacyExtraInfo
Bug: 182963415
Test: m ethernet-service
Test: atest EthernetServiceTests
Change-Id: I4a66f34daa129b3158e4dd2fb720c175611eaf69
2021-03-19 14:15:39 +08:00
junyulai
89764da132 Replace references of request.networkCapabilies
Replaced by request.canBesatisfiedBy() to avoid direct reference
of hidden member.

Bug: 182963415
Test: m ethernet-service
Test: atest EthernetServiceTests
Change-Id: I2a27410a6148c525e17a11cb1ba3570f04e60b5d
2021-03-19 14:13:19 +08:00
lucaslin
df51759103 Use clearAll() of NetworkCapabilities.Builder instead
NetworkCapabilities#clearAll() is a hidden API, use clearAll()
of NetworkCapabilities.Builder instead.

Bug: 182963415
Test: m ethernet-service
Test: atest EthernetServiceTests
Change-Id: I87745b5f7a5817f95cdbc623b2313c181ff48f19
2021-03-18 14:45:22 +08:00
Remi NGUYEN VAN
ddbc35510e Merge "Rename StringNetworkSpecifier to Ethernet" 2021-03-11 23:51:49 +00:00
Frank Li
35a6de8db3 Merge "[CS09]Remove hidden API usage of NetworkRequest" 2021-03-11 15:56:55 +00:00
lifr
60ce2ec168 [CS09]Remove hidden API usage of NetworkRequest
The connection service will become the mainline module.
So, need to remove the hidden API usage of NetworkRequest.
The NetworkRequest.type(TRACK_DEFAULT) is no longer sent
to the factories. So, remove the (TRACK_DEFAULT) check to
avoid using hidden API.

Bug: 170598012
Test: atest EthernetServiceTests
Change-Id: I5b5fed864318e9ac7e190c40d4f52076ab0eece8
2021-03-11 23:55:04 +08:00
Remi NGUYEN VAN
a837199195 Rename StringNetworkSpecifier to Ethernet
The new specifier represents ethernet interfaces more
specifically and is part of the public API.

Bug: 179329291
Test: atest CtsNetTestCases
Merged-In: I6cba1709b3007a22d95849a1281237c77e1464a4
Change-Id: I6cba1709b3007a22d95849a1281237c77e1464a4
2021-03-10 09:20:39 +09:00
lifr
89f2f50aee [CS07]Remove hidden API usage of NetworkCapabilities
The connection service will become the mainline module. The mutable
NetworkCapabilities is deprecated, and the NetworkCapabilities should
be built through their Builder instead.

Bug: 170598012
Test: atest EthernetServiceTests
Change-Id: I09661ddda24d652ed791a7c6b093541e20a15e77
2021-03-05 16:45:48 +08:00
lifr
810d8f0c94 [CS02]Remove hidden API usage of NetworkCapabilities
The connection service will become the mainline module. The mutable
NetworkCapabilities is deprecated, and the NetworkCapabilities should
be built through their Builder instead.

Bug: 170598012
Test: atest EthernetServiceTests
Change-Id: I31f12a39a924302beca980b8d920e3c5c18816d4
2021-02-09 20:45:09 +08:00
Lucas Lin
ab2e555c99 Merge "Replace the usage of NetworkManagementService with NetdUtils" 2021-02-02 03:38:37 +00:00
junyulai
c8148a18d0 [VCN07.4] Add NOT_VCN_MANAGED for NetworkAgent implementations
Follow-up from aosp/1549897, the capability will not be in
default capabilities, but will be in most of the NetworkRequests
which requires internet. Thus, add the capabilities into all
NetworkAgent implementations by default to provide
backward compatibility.

Test: TH
Bug: 175662146
Change-Id: Ib6e203571946e3094e4ce534b108f796cc3b8fb7
2021-01-28 14:52:12 +08:00
lucaslin
88f4df8e0f Replace the usage of NetworkManagementService with NetdUtils
Since NetdUtils has the same method(setInterfaceUp) as
NetworkManagementService, replace the usage of NMS with NetdUtils.

Bug: 170598012
Test: atest EthernetServiceTests
Change-Id: Id0f8e17e9d6237fa8ab157c96dd982c47007a453
2021-01-26 08:42:18 +00:00
Chalard Jean
be2858b9da [NS01.eth] Remove a useless argument
Test: FrameworksNetTests
Change-Id: Ib262871e4909ae65b5e6b2e52d2f25bf5a653f34
2021-01-12 16:29:55 +09:00
Remi NGUYEN VAN
1849ebd9c3 Add TRANSPORT_TEST to test ethernet interfaces
Because they operate on test interfaces, ethernet interfaces included
with setIncludeTestInterfaces should have TRANSPORT_TEST.

Bug: 156319532
Test: atest CaptivePortalApiTest
Change-Id: Ife3eab06432cabf3ee626de49abc31c8349b4316
2020-05-27 12:35:40 +09:00
Chalard Jean
bddcfc0c48 Add capability they should always have to eth networks.
There is a stopgap hack in ConnectivityService doing
this automatically, but individual agents should be doing
this themselves.

Test: FrameworksNetTests NetworkStackTests
Bug: 150570873
Change-Id: I6f75e2b26eb9f554243bc418142a4dc18839aa79
2020-05-11 11:21:15 +09:00
Chalard Jean
4b9a7dd13d Address further API council comments.
Test: FrameworksNetTests NetworkStackTests
Bug: 152238712
Copy from ag/10857997
Change-Id: I7c27f76c54a76abeae46dcdcddaeb3ca48afa358
Merged-In: I7c27f76c54a76abeae46dcdcddaeb3ca48afa358
2020-04-01 11:04:18 +00:00
Chalard Jean
86aac0daec Convert the Ethernet factory to the new network agent
This is a combination of ag/10147368 and ag/10438581.
ag/10147368 implemented this conversion together with
using the planned NetworkScore API, while ag/10438581
reverted the parts that had to do with NetworkScore.
This is just a squash of these two patches and it
brings the factory in line with the code in rvc-dev.

Test: FrameworksNetTests NetworkStackTests EthernetTetheringTest
Change-Id: Ib214fbbd042f2c0ebd01cf5b0ec33d922629677e
Merged-In: Ie7b70750ef0e17141080f4266dea6155c3601569
2020-04-01 09:09:32 +00:00
Lorenzo Colitti
dd397f58c7 Fix querying Ethernet availability for unprivileged callers.
Both EthernetManager#getAvailableInterfaces() and the no-arg
version of EthernetManager#isAvailable() end up calling
EthernetServiceImpl#getAvailableInterfaces. This method attempts
to filter out restricted interfaces if the caller does not have
the CONNECTIVITY_USE_RESTRICTED_NETWORKS permission.

Unfortunately EthernetNetworkFactory's notion of a restricted
interface is the opposite of what it should be. This means that
while privileged callers can see all interfaces, unprivileged
callers can only see restricted interfaces which they cannot use.

Fix this by correcting NetworkInterfaceState#isRestricted(), so
that unprivileged callers can see only unrestricted interfaces.
Privileged callers are unaffected.

This bug probably went unnoticed because restricted Ethernet
interfaces are rare (likely used only on auto devices) and
because the callers that care about those restricted interfaces
are generally privileged.

Bug: 148824036
Test: atest android.net.EthernetTetheringTest#testPhysicalEthernet
Change-Id: Idff3b05a193a80c581d80d0e4fe9c2d3fc0d8a25
2020-03-26 22:53:10 +09:00
Lorenzo Colitti
bd66333a24 Don't call maybeTrackInterface on the wrong thread.
Bug: 150644681
Test: atest TetheringIntegrationTests:EthernetTetheringTest --rerun-until-failure 100
Change-Id: Ia2cb265f8d4de96210f1462339c10ad2947eec65
2020-03-26 17:02:27 +09:00
Lorenzo Colitti
165b456d92 Send tethered interface callbacks based on interface existence.
Currently, callbacks for tethered interface availability are sent
based on interface link state. This is incorrect:

- It is acceptable and expected to be able to enable tethering on
  an interface that does not yet have link up.
- It doesn't seem useful to disable Ethernet tethering if link
  temporarily goes down.

Instead, only base the callbacks on whether an interface exists
or not.

Bug: 150644681
Test: WIP tests in aosp/1260100 pass
Change-Id: I015219cbd03626c38fb5156d0cb2991ba7d7def7
2020-03-19 22:12:32 +09:00
Lorenzo Colitti
e81f99d532 Support setting the default interface to null again.
Currently, the default interface can only ever go from null to
non-null. This is correct for fixed interfaces (because they
don't get unplugged) and it's generally correct for USB
interfaces that use ethX as their device name (because when
they are unplugged and plugged in again, the device name won't
change). But it is not correct if, for example, the default
interface is a test interface. So, allow mDefaultInterface to go
back to null.

This CL also fixes a crash if a tethered interface request is
added and removed when there is no default interface.

Also, make dump() report tethered interface requests.

Also remove an unused variable that I missed in the previous CL.

Bug: 150644681
Test: tested by EthernetTetheringTest in same topic
Change-Id: I5109d8da3aeb6c1f6523291d9e2ec92c64b5ad2d
2020-03-19 22:04:23 +09:00
Lorenzo Colitti
841195a103 Make Ethernet interfaces more testable.
This CL adds a setIncludeTestInterfaces method to EthernetManager
that, when called, causes the Ethernet service to recognize and
manage test interfaces created by TestNetworkManager.

Bug: 150644681
Test: Tested by EthernetTetheringTest in same topic
Change-Id: I86eef7a93267f800dbfc8eafd307effa76a344ca
2020-03-19 18:06:59 +09:00
Milim Lee
f85c0b301c Set Ethernet default mode as CLIENT
Bug: 130840861
Test: build, boot
      atest EthernetTrackerTest
      manual test (using Ethernet)

Change-Id: I935ea2e5f214aced67fb60f4aec2744077177545
2020-02-01 05:48:53 +09:00
Lorenzo Colitti
32327808e1 Support one Ethernet interface in server mode.
Currently, Ethernet only supports interfaces in client mode
(e.g., to connect to the Internet). Add minimal support to
Ethernet to support interfaces in server mode. This simple
implementation only works on the default interface, which is the
first interface that is detected on boot (even if the interface
is later removed).

This also provides (but does not yet unhide) a simple API for
Tethering to request that the next-plugged-in interface to be
placed into server mode.

Test: Enabling tethering with change on top
Bug: 130840861
Merged-In: I78f85bc36aaceb62ce274003a75ea99d0b6bc8b7
Change-Id: I78f85bc36aaceb62ce274003a75ea99d0b6bc8b7
(clean cherry-pick from internal branch)
2020-01-28 16:22:46 +09:00
Lorenzo Colitti
918f68fce9 Merge "Avoid creating IpClient if ethernet cable is unplugged." 2020-01-09 05:26:34 +00:00
Junaid Babu
b92d1f5513 Fix refCount check at releaseNetworkFor
When releaseNetworkFor is called, refCount should be equal to 1 for
network.stop() to be called. This is the same logic that is followed by
WifiNetworkFactory also.
In the current code, when refCount is 2 and releaseNetworkFor() is called,
network.stop() will be executed and will stop Ethernet

Bug: 146089778
Test: build and boot OK
Change-Id: Ib7d1b488a2943364a8ba4a89eec5de4c33cf1d5a
2019-12-17 15:09:01 +09:00
kevinwk_lee
13d5b86614 Avoid creating IpClient if ethernet cable is unplugged.
This change avoids calling start() on needNetworkFor() if ethernet
cable is unplugged. Fixed by adding isLinkUp validation.

Test: ./cts-tradefed run cts-dev -d -m CtsSecurityTestCases -t \
      android.security.cts.ListeningPortsTest#testNoRemotelyAccessibleListeningUdpPorts
      adb shell netstat -lnup

Change-Id: I2debd7367a20b665249f9c19d2d8a61737435803
2019-10-31 07:23:11 +00:00
Paul Hu
cd73c22c96 Merge "[Ethernet] Replace internal connectivity checks permission" 2019-09-20 07:23:07 +00:00
Chalard Jean
91456a8c7a Update Ethernet code for the NetworkFactory serial number.
See aosp/708790

Bug: 18637384
Bug: 29030667
Test: manual
      cts
      runtest framework-net
      atest frameworks/opt/net/ethernet/tests

Change-Id: I5caa4cb89ca1441f3c84b5675ceede6ecacfd132
2019-09-09 11:03:51 +08:00
paulhu
6957e3a35a [Ethernet] Replace internal connectivity checks permission
A number of connectivity checks that protect system-only methods
check for CONNECTIVITY_INTERNAL, but CONNECTIVITY_INTERNAL is a
signature|privileged permission. We should audit the permissions
checks, and convert checks that protect code that should not be
called outside the system to a signature permission. So replace
the permission to NETWORK_STACK.

Bug: 32963470
Test: atest EthernetServiceTests
Change-Id: I2a88d04bbdcd7e7e624b9065372a6603d2bb45a2
2019-08-22 16:03:59 +08:00