Commit Graph

1346 Commits

Author SHA1 Message Date
junyulai
4c95b08a23 [KA01] export SocketKeepalive API for NAT-T keepalive
The new set of API replace the PacketKeepalive system API
which is only specific for IPsec NAT-T keepalive packet. Allows
applications to request different types of keepalives through
the same set of API.

By using keepalives, applications could request system to
periodically send specific packets on their behalf, using
hardware offload to save battery power.

This change would only address interface change and test part of
original functionality. After all reference of PacketKeepalive
are removed, another change would be submitted to remove old
API.

Bug: 114151147
Test: atest FrameworksNetTests
Change-Id: I3367666810acc44d5ad20e19acd4bf936e8b5d9c
2019-01-23 23:17:17 +08:00
Luke Huang
6fd9d58242 Merge changes from topic "Java async dns"
* changes:
  Add asynchronous DNS query API in Java
  Add jni method for DnsResolver
2019-01-23 08:48:23 +00:00
Remi NGUYEN VAN
1aa810b0f3 Merge "Add getAvoidBadWifi system API" 2019-01-23 01:13:01 +00:00
Luke Huang
6d23e740f8 Add asynchronous DNS query API in Java
DnsResolver for asynchronous DNS querying
DnsPacket for parsing answer

Test: built, flashed, booted
      atest DnsResolverTest
      atest DnsPacketTest

Change-Id: Id014bc7387dd940cfaa270f68e7d4d85fab320a0
2019-01-23 00:07:43 +08:00
Luke Huang
4e5831aecc Add jni method for DnsResolver
Test: built, flashed, booted
      atest DnsResolverTest

Change-Id: Iff730ec918f4db1ba0216f90a12550fe26e271d0
2019-01-23 00:07:43 +08:00
Remi NGUYEN VAN
27de63e494 Add getAvoidBadWifi system API
This helps remove the dependency on MultinetworkPolicyTracker from
IpClient.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: If56791dbed564772f25a859f301b8b52d84e38a3
2019-01-22 15:57:34 +00:00
Remi NGUYEN VAN
44ed85862c Migrate ICaptivePortal to stable AIDL
Also add required API for the captive portal app to stop using hidden
members.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Merged-In: I62b457e709fa199822bb8f80b0eab990be4ded93
Change-Id: I62b457e709fa199822bb8f80b0eab990be4ded93
2019-01-23 00:53:13 +09:00
Pavel Grafov
5e135e2bdc Merge "Add API for VPN apps to query always-on and lockdown." 2019-01-22 14:43:06 +00:00
Remi NGUYEN VAN
109f8d5585 Add LinkProps and NetworkCaps methods to SystemApi
Added methods are used by the NetworkStack.

Test: atest FrameworksNetTests NetworkStackTests
Bug: 112869080
Change-Id: I8822d43c1a4981ca39289525685b3f975fb0e8d5
2019-01-22 16:57:16 +09:00
Remi NGUYEN VAN
a1e4e0bc23 Merge "Add NetworkMonitor constants to SystemApi" 2019-01-22 03:03:37 +00:00
Remi NGUYEN VAN
aa983b7f1c Merge "Add fields used by NetworkStack to the API" 2019-01-21 23:20:26 +00:00
Remi NGUYEN VAN
85b9665073 Add fields used by NetworkStack to the API
Test: m
Bug: 112869080
Change-Id: I59f6d5ae8a601b7496548b87f137a577f2365a37
2019-01-21 23:03:25 +09:00
Pavel Grafov
e87b7ceaa6 Add API for VPN apps to query always-on and lockdown.
Test: atest MixedDeviceOwnerTest#testAlwaysOnVpn
Bug: 72628179
Change-Id: I73cb0888f7049b12ab0cdfa62678c3846e074d3b
2019-01-21 13:48:45 +00:00
Remi NGUYEN VAN
70ab67f1ce Add NetworkMonitor constants to SystemApi
NetworkMonitor lives in the NetworkStack which must only use system
APIs. This includes constants used by NetworkMonitor and captive portal
login.

Bug: 112869080
Test: m
Merged-In: I8b5f0bb61c3ef0d2f33af7dd67b72ac6c5a1d1b5
Change-Id: I4879568d3fbf9435767c8d4d0ab5198d421a2f4f
2019-01-21 21:11:15 +09:00
Remi NGUYEN VAN
699aefeb81 Add stable AIDL parcelables for IIpClient API
Test: atest FrameworksNetTests NetworkStackTests
Bug: b/112869080
Change-Id: Ia4ac1eb482850a06c4dc1b6c1fe55d33d4087388
2019-01-21 12:54:24 +09:00
Remi NGUYEN VAN
8f7bc647b5 Add Nat64Prefix to LinkProperties copy constructor
The attribute is copied when parceling/unparceling so should also be
preserved in the copy constructor.

