Commit Graph

1870 Commits

Author SHA1 Message Date
Chalard Jean
0e6446cc22 Merge "[NS01] Add NetworkScore" 2021-03-16 06:36:07 +00:00
Remi NGUYEN VAN
8c1611cf5a Merge "Create ServiceConnectivityResources" 2021-03-16 02:29:31 +00:00
Chalard Jean
2801857fec [NS01] Add NetworkScore
As attested by numerous TODOs in the code, a new way of
representing network quality and policy is needed instead
of an int.

An int representing the quality of the network requires
all parties using it to know how all other parties are
using it, and implementation details about the decision
algorithm. For all intents and purposes, the selection
is left to individual network factories who try to
achieve a desired result while piecing together all
possible states of the system.

As the number of such cases and desires increases, this
becomes both intractable and unmaintainable. Indeed, at
this time in the codebase nobody can really predict exactly
how a given change in score will affect selection across
the board, and it is essentially impossible to figure out
the behavior of network selection by inspecting the code
because the moving parts are scattered throughout the
entire codebase.

Having an object encapsulating policy and quality values
will let us centralize the selection and make it again
possible to maintain without knowledge of all behaviors
of all network factories. It will also provide better
guarantees of respecting policy, and allow bugfixes that
were not possible before because they'd touch too many
parts of the code.

Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests
Change-Id: I3185a6412b9b659798faf0c6882699e9c63cc115
2021-03-15 09:49:47 +00:00
Roshan Pius
2bead69f56 Merge "ConnectivityManager: Provide API's to include location sensitive info" 2021-03-12 05:56:29 +00:00
Paul Hu
738f6020bb Merge "Stop using PackageManagerInternal in PermissionMonitor" 2021-03-12 05:23:05 +00:00
Lucas Lin
54307cc3fc Merge changes Ib80f814f,Ic605e489
* changes:
  Use new API - getIpSecNetIdRange() in IpSecService
  Add a new API to get the network ID range of IPSec tunnel interface
2021-03-12 03:30:32 +00:00
Remi NGUYEN VAN
21c854a6c0 Create ServiceConnectivityResources
Create the ServiceConnectivityResources package, which contains
resources Connectivity unbundled from platform resources.

Migrate the first few resources from ConnectivityService that have no
RRO in AOSP. To avoid boot time impact, avoid loading the resources in
the ConnectivityService constructor.

Bug: 182125649
Test: atest FrameworksNetTests
Merged-In: I77ac6f4303c54acc96f16e18ef02add30298ff3d
Change-Id: I77ac6f4303c54acc96f16e18ef02add30298ff3d
2021-03-12 12:09:13 +09:00
Roshan Pius
951c003ef4 ConnectivityManager: Provide API's to include location sensitive info
Existing NetworkCallback users will get NetworkCapabilities with
location sensitive data removed (except for ownerUid which will be
added for existing apps for backwards compatibility). Apps
have to opt-in to receive location sensitive data.

Note: This was chosen because WifiInfo is the only TransportInfo tha
has location sensitive info & that was added only in Android 12. If we
choose to default to true, all existings apps retrieving
NetworkCapabilities for wifi networks will be blamed for location access
unnecessarily.

Changes:
i) Add a flag in NetworkCallback creation to retrieve
NetworkCapabilities with location sensitive info in their callback.
(More flags are being planned for NetworkCallback for throttling
callback frequency, etc)
ii) For NetworkCapabilities.getOwnerUid(), we will continue to send the
data for apps targeting older SDK (since this is an existing field and
the new flag defaults location sensitive data to off).

Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: If70b5ea6f5c8885f0c353c8df08a826d55fe7f7a
2021-03-11 18:27:18 -08:00
Remi NGUYEN VAN
b833c6bcbd Merge changes from topic "ethernet_specifier"
* changes:
  Fix common tests on Q and R
  Add Ethernet, TestNetworkSpecifier API
2021-03-11 23:51:49 +00:00
lucaslin
30e70a82c0 Add a new API to get the network ID range of IPSec tunnel interface
- Add a new API to get the network ID range of IPSec tunnel
interface.
- Use the new API in IpSecServiceTest to make sure the result is
the same. Follow-up commit will change the logic in
IpSecService#reserveNetId(), the modified test can ensure the
correctness of the new change.

Bug: 172183305
Test: atest FrameworksNetTests:IpSecServiceTest
Change-Id: Ic605e48941fc9d6482cdcd01a8adcdc9b6d586a6
2021-03-12 00:46:33 +08:00
Remi NGUYEN VAN
57c9cc2614 Add Ethernet, TestNetworkSpecifier API
Rename StringNetworkSpecifier to EthernetNetworkSpecifier (its only
production user), and make it module-lib API.
The original StringNetworkSpecifier file is actually kept to satisfy
some invalid dependencies; it will be removed separately.

