Commit Graph

279 Commits

Author SHA1 Message Date
James Mattis
54e3aebb95 Using PermissionUtils for common net permissions
Code clean-up to use PermissionUtils for common networking
permissions. Should be a no-op.

Bug: 210485380
Test: make, flash and boot
Change-Id: I4be08243156e9d04f4b3b44ab7328d0f6f7fdda1
2022-01-05 15:00:03 -08:00
James Mattis
a5f724dfdd Changes to make eth service methods more testable
Updates to make methods in EthernetServiceImpl that rely on
EthernetTracker unit testable. This CL also includes added tests for
such methods in EthernetServiceImplTest.

Bug: 210485380
Test: atest EthernetServiceTests
Change-Id: I63969b60cc4cf9d391e2cd21d02e1bdc8988aba8
2022-01-05 14:59:56 -08:00
James Mattis
cc1dac61b3 Eth Service updates to validate net mgmt calls
Updates to ethernet service code to validate calls to ethernet network
management APIs.

Bug: 210485380
Test: atest EthernetServiceTests
Change-Id: I66b91c6d12e6859de33760ab21bb00f1477720e8
2022-01-05 13:50:42 -08:00
Junyu Lai
544e5836c0 [MS33.1] Remove NetdService dependency
This change pass INetd to NetworkStatsFactory to replace
NetdService#getNetdInstance.

Test: atest FrameworksNetTests
Bug: 204830222
Change-Id: I39b278989cea06dd316f21214380b5c4b54d2d50
2022-01-05 05:29:46 +00:00
Treehugger Robot
e0d31a072d Merge "[MS31] Fix several hidden API usages" 2022-01-04 03:56:23 +00:00
Treehugger Robot
e10a94f740 Merge changes from topics "ms25-appops", "ms28-service-fix"
* changes:
  [MS25.1] Remove AppOpsManager.OP_GET_USAGE_STATS dependency
  [MS28.1] Fix several hidden API dependencies
2022-01-03 22:41:07 +00:00
Junyu Lai
19921cdd1f [MS31] Fix several hidden API usages
This includes:
1. Replace UserHandle.getUid(userId, appId) with public API
2. Remove Preconditions.checkArgument
3. Replace MathUtil.constrain with the one in NetworkStatsUtils
4. Remove Sets
5. Replace NetworkStack.checkNetworkStackPermission with the
   one in the PermissionUtils
6. Replace internal CollectionUtils with the one in the module
7. Inline ProtoOutputStream(fd)
8. Replace Intent.EXTRA_USER_HANDLE with Intent.EXTRA_USER

Test: atest NetworkStatsSubscriptionsMonitorTest \
      NetworkStatsServiceTest
Bug: 204830222

Change-Id: If06a27b04ad15c29052b670eefc2f6dc0d199420
2022-01-03 15:15:05 +00:00
Treehugger Robot
08af91950f Merge "[MS26.1] Remove Process.NETWORK_STACK_UID dependency" 2021-12-30 12:43:39 +00:00
Junyu Lai
c7ba513aaf [MS28.1] Fix several hidden API dependencies
This includes:
1. Replace Slog with Log
2. Use android.util.IndentingPrintWriter instead of the
   deprecated internal one.
3. Replace usages of ArrayUtils with CollectionUtils.
4. Reimplement DumpUtils#checkDumpPermission in PermissionUtils.
5. Replace MathUtils.constrain with NetworkStatsUtils.constrain

Test: FrameworksNetTests
Bug: 204830222
Change-Id: I2b064fc25497288d66018584e66da98c79bd208d
2021-12-30 10:00:19 +00:00
Junyu Lai
8b46180814 [MS26.1] Remove Process.NETWORK_STACK_UID dependency
Check NetworkStack permission instead.

Test: NetworkStatsAccessTest
Bug: 204830222
Change-Id: I052a1422d145af533b036b0f017ace485b67cbfe
2021-12-29 01:43:54 +00:00
Junyu Lai
40e4fc8326 [MS18] Augment data usage by default
Follow-up from ag/2815797, callers who uses the hidden API
will have their data augmented by default, and the public
API offers a way to opt-into augmentation.

However, since the data usage is going to the module.
All the hidden API usage must be eliminated. Also, from user
perspective, it is better for UI and API to have aligned
behavior.