Test: tests based on this pass
Change-Id: Ia48d94fc075e6414f537dad181a236be5a32b41b
2019-01-16 15:27:27 +09:00
Lorenzo Colitti
981b34f6b8 Add the NAT64 prefix to LinkProperties.
Currently we support exactly one NAT64 prefix. This matches what
other components in the system (Dns64Configuration, clatd, etc.)
support.

Test: atest FrameworksNetTests
Change-Id: I45a11cebe43a5e1c60d50eca7889cb317565b598
2019-01-12 02:16:34 +09:00
Remi NGUYEN VAN
b35979db6b Merge "Move NetworkMonitor to NetworkStack" 2019-01-11 05:08:52 +00:00
Remi NGUYEN VAN
8539129ad9 Move NetworkMonitor to NetworkStack
Bug: b/112869080
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I1b8b6a3f4390adbabf92fb9e48da61c47b08b2ec
2019-01-11 09:59:11 +09:00
Chalard Jean
a99e1eeb9d Merge "Add PCSCF to LinkProperties." 2019-01-10 05:55:05 +00:00
Remi NGUYEN VAN
82ef768e0c Merge "Move DhcpServer to NetworkStack app" 2019-01-09 10:42:48 +00:00
Remi NGUYEN VAN
a35360c1b6 Move DhcpServer to NetworkStack app
Test: atest FrameworksNetTests && atest NetworkStackTests
Bug: b/112869080

Change-Id: I96c40e63e9ceb37b67705bdd4d120307e114715b
2019-01-09 15:42:16 +09:00
Chalard Jean
158702db55 Add nullability annotations to public methods of ConnManager.
This is mainly for Kotlin compatibility.
https://android-developers.googleblog.com/2018/08/android-pie-sdk-is-now-more-kotlin.html

Bug: 122437895
Test: no logic changes
Change-Id: Ic1b9a774aee0099397b1ccfd958ff3b61d69a7fb
2019-01-07 19:35:09 +09:00
Mathew Inwood
bdfc1fcb7a Limit access to suspected false positives.
Members modified herein are suspected to be false positives: i.e. things
that were added to the greylist in P, but subsequent data analysis
suggests that they are not, in fact, used after all.

Add a maxTargetSdk=P to these APIs. This is lower-risk that simply
removing these things from the greylist, as none of out data sources are
perfect nor complete.

For APIs that are not supported yet by annotations, move them to
hiddenapi-greylist-max-p.txt instead which has the same effect.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Change-Id: Ia937d8c41512e7f1b6e7f67b9104c1878b5cc3a0
Merged-In: I020a9c09672ebcae64c5357abc4993e07e744687
2018-12-28 14:26:35 +00:00
Paul Hu
6f8696cf67 Merge "Unhide LinkProperties, NetworkCapabilities, NetworkRequest APIs" 2018-12-21 15:21:03 +00:00
Junyu Lai
84a764b1f4 Merge "Deprecate NetworkInfo" 2018-12-21 09:56:39 +00:00
junyulai
9826e7f292 Deprecate NetworkInfo
Currently NetworkInfo is used by Apps to get information of
network. However, to get such information, Apps need to poll
NetworkInfo frequently from ConnectivityService.

In order to increase the stability and reduce the maintain
effort, all functionalities provided by NetworkInfo are targeted
to be replaced or removed entirely.

Apps should use ConnectivityManager.NetworkCallback instead, to
get faster and more detailed updates from connectivity changes.

Or, apps could use getNetworkCapabilities or getLinkProperties
to get information synchronously, but should not mix the
callbacks and synchronous methods together.

Bug: 113629330
Test: atest FrameworksNetTests
Change-Id: Ie8faf620958c3fa0a4a2f233b35b825de0e99ffc
2018-12-20 16:36:10 +08:00
Treehugger Robot
9952ebd7d5 Merge "Fixed toString() printing error" 2018-12-19 17:39:58 +00:00
paulhu
058120dbc2 Unhide LinkProperties, NetworkCapabilities, NetworkRequest APIs
These methods are marked to @UnsupportedAppUsage APIs since
Android Q. But some system apps still need them to set/get
necessary network or request information. Hence, make them to be
public or system APIs.

Bug: 120448492
Test: atest FrameworksNetTests
Change-Id: I95a44daef5615e290b40d0796ca183b88ad8a63f
2018-12-18 08:39:49 +00:00
Paul Duffin
70c2193096 Add InetAddresses class to API
Adds methods needed by app developers to avoid them having to call
non-SDK APIs.