This allows specifying an Ethernet interface with a non-deprecated API:
until this change the only way to do so would be to use
NetworkRequest#setSpecifier(String), which is deprecated.

Similarly, add the TestNetworkSpecifier API for TestNetworkManager, to
replace previous usage of StringNetworkSpecifier. TestNetworkManager is
module API, so TestNetworkSpecifier should be module API too. This
allows tests to request the test interface specifically, without using
the deprecated NetworkRequest#setSpecifier(String).

Bug: 179329291
Test: m
Merged-In: Iee569f5c8bbdc4bc979610e1191308281f3d4620

Change-Id: Iee569f5c8bbdc4bc979610e1191308281f3d4620
2021-03-11 23:02:02 +08:00
junyulai
962bdb8677 [VCN11] Make requestBackgroundNetwork requires handler
Test: atest FrameworksNetTests android.net.cts.ConnectivityManagerTest
Bug: 175662146
Change-Id: Iac9487e8de8bfdd87fc7a0153b228ae2a7ba4e19
2021-03-11 21:05:27 +08:00
junyulai
7514e3187b [VCN10] Add new API to listen for highest score network
Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback
Bug: 175662146
Change-Id: Ifa411c7b53da789c74fff7e1a95f9c9ebf5bd05c
2021-03-11 21:04:06 +08:00
Lorenzo Colitti
82ff67f3cf Merge "Don't start clatd if disabled by vendor property." 2021-03-11 12:22:34 +00:00
Lorenzo Colitti
73aa86d8c9 Merge "Unbreak extraInfo values returned to apps." 2021-03-11 08:06:03 +00:00
paulhu
2adf56309b Stop using PackageManagerInternal in PermissionMonitor
- Replace the PackageManagerInternal#getPackageList() with
receiving PACKAGE_{ADDED|REMOVED} intent.
- Also remove the onPackageChanged method because the traffaic
permissions(INTERNET, UPDATE_DEVICE_STATS) are not changed after
package changed(Disable or enable package).

Bug: 176788468
Test: atest FrameworksNetTests
Change-Id: I5505d1c77db66a7e65fc336ea0e99846e78c6b36
2021-03-11 07:16:11 +00:00
Lorenzo Colitti
97f7b04b45 Merge "Set extraInfo on cellular TestNetworkAgents." 2021-03-11 03:31:49 +00:00
Aaron Huang
a0d00e1964 Merge "Remove IBatteryStats from ConnectivityService module" 2021-03-11 02:04:41 +00:00
Lorenzo Colitti
9b8b90be2b Don't start clatd if disabled by vendor property.
Fix: 182333299
Test: new unit tests
Change-Id: Ic15dc4fff6a13aa916e3d2dc6203829e96ddeda4
2021-03-11 00:59:14 +09:00
Lorenzo Colitti
e30db8d2a7 Unbreak extraInfo values returned to apps.
These were broken by aosp/1553463, which made filterNetworkInfo
unconditionally call setDetailedState with a reason of "" and an
extraInfo of null.

Fix both synchronous getter APIs (e.g., getNetworkInfo) and
CONNECTIVITY_ACTION broadcasts by calling a new
filterForLegacyLockdown method that behaves similarly to how the
now-deleted LockdownVpnTracker#augmentNetworkInfo used to behave.

While I'm at it, move back to private a method that was public
only because LockdownVpnTracker used it.

Fix: 181855958
Test: new unit test coverage
Change-Id: I2c7b88fcec9dd36b45cb51db8d19b3ee8bad44a6
2021-03-11 00:59:14 +09:00
Lorenzo Colitti
8affa9ee66 Set extraInfo on cellular TestNetworkAgents.
This makes the test more realistic, since telephony always puts
the APN name in the extraInfo field. It also makes it easy to
test that various APIs properly return the extra info without
plumbing a new parameter through TestNetworkAgentWrapper,
NetworkAgentWrapper, and InstrumentedNetworkAgent.

Also make the extraInfo and the legacyType available to tests.
This will be used in future tests that assert the contents of
extraInfo.

Bug: 181855958
Test: test-only change
Change-Id: If4eddb6cd9e70bb33e10d72aceebaea843244246
2021-03-10 23:33:08 +09:00
Chalard Jean
4a00da2054 Merge "Fix a bug where listen callbacks would not be called" 2021-03-10 00:32:58 +00:00
Aaron Huang
2aac0cd79d Remove IBatteryStats from ConnectivityService module
Currently ConnectivityService calls the methods in
BatteryStatsService through BatteryStatsManager so
IBatteryStats can be removed from ConnectivityService.