Thus, enable augment data usage for public API callers.

Test: atest FrameworksNetTests \
      android.app.usage.cts.NetworkUsageStatsTest
Bug: 204830222
Change-Id: Ida254fac8d44c32d388f1886a866f7324a41ce75
2021-12-24 09:55:22 +00:00
Xiao Ma
39e7a77991 Remove INetworkManagementService usage from EthernetTracker.
Ethernet service related files are going to be moved into Connectivity
module. INetworkManagementService won't be visible to EthernetTracker
since it's a hidden class. Alternatively, use INetd APIs to replace
INetworkManagementService usages, including below API changes:

- mNMService.listInterfaces -> mNetd.interfaceGetList

- mNMService.getInterfaceConfig -> NetdUtils.getInterfaceConfigParcel
  - remove InterfaceConfiguration usage, use NetdUtils APIs instead.

- mNMService.registerObserver -> mNetd.registerUnsolicitedEventListener
  - for this API change, also replace the parameter BaseNetworkObserver
    class with BaseNetdUnsolicitedEventListener class.

Bug: 210586283
Test: atest FrameworksNetTests
Test: atest EthernetServiceTests
Change-Id: Ic14c55a6a36b774006931a6fbcbfdec0c51a16e9
2021-12-24 08:58:47 +00:00
James Mattis
5fac76d3a2 Stubbed net mgmt API methods in eth service
Stubbed API methods in EthernetServiceImpl to be used for network
management.

Bug: 210487086
Bug: 210485380
Test: make, flash and boot and atest EthernetServiceTests
Change-Id: I8bd5a6eca07d00e0f155b71e2960371989a13013
2021-12-22 09:57:44 -08:00
Xiao Ma
7ab9fb8f1a Merge "Replace Preconditions.checkNotNull with Objects.requireNonNull." 2021-12-22 01:42:21 +00:00
Xiao Ma
3a26d1b8ed Import InterfaceParams class from f/libs/net/common.
Ethernet service related files are going to be moved into Connectivity
mainline module. Import InterfaceParams class in EthernetNetworkFactory
from f/libs/net/common, which is visible to Connectivity module.

Bug: 210586283
Test: atest EthernetServiceTests
Change-Id: I98ebb04cc3c2b685464e7f2689424794957088b3
2021-12-21 08:06:07 +00:00
Xiao Ma
31ce0a1dc7 Replace Preconditions.checkNotNull with Objects.requireNonNull.
Ethernet service related files are going to be moved into Connectivity
mainline module. Replace the Preconditions.checkNotNull usage in
EthernetNetworkFactory with Objects.requireNonNull.

Bug: 210586283
Test: atest EthernetServiceTests
Change-Id: Ibeaf687f706e8400f825cb2ca97bb1341774a97d
2021-12-21 08:01:04 +00:00
paulhu
802ab9760f Build framework-connectivity-tiramisu library
- Move nsd APIs and build framework-connectivity-tiramisu library
- Add nsd associated hidden apis
- Build service-connectivity-tiramisu-pre-jarjar library for
  T+ services.
- Move ConnectivityServiceInitialiizer to service-t directory
  to create S+ service instances which can avoid dependency on
  lower sdk library.

Bug: 206893064
Test: atest FrameworksNetTests CtsNetTestCases
CTS-Coverage-Bug: 207804007
Merged-In: I9628716f5c38047ff4ea2346b27589077259c436
Change-Id: I9628716f5c38047ff4ea2346b27589077259c436
2021-12-17 00:04:24 +08:00
Xiao Ma
9cb7b5dc65 Merge "Move Ethernet related files to f/b/packages/ConnectivityT." 2021-12-16 14:12:39 +00:00
Xiao Ma
479ee83516 Merge "Remove NetdService usage from EthernetTracker." 2021-12-16 08:22:01 +00:00
Xiao Ma
202317df53 Move Ethernet related files to f/b/packages/ConnectivityT.
ethernet-service is going to be moved into Connectivity mainline module.
Move all ethernet related files in f/b/ to f/b/packages/ConnectivityT so
that it's easier to migrate these files to Connectivity module finally
after clearing the hidden API usages. Below files to be moved:

