Commit Graph

1481 Commits

Author SHA1 Message Date
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
Andrew Solovay
be99bca44d docs: Replacing {#link with {@link
Several java files had the typo {#link (for cross-references to other
Javadocs) instead of the proper {@link format. This was confusing the
new doc publish tool (Mivi) since that's the format used for {# Django
comments #}.

Fixed a couple of links that had other errors (which prevented building
once the {# -> {@ was done) and other typos.

Replaced throughout the frameworks/base project; I'll need a separate CL
for the AndroidX fixes.

Staged to:

go/dac-stage/reference/android/app/Instrumentation.html
go/dac-stage/reference/android/bluetooth/BluetoothAdapter.html
go/dac-stage/reference/android/bluetooth/BluetoothDevice.html
go/dac-stage/reference/android/bluetooth/BluetoothServerSocket.html
go/dac-stage/reference/android/inputmethodservice/InputMethodService.html
go/dac-stage/reference/android/view/KeyCharacterMap.html
go/dac-stage/reference/android/view/KeyEvent.html
go/dac-stage/reference/android/media/AudioManager.html
go/dac-stage/reference/android/net/wifi/WifiConfiguration.html

(Other files were not in the public Javadocs.)

Bug: 111925950
Test: make ds-docs
Exempt-From-Owner-Approval: Docs-only change
Change-Id: Ia06e1fffd814671289a1caebd5962aedc18a28d7
Merged-In: Ia06e1fffd814671289a1caebd5962aedc18a28d7
2018-10-04 18:20:51 +00: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
Erik Kline
767b7f2021 Remove ResolveUtil from frameworks/base callers
Use the Private DNS bypass logic that was moved into Network.

Once all callers of ResolvUtil are updated to use this interface
ResolvUtil can be deleted.

Test: as follows
    - built, flashed, booted
    - runtest frameworks-net passes
    - connection to captive portal network detects portal correctly
      and the login activity functions as expected

Bug: 64133961
Bug: 72345192
Bug: 73872000
Bug: 78548486

Change-Id: If11ef2b5ffdc729f8449cf18dccd5f1eccbc51e6
2018-08-28 12:59:21 +09:00
Treehugger Robot
43afefcd97 Merge "Fix typo in IpConfiguration comment" 2018-08-24 03:43:38 +00:00
Blake Lawson
4253b45cbb Fix typo in IpConfiguration comment
Bug: NONE
Test: NONE
Change-Id: Ib2ce166532292266da17ec85c16e400afe4f9111
2018-08-23 08:43:07 -07:00
Remi NGUYEN VAN
aa3d9ac73b Add DhcpServingParams
Those parameters will be used to start DhcpServer or update its
configuration.

Test: runtest DhcpServingParamsTest.java
Bug: b/109584964
Change-Id: Id8d3dcf62d66dcb02accffa8d8500e30f07af452
2018-08-23 17:29:48 +09:00
Remi NGUYEN VAN
029434e9ac Add util to add an ARP table entry
This is to be used by the new DhcpServer to add ARP entries with new
addresses before sending unicast responses.

Test: manual: cat /proc/net/arp with implementation based on this
Bug: b/109584964
Change-Id: I3559893583aa3c49b188ad689a41ee2f3e9d9bf3
2018-08-23 16:01:44 +09:00
Mathew Inwood
c5b9bec94e Add @UnsupportedAppUsage annotations
For packages:
  android.net.wimax
  android.net.wifi.p2p.nsd
  android.net.wifi.p2p
  android.net.wifi.hotspot2.pps
  android.net.wifi.hotspot2.omadm
  android.net.wifi.hotspot2
  android.net.wifi.aware
  android.net.wifi
  android.net.util
  android.net.sip
  android.net.rtp
  android.net.nsd
  android.net.metrics
  android.net.lowpan
  android.net.http
  android.net.captiveportal
  android.net

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: Ie25423113ee1a8071cd5039382c00de6ce0af7fd
Merged-In: I520be7a4c79e68310c12e4f55bf66acaa94145a1
2018-08-14 14:44:29 +01:00
Treehugger Robot
bc63072e52 Merge "NetworkAgent: Send primitive integer in explicitlySelected" 2018-08-13 17:09:51 +00:00
Roshan Pius
00ef96bc0e NetworkAgent: Send primitive integer in explicitlySelected
|Boolean| object is not parcelable and hences crashes when the binder call
crosses a process boundary. Using a primitive integer instead to
represent the boolean value.

Bug: 112358948
Test: Device boots up and able to make wifi connection.
Change-Id: Iac69fd302e1f1338ed0da1446105ffc5855451cc
2018-08-10 07:44:33 -07:00
Roshan Pius
45190f8e7f Merge "NetworkAgent: Send primitive integer in score" 2018-08-10 14:33:07 +00:00
Roshan Pius
d594290fd9 NetworkAgent: Send primitive integer in score
|Integer| is not parcelable and hences crashes when the binder call
crosses a process boundary. Using a primitive integer should suffice
for sending the value to the server. There are no other usage of
|EVENT_NETWORK_SCORE_CHANGED| in the codebase.

Bug: 112358948
Test: Device boots up and able to make wifi connection.
Change-Id: I4c8fc17f4b803f69a4d882c71a8ce014a194d1ba
2018-08-09 07:10:27 -07:00
Remi NGUYEN VAN
c9f4d7be9e Merge "Add utils to convert Inet4Address <-> int"
am: 2587292cd1

Change-Id: I347d23f4682eca623e3b10f72bc9000b1c5954a3
2018-08-06 09:34:55 -07:00
Remi NGUYEN VAN
6e2a93cf9a Add utils to convert Inet4Address <-> int
The current utilities map the higher-order bytes of ints to the
lower-order bytes of IPv4 addresses, which makes applying masks and
generating series of addresses confusing.

For example, the current utilities would convert 1.2.3.4 to 0x04030201,
or generate 0x0080ffff for a /17 subnet mask. The utilities in this CL
convert 1.2.3.4 to 0x01020304, and a /17 subnet mask is represented as
0xffff8000.

Includes tests for all the above methods and migration of
NetworkUtilsTest to JUnit4.

Test: added tests pass
Change-Id: I5f5aa2e6e3b054b66b9dc507dab64f41be9139b1
2018-08-03 15:55:24 +09:00
Chalard Jean
24749e0b40 Merge changes I6abd2221,I2c149d29,I45d22857,I1f879b2c,If4986a25, ...
am: 6c0106b57f

Change-Id: I86bc83e2bd859b48017f12832e9ff0080ec162b8
2018-06-12 06:57:33 -07:00
Chalard Jean
040a41f850 Small cleanup of Network.
Test: runtest
Change-Id: I56dbd37bb8f890938d360f45835de72be4beb91a
2018-06-12 19:03:14 +09:00
Chalard Jean
d51966a41b Cleanup of LinkProperties.
Test: runtest
Change-Id: I7299de93a79901635ce755a2d933666ee43767d5
2018-06-12 19:03:07 +09:00