Bug: 171686421
Test: FrameworksNetTests
Change-Id: I559369c9900e8100cdae187bc9cec603ed85a131
2021-03-09 21:39:17 +08:00
Zoey Chen
b77aaa1e63 Merge changes from topic "PSL_TelephonyCallback"
* changes:
  [Telephony] Use TelephonyCallback instead of PhoneStateListener part1
  [PhoneStateListener] Redesign PhoneStateListener: Use TelephonyCallback
2021-03-09 10:36:03 +00:00
Aaron Huang
eac59ebbf8 Merge changes I1d1f0d2d,Ifbd4a978
* changes:
  Communicate with BatteryStatsService through BatteryStatsManager
  Add a new API in BatteryStatsManager for connectivity service
2021-03-09 10:33:56 +00:00
Chalard Jean
b5becbca0a Fix a bug where listen callbacks would not be called
NetworkAgentInfos cache the list of requests they satisfy,
and that list is used to send callbacks. Therefore, when
the TRACK_DEFAULTs are copied, this list needs to be
updated.

The best way to do this is to figure out what was the old
active request and find which requests corresponds to it
in the new list, and then upon registering adding the
active request to the relevant satisfier if present.

A few other ways can be considered like replacing the
request as it gets added, but this would temporarily
increase the number of callbacks allocated to the app
and risks crashing it for no good reason ; furthermore
the call to remove would have to be eschewed somehow
for those requests that are replaced. This is much
simpler.

Test: new test for this. This also passes the future
      tests for per-profile default network preference.
Change-Id: I001351e5c478c2c77cbf2844abca77b205291778
2021-03-09 19:05:55 +09:00
Aaron Huang
330a4c0bfa Communicate with BatteryStatsService through BatteryStatsManager
Mainline connectivity service is only allowed to use formal
APIs. Use new system API in BatteryStatsManager instead of
calling BatteryStatsService directly.

Bug: 171686421
Test: FrameworksNetTests
Change-Id: I1d1f0d2d456003e842ad77519667c0532995610d
Merged-In: I1d1f0d2d456003e842ad77519667c0532995610d
2021-03-09 06:29:30 +00:00
Zoey Chen
1b4ea1877b [Telephony] Use TelephonyCallback instead of PhoneStateListener part1
Since the redesign of PhoneStateListener, use TelephonyCallback to get the callback of EVENT_*

Bug: 167684594
Test: make
Change-Id: Ia3b777b12142b104b5798804f50b34748f9bf28c
Merged-In: Ia3b777b12142b104b5798804f50b34748f9bf28c
2021-03-08 20:25:00 +08:00
James Mattis
5062ffb6f5 Merge "Applying OEM network pref to all users" 2021-03-05 19:09:24 +00:00
Treehugger Robot
b55e8e82a3 Merge "[FUI22] Support getAllNetworkStateSnapshot" 2021-03-05 05:16:43 +00:00
Janis Danisevskis
d1320fac29 Merge "Keystore 2.0: Make VPN Keystore 2.0 ready." 2021-03-05 02:57:34 +00:00
James Mattis
ae9aeb0c3b Applying OEM network pref to all users
Updating handleSetOemNetworkPreference so that the given policy is
applied to all users on the device. Additionally, remove uids for all
users/apps so that stale uids don't stay present after rematch. Finally,
small cleanup on how we deal with remote exceptions.

Bug: 181581017
Bug: 176494815
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I214717ee0c78cfe8322e551c2c2e9dc01c0242b2
2021-03-04 11:32:10 -08:00
Treehugger Robot
75f450ab9e Merge changes Ie8d98359,I4d5cadfd
* changes:
  Fix a bug in RequestReassignment#toString
  Cleanup some of the PANS code
2021-03-04 12:39:04 +00:00
junyulai
ebd15164e9 [FUI22] Support getAllNetworkStateSnapshot
Currently, ConnectivityService has getAllNetworkState but it is
not ideal to expose as system API since the plan is to get rid
of NetworkState. Thus, create a new one that returns
NetworkStateSnapshot to fulfill the needs.

Note the original getAllNetworkState cannot be deleted now since
it has @UnsupportedAppUsage annotation.

Test: atest FrameworksNetTests
Bug: 174123988
Change-Id: Icddd434552b0e9ecbc8299e7242ec88cf3145aca
2021-03-04 18:41:09 +08:00
Janis Danisevskis
463c2d5292 Keystore 2.0: Make VPN Keystore 2.0 ready.
* Use public stable API to load certificates from keystore.
* Also use grants to allow racoon to use keystore keys without
  special exceptions in keystore.
* Use LegacyProfileStore instead of Keystore for storing VPN profiles.

Bug: 175068876
Bug: 171305607
Test: atest android.net.cts.Ikev2VpnTest
      atest android.net.cts.IpSecManagerTest
      atest com.android.server.connectivity.VpnTest
      atest com.android.server.ConnectivityServiceTest
