Commit Graph

1884 Commits

Author SHA1 Message Date
Roshan Pius
98f59ecb99 TransportInfo: Add a generic redaction mechanism
This replaces the existing mechanism for redacting location sensitive
fields with a more extensible mechanism. Currently supported redactions
are for the following permissions:
i. ACCESS_FINE_LOCATION
ii. LOCAL_MAC_ADDRESS
iii. NETWORK_SETTINGS

Also, removed WifiInfo from ConnectivityServiceTest to reduce cross
dependencies on wifi code.

Bug: 156867433
Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: I2bb980c624667a55c1383f13ab71b9b97ed6eeab
2021-03-19 20:15:21 +00:00
Chiachang Wang
8156c4ea31 Revert^2 "Replace the usage of UidRange"
1b5c01b06f

UidRange is used in a shared way between ConnectivityService
and VPN through the use of NetworkCapabilities. UidRange will
be part of the ConnectivityService mainline but Vpn.java will
stay in the framework. We need a way to replace the APIs using
UidRange, or to make UidRange system API. The only really
relevant surface here is NetworkCapabilities#{setUids, getUids}.
The need for UidRange could be replaced by an integer Range, so
replace the usage of UidRange by a integer Range in
NetworkCapabilities#{setUids, getUids} and update the relevant
callers.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk

Change-Id: I0f679fb5fb8f4fe26461ca4912ca1fdfe7f43c9e
Merged-In: I4e5aec6ef1ea02e038fcd7ed117a3b67b69c5cb9
2021-03-19 02:11:07 +00:00
Anthony Stange
1b5c01b06f Revert "Replace the usage of UidRange"
Revert "Add shims for NetworkRequest"

Revert submission 1626206-replaceUidRange

Reason for revert: Breaking build - b/183106405
Reverted Changes:
I0b79c73e8:Add shims for NetworkRequest
I4bc0daf5a:Replace the usage of UidRange
I4e5aec6ef:Replace the usage of UidRange
I107c329d4:Expose uids related APIs in NetworkRequest and Net...

Change-Id: I6290429db1c8e787f8138b55b98fd92a74ac6402
2021-03-18 16:30:59 +00:00
Chiachang Wang
0843e480ca Replace the usage of UidRange
UidRange is used in a shared way between ConnectivityService
and VPN through the use of NetworkCapabilities. UidRange will
be part of the ConnectivityService mainline but Vpn.java will
stay in the framework. We need a way to replace the APIs using
UidRange, or to make UidRange system API. The only really
relevant surface here is NetworkCapabilities#{setUids, getUids}.
The need for UidRange could be replaced by an integer Range, so
replace the usage of UidRange by a integer Range in
NetworkCapabilities#{setUids, getUids} and update the relevant
callers.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Change-Id: I4e5aec6ef1ea02e038fcd7ed117a3b67b69c5cb9
2021-03-17 23:02:22 +08:00
Paul Hu
7aad07748e Merge "Remove Settings.Global.TCP_DEFAULT_INIT_RWND on CS" 2021-03-17 14:44:17 +00:00
Remi NGUYEN VAN
843367e8cf Merge "Remove usage of networkAttributes" 2021-03-17 11:24:28 +00:00
paulhu
8ec8e90036 Remove Settings.Global.TCP_DEFAULT_INIT_RWND on CS
TCP_DEFAULT_INIT_RWND setting has never been set before, CS
always read the tcp receive window size from
net.tcp.default_init_rwnd then set to net.tcp_def_init_rwnd.
Thus, remove the unnecessary setting from CS, and the property
doesn't need to set either. Because aosp/1639922 migrate the
properties, the default value has been set to kernel already.

Bug: 182538166
Test: atest FrameworksNetTests
Change-Id: I13e175ab4dea72446af7df4a25e307e5934fa813
2021-03-17 11:14:35 +00:00
Lucas Lin
60b3e230b6 Merge "Change the parameter type from ContentResolver to Context" 2021-03-17 06:35:21 +00:00
Chalard Jean
85538adb19 Merge changes I335e82e2,I84ba363d,I8f18083b,I854a952d,I00e23441
* changes:
  Remove per-user preference when the user is removed
  Expose the enterprise per-profile networking API.
  Implement setNetworkPreferenceForUser.
  Public API for per-profile network preference.
  Add tests for setNetworkPreferenceForUser
2021-03-17 05:48:18 +00:00
junyulai
1b1c874db4 [VCN13] Implement tracking best matching network
This is done by:
  1. In requestNetwork, provide a basic permission check.
  2. rematchNetworksAndRequests: no change, since non listen
     requests will be automatically processed to track
     best satisfying network.
  3. applyNetworkReassignment: no change, since non-request
     will not be sent to factories.

Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback_noIssueToFactory
Test: atest ConnectivityServiceTest#testRegisterBestMatchingNetworkCallback_trackBestNetwork
Bug: 175662146
Change-Id: I8cf4ab334df6812d84cdda160e9b72b6f54062af
2021-03-16 21:30:55 +08:00
Chalard Jean
0f57a492de Remove per-user preference when the user is removed
Test: new test for this
Change-Id: I335e82e29ec8f4c8da9def8b40153858cfd5bacb
2021-03-16 12:14:12 +00:00
Chalard Jean
06f68e7643 Add tests for setNetworkPreferenceForUser
Test: this
Change-Id: I00e2344118408da307439a0a993eb67cb17bf777
2021-03-16 12:11:27 +00:00
lucaslin
20f0488017 Change the parameter type from ContentResolver to Context
Context is more useful than ContentResolver, it can provide more
information if we want to change the behavior in the future.

Bug: 172183305
Test: atest FrameworksNetTests
Change-Id: I5702c7d74b862a76558b94f1abe2c6df9eb7f097
Merged-In: I5702c7d74b862a76558b94f1abe2c6df9eb7f097
2021-03-16 09:26:57 +00:00
Remi NGUYEN VAN
5a42a5ff0b Remove usage of networkAttributes
networkAttributes is a legacy configuration that is now only used to
configure which legacy type networks are supported, and what the restore
timer is for that network type, for the deprecated
startUsingNetworkFeature API.

Use a dedicated resource for the restore timers, and build supported
legacy network types using hasSystemFeature for wifi, wifi p2p,
bluetooth, proxy types, and TelephonyManager.isDataCapable for the
mobile types.

Bug: 146206136
Test: atest FrameworksNetTests
Change-Id: I3a771d3de6c5e912f18d2834e3a50af797ac4991
2021-03-16 16:01:40 +09:00
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