Ethernet framework related files:
    - EthernetManager.java
    - EthernetNetworkSpecifier.java
    - IEthernetManager.aidl
    - IEthernetServiceListener.aidl
    - ITetheredInterfaceCallback.aidl

Ethernet service related files:
    - IpConfigStore.java(EthernetConfigStore has dependency on the class)

For the ethernet-service related files, keep it as-is temproraliy and
fix the hiden API dependencies in f/opt/net/ethernet/. After this work
is done, then migrating the whole of ethernet folder to Connectivity
module completely.

This CL also fixes some minor errors of code style format to pass the
code style check.

Bug: 210586283
Test: build pass
      atest FrameworksNetTests
      atest EthernetServiceTests
Change-Id: Ib359d29d5221105f648bc4194c6d6dbe4cc6e3e5
2021-12-16 06:59:08 +00:00
Xiao Ma
300abdb2a8 Remove NetdService usage from EthernetTracker.
Ethernet service related files are going to be moved into Connectivity
module. So, NetdService won't be visible to EthernetTracker since it's
a hidden class. Alternatively, get the INetd instance from system
service instead.

Bug: 210586283
Test: atest FrameworksNetTests
Test: atest EthernetServiceTests
Change-Id: Iea021ac25cbe4b8836fdab2cd6b4bd3ead5bf725
2021-12-16 04:31:27 +00:00
Pavan Kumar M
e600bef8f9 Handle neighbor lost event
Neighbor lost event is received when gateway is not reachable.
Ethernet Factory currently doesn't handle the neighbor lost event and
network will not be brought down. This results in loss of
connectivity even if there are other networks like WiFi.

Restart NetworkInterfaceState when neighbor lost event is
received. If there is a better network like WiFi, it will become
default and apps will be able to use internet. If ethernet gets
connected again, and has backhaul connectivity, it will become
default.

Bug: 180077540
Tests: Builds, Boots, EthernetServiceTests
Change-Id: I26d720994ecb35f6529358a53e115091e7817c2f
2021-12-15 22:56:06 +05:30
Aaron Huang
2617cf51ba Remove NetdService usage from IpSecService
IpSecService is going to be moved into ConnectivityService
module. So, NetdService won't be visible to IpSecService
since it is a hidden class.

NetdService.get(timeout) is a method that blocks for specified time
until INetd instance is available. In SystemServer IpSecService is
created after NetworkManagementService and NMS uses NetdService.get()
to get INetd instance which is a method that blocks until an INetd
instance is available. Thus, connectNativeNetdService can be removed
because NMS already waits for INetd instance is available so IpSecService
should be able to get INetd instance immediately.

Bug: 204153604
Test: FrameworksNetTest
Change-Id: I007cb28de63783d60084f93dddb4de78faa0e868
2021-12-15 19:29:00 +08:00
Aaron Huang
9b27b0e6bf Refactor IpSecServiceConfiguration to Dependencies
IpSecService is going to be moved into ConnectivityService module,
so the hidden API usage should be removed.

NetdService.getNetdInstance is a hidden API, therefore the alternative
is to get the instance by Context.getSystemService.

Bug: 204153604
Test: FrameworksNetTests

Change-Id: I1bd8efc03c37654d12a8eadd3e78ed45e10b5691
2021-12-14 14:39:42 +08:00
Aaron Huang
fbae308e6a Fix style errors for IpSec associated files
Bug: 204153604
Test: build pass.
Change-Id: I940de8bef7f693dcce8808148a975bea1f36712c
2021-12-14 14:36:59 +08:00
Aaron Huang
9a708a4a19 Move IpSec associated files to f/b/packages/ConnectivityT
IpSecService is going to be moved into Connectivity mainline module.
Move all ipsec associated files to packages/ConnectivityT so that
it can be easily migrate these files to connectivity module after
clearing the hidden API usages.

Bug: 204153604
Test: build pass
      FrameworksNetTests
      CtsNetTestCases
Change-Id: I562b47f18e345988a2638cf886f86818f9144b91
2021-12-14 14:06:44 +08:00
Junyu Lai
c8c87d4a01 [MS07.1] Move NetworkStatsCollection/IdentitySet into frameworks
These files are needed for the data migration util system Api
interfaces to allow OEMs to construct NetworkStats* objects.
Thus, they need to be moved into android.net package, and some
of them will be exposed as @SystemApi in T.