Merged-In: I27975113896ea137260a9f94a34fb1c3ca173fe3
Change-Id: I27975113896ea137260a9f94a34fb1c3ca173fe3
2021-03-03 22:14:41 -08:00
Junyu Lai
87a6d6acd2 Merge "[FUI19] Migrate ConnectivityService to use NetworkStatsManager" 2021-03-04 01:24:57 +00:00
Sarah Chin
0f46c91ee5 Merge "APIs for 5G slicing" 2021-03-03 18:42:20 +00:00
junyulai
e7c7d2a9e1 [FUI19] Migrate ConnectivityService to use NetworkStatsManager
Test: atest FrameworksNetTests
Bug: 174123988
Change-Id: Iaefd99f87ae96bc9d97d139bcd92a3fe8de917d2
2021-03-03 20:01:51 +08:00
Remi NGUYEN VAN
74ba6de40f Extend timeout for receiving broadcasts
The test is currently flaky as broadcasts can take a long time
to be delivered, often more than 500ms.
Extend the timeout for broadcasts to 30s.

Historically the test would wait for broadcasts for at most 500ms,
but not verify that they were received before proceeding. This was
fixed recently by adding an assertion, but the assertion needs to
give enough time for the broadcast to be received.

Bug: 173331190
Change-Id: I0760f3418c635aa4d68de5aefdb7120a9d3e930b
Test: atest FrameworksNetTests
2021-03-03 06:26:16 +00:00
Sarah Chin
223bc35f3b APIs for 5G slicing
Create TrafficDescriptor class
Create new APN ENTERPRISE
Update setupDataCall and DataCallResponse to take TrafficDescriptor and
matchAllRuleAllowed
Move ApnTypes from Annotation to ApnSetting

Bug: 179312227
Test: atest FrameworksTelephonyTests
Change-Id: I7433976bfe25bcb2af85ffb9338959cbcc9f42f3
Merged-In: I7433976bfe25bcb2af85ffb9338959cbcc9f42f3
2021-03-03 14:16:21 +09:00
Chalard Jean
5d6e23bdfb Cleanup some of the PANS code
Test: FrameworksNetTests
Change-Id: I4d5cadfdd8e30a179948302e8c0c45f4d42b59ea
2021-03-03 14:16:21 +09:00
Paul Hu
0957fc8681 Merge "Use IDnsResolverUnsolicitedEventListener" 2021-03-03 01:08:27 +00:00
Yan Yan
5bab9c0448 Merge "Support new IpSecAlgorithm AUTH_AES_CMAC" 2021-03-02 18:24:27 +00:00
junyulai
14133c117d [FUI09] Expose NetworkStateSnapshot as system API
This is needed by NetworkStatsService and
NetworkPolicyManagerService to utilize the snapshots of
information of networks that grabbed from ConnectivityService.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I7e974ef7b23ba9ba6ee775eed9899b0c0e2eca55
2021-03-02 23:09:16 +08:00
junyulai
de41fc2022 [FUI17] Migrate NetworkStatsService to use NetworkStateSnapshot
This change migrates NetworkStatsService and related code to use
NetworkStateSnapshot which is used for replacing the NetworkState.

This patch also changes some formating which is suggested by
the linter.

Test: FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I547da8f411cb45bdadc376ac3cadf3f3c55bb282
2021-03-02 20:08:53 +08:00
Lucas Lin
6a2bb12457 Merge changes I35ed84fc,Ie6cfd77b,I4e4f929f,I751526e8
* changes:
  Fix comments left on aosp/1547454 and aosp/1556106
  Remove INetworkManagementService from ConnectivityService
  Remove unused INetworkManagementService
  Remove BaseNetworkObserver from Nat464Xlat
2021-03-02 04:07:35 +00:00
paulhu
7c0a2e61fe Use IDnsResolverUnsolicitedEventListener
Only part of events will report from DnsResolver through
INetdEventListener. So use IDnsResolverUnsolicitedEventListener
to get exactly supporting events from DnsResolver and it uses
Parcelable object to deliver data which can be more updateable
and extendable in the future.

Bug: 173485754
Test: atest FrameworksNetTests
      atest CtsNetTestCases
Change-Id: I8d2e700ae8861ed8ceccd287f3ca5bc2f1ed6dee
2021-03-02 11:37:47 +08:00
Junyu Lai
ff35256ebd Merge "Fix copyright license of VpnTransportInfo" 2021-02-26 03:38:59 +00:00
Chris Weir
2a6448ce32 Merge "Update tests for PANS network usage metrics" 2021-02-25 21:37:42 +00:00
Yan Yan
6ca69e5f31 Support new IpSecAlgorithm AUTH_AES_CMAC
Bug: 161716062
Test: IpSecAlgorithmTest, verified with CTS
Change-Id: Ideaf4225bd851fad8c8072505c6ad99d85ba616e
2021-02-25 10:35:10 -08:00