Test: tests added to cts
Bug: 78686891
Change-Id: Ic0eadfdab2b111d5ca4becb753f4fe3557806433
2018-12-17 11:53:33 +00:00
Etan Cohen
73fb5a86f0 [CM] Fix comments, add tests to TransportInfo API
Bug: 117605977
Test: atest NetworkCapabilitiesTest
Change-Id: I734ec56e44cd09d11ae81a856a53a26e1191b9a0
2018-12-11 15:00:10 -08:00
Etan Cohen
ac07cca084 [CS] Add a generic transport-specific information API
Add a generic transport-specific information container interface and
access methods. These can be used by a network factory to pass transport
(bearer)-specific network parameters to the app.

Bug: 117605977
Test: atest frameworks/base/tests/net/java/android/net (+new unit tests)
Change-Id: Ib7c83b677e1c02a2212265719813e648b0c9cc1b
2018-12-07 17:37:48 +00:00
Hongshik
e2d7cf5aed Add PCSCF to LinkProperties.
Some applications or services are needed PCSCF address to register IMS server but there is no way to get it on Android Framework.
We have added PCSCF address to LinkProperties like attached diff files.

Test: get Linkproperties and check Pcscf addresses.
      atest FrameworksNetTests

Change-Id: Ic2341a4ce2ed88d560325721766fc21f85f7ff86
Signed-off-by: Hongshik <hshik.kim@samsung.com>
2018-12-05 22:05:49 +09:00
jiayanhong
a03720b3e9 Fixed toString() printing error
There maybe some copy paste error about mNetworkCapabilities
and mUnwantedNetworkCapabilities in NetworkCapability#toString()

Test: manual + CodeDEX scan
Change-Id: I9997163e8b557590c27d15f0b2184ce6e1a53647
2018-11-23 14:23:04 +08:00
Jack Yu
c606db86c8 Merge "Move hidden APIs into system APIs" 2018-11-21 02:40:30 +00:00
Jack Yu
2268041efb Move hidden APIs into system APIs
To allow vendor code to construct LinkAddress, which is
one of the parameter in the system API DataCallResponse.

Test: Build
Bug: 73659459
Merged-In: I3e203781d3a03285fa0e047cc8837ccb4a09016a
Change-Id: I3e203781d3a03285fa0e047cc8837ccb4a09016a
2018-11-19 14:40:13 -08:00
Etan Cohen
ec1c466cb0 Add IPv6 link-local address generation from EUI-48
Add a utility method to convert an EUI-48 to an IPv6 link-local
address based on RFC 4291 (EUI-64 generation) followed by RFC 4862.

Bug: 117605977
Test: atest MacAddressTest
Merged-In: I80b683e69da6beff3b37fc345fc15aa9610d09b7
Change-Id: I80b683e69da6beff3b37fc345fc15aa9610d09b7
2018-11-16 21:50:24 -08:00
Luke Huang
477db5fe1a Refactor UidRange by using stable aidl structure
Use stable aidl generated structure instead of UidRange

Test: runtest frameworks-net passes
Test: manual testing of UidRange related function works
Change-Id: Iaf1c10777dc1e71df2be2a57533a10257b12626b
2018-10-24 19:45:09 +09:00
Chalard Jean
698b80818c Merge "To support skip464xlat per Network" 2018-10-24 07:15:20 +00:00
Mathew Inwood
0e71d36c58 Move some members to the "Q blacklist".
Based on some analysis, these fields/methods are likely false positives.
Set maxTargetSdk=P so that any apps using them are required to migrate off
them in future. See the bug for more details.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Merged-In: I719b5c94e5b1f4fa562dd5d655953422958ad37e
Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
(cherry picked from commit 2622bdf569)
2018-10-22 17:28:24 -07:00
Junyu Lai
f41deeb4a9 Merge "Add new callback to inform blocking of network on specific uid." 2018-10-19 15:20:48 +00:00
Lorenzo Colitti
38149e3ea7 Merge "Change permissions checks for setAirplaneMode." 2018-10-15 13:36:45 +00:00
Lorenzo Colitti
c7da00d199 Change permissions checks for setAirplaneMode.
Require NETWORK_SETTINGS (or NETWORK_SETUP_WIZARD) instead of the
legacy CONNECTIVITY_INTERNAL permission. The users are as follows:

- The system callers (Phone, Settings, SystemUI, VrSettings) all
  have NETWORK_SETTINGS.
- SetupWizard has NETWORK_SETUP_WIZARD
- sl4a has NETWORK_STACK