Eventually these classes will be moved into the Connectivity
module, but in the mean time they will be temporarily moved to
f/b/package/ConnectivityT for the preparation stage.
However, the tests are already in the module. Therefore for
the S-derived branch, the test cannot see the renamed classes
since any framework CLs will not be auto-merged into this branch.
Thus, the tests need to stay disabled on the S-derived branch,
and will be re-enabled after all files are moved into the module.

Test: TH
Bug: 197717846

Change-Id: I95278a99cf2437ada28001161ceea17a1d32f2a4
2021-12-10 16:11:08 +00:00
Junyu Lai
ad166b43df [MS08] Move NetworkStats files to f/b/package/ConnectivityT
NetworkStatsService is going to be moved into ConnectivityService
module. Move all related files to packages/ConnectivityT so that
it can be easily migrate these files to connectivity module
after clearing the hidden API usages.

Bug: 197717846
Test: TH
Change-Id: Iead00832b5eb7b1dc40a92027c5a14ae8316b16c
2021-12-10 16:11:08 +00:00
Aaron Huang
e500616efd Move f/b/packages/Nsd files to f/b/packages/ConnectivityT
Move Nsd files to ConnectivityT so that nsd, ipsec,
ethernet and netstats files can live in the same
directory and it will be easier to move everything
in frameworks/base/packages/ConnectivityT to
packages/modules/Connectivity after fixing all of the
hidden API usages.

Bug: 204153604
Test: FrameworksNetTests
      CtsNetTestCases
Change-Id: I411e242e8739d15920cfc2fe274115f7f39bd89f
2021-12-09 16:22:00 +08:00
James Mattis
2fc1c08cb5 Adding test coverage for eth transport overrides
Added test coverage regarding how EthernetTracker consumes the xml
config as set in config_ethernet_interfaces. Additionally, adding
test coverage for transport override functionality in
EthernetNetworkFactory.

Bug: 206170402
Test: atest com.android.server.ethernet.EthernetTrackerTest
&& atest com.android.server.ethernet.EthernetNetworkFactoryTest

Change-Id: I3d55a230d3f28154ed6fdac6d63ed57bf589d3bd
2021-12-07 16:43:33 -08:00
James Mattis
68c4a5108b Removing unused int network score from eth factory
Hard coded network scores are no longer used however they still exist
in EthernetNetworkFactory. This change removes this unused code in
favor of the NetworkScore object.

Bug: 209679953
Test: m && atest com.android.server.ethernet.EthernetNetworkFactoryTest

Change-Id: Ic9035964fc0e0bdf1dbd1ee845ba3293c753dd8d
2021-12-07 16:38:05 -08:00
paulhu
1932a7e7ec Stop using NetworkStack#checkNetworkStackPermission* am: d6789606d5
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1827093

Change-Id: I304701a1ad5be47bec534d679eca259b06cb084d
2021-09-16 02:03:58 +00:00
paulhu
d6789606d5 Stop using NetworkStack#checkNetworkStackPermission*
Replace them with PermissionUtils.enforceNetworkStackPermission*
since those methods are deprecated.

Bug: 177187957
Test: atest EthernetServiceTests
Change-Id: Ifde4a8898439b86e6cc49b7469787bc5e4a91835
2021-09-15 16:53:45 +08:00
Treehugger Robot
07060e39fd Merge "prevent nullptr dereference when calling unwanted" am: 03f03d7acf
Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/net/ethernet/+/1802269

Change-Id: I703f0c9fb9748cc2a211acd667f7d27a265025a7
2021-08-20 09:11:10 +00:00
Treehugger Robot
03f03d7acf Merge "prevent nullptr dereference when calling unwanted" 2021-08-20 08:57:35 +00:00
Patrick Rohr
4cf6809d75 prevent nullptr dereference when calling unwanted
When the EthernetNetworkAgent has already been stopped, a call to
unwanted will cause a crash due to a nullptr derefernce.

Bug: 197279734
Test: atest EthernetNetworkFactoryTest
Change-Id: Ice39c603bdd3e3139aa8ece7fb897bf7b567e74b
2021-08-20 09:36:00 +02:00
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