Bug: 115302596
Test: builds, boots, airplane mode via SystemUI works
Change-Id: I8ca40182bd8b5e3fd9a82296c0cc28de30ed4baf
2018-10-12 16:35:46 +09:00
Yuuki Habu
addf827426 To support skip464xlat per Network
To add skip464exlat in NetworkMisc.
NetworkAgent can skip to start 464xlat if need.
(e.g. IMS PDN for Cellular can be disabled)

Device will treat the network as IPv6-only if it is set

Bug: 69949375
Test: Nat464XlatTest, ConnectivityServiceTest

Change-Id: I676a02cb92530d64f29f34e89482a934f3ec4553
2018-10-12 14:35:30 +09:00
Chalard Jean
12f8847e40 Merge "Add log for debugging ConnectivityManager" 2018-10-12 03:14:48 +00:00
junyulai
f2c67e4521 Add new callback to inform blocking of network on specific uid.
Currently, apps rely on querying NetworkInfo object to know
whether their network is blocked or not. There is no proactive
way to tell app when it is being blocked/unblocked. The only
event that app would receive is SocketException with
ECONNABORTED when their ongoing socket connection has been
blocked, which is not an elegant way to notify app.

Thus, this commit is trying to address this problem. Therefore,
with the uses of other callbacks, the need of
getState/getDetailedState in NetworkInfo could be completely
eliminated.

Test: runtest frameworks-net
      runtest -x NetworkPolicyManagerServiceTest.java
      cts-tradefed run cts -m CtsHostsideNetworkTests
      cts-tradefed run cts -m CtsNetTestCases -t \
              android.net.cts.ConnectivityManagerTest
Bug: 74575553

Change-Id: Iec96a3103d0aa9a505020eb89d69b89c0b694486
2018-10-11 16:31:10 +08:00
Lorenzo Colitti
0bfef02a24 Make setAirplaneMode @SystemApi for SetupWizard.
Expose ConnectivityManager#setAirplaneMode and the
NETWORK_SETUP_WIZARD permission so that SetupWizard can call
setAirplaneMode.

Delete setAirplaneMode from the greylist because the permissions
checks on it, since at least 2013, have been for a privileged
permission (CONNECTIVITY_INTERNAL) that normal apps don't have.

Test: m
Bug: 115302596
Change-Id: I28f24d32c4b4b386407e9e0e3514ea9f8854f4a8
2018-10-10 17:50:05 +09:00
Soi, Yoshinari
b8102ef4d7 Add log for debugging ConnectivityManager
Add log to ConnectivityManager for better investigations of issue.
This patch adds StackTrace to the following APIs.

reportInetCondition()
reportBadNetwork()
reportNetworkConnectivity()
sendRequestForNetwork()
requestNetwork()
releaseNetworkRequest()
registerNetworkCallback()
unregisterNetworkCallback()

Bug: 116751720
Change-Id: I992292cd9d6f3d69c91ddbde5577591f9ec0f39b
2018-10-10 11:56:04 +09:00
Lorenzo Colitti
2386291f56 Make requestRouteToHost a no-op for system callers.
Everything in the system should now be using proper multinetwork
APIs instead of this insecure and error-prone API.

Make this method do nothing when called by the system. For now,
keep the code around for backwards compatibility for apps
targeting Android releases before M.

Bug: 25824776
Bug: 25876485
Test: FrameworksNetTests pass
Test: CtsNetTestCasesLegacyApi22 pass
Test: CtsNetTestCasesLegacyPermission22 pass
Test: android.net.cts.ConnectivityManagerTest passes
Change-Id: I9b3557faccccc95c7b954db6a13b853b4c7edea0
2018-10-01 12:05:42 +09:00
Jeff Vander Stoep
39a51e0191 Add ConnectivityManager.getConnectionOwnerUid()
Allow VPN apps to lookup the UID owner of a network connection.

Requires specifying the:
 - IP address and port for both the source and destination of a TCP
   connection.
 - IP address and port for either source and destination or just
   source for a UDP connection.
Only TCP and UDP protocols are supported. Only connections for UIDs
that apply to the calling VPN app will be resolved. This is intended
to replace direct app access to /proc/net/{tcp,tcp6,udp,udp6}.

The implementation uses netlink inet_diag sockets[1] to perform
the lookup on TCP sockets as well as UDP sockets when supported
(kernel has CONFIG_INET_UDP_DIAG=y).

[1] http://man7.org/linux/man-pages/man7/sock_diag.7.html

Bug: 9496886
Bug: 109758967
Test: atest HostsideVpnTests
Test: atest InetDiagSocketTest on Taimen with CONFIG_INET_UDP_DIAG
    and on Sailfish without CONFIG_INET_UDP_DIAG.
Change-Id: I2bbc7072dd091e2e653dadf6dc05024c04180f34
2018-09-21 06:16:09 +00:00