Commit Graph

3630 Commits

Author SHA1 Message Date
Luke Huang
808c2fa747 Merge "interface-related commands porting" 2018-11-01 07:09:54 +00:00
junyulai
c33ac0d43b Fix negative uid stats caused by 464xlat adjust when eBPF is on.
When using xt_qtaguid to count per uid stats,
NetworkStatsService needs to adjust the 464xlat traffic since
iptables module would double count for ipv4 and ipv6 packet.
But for eBPF, the per uid stats is collected in a different
hook, so the adjustment on root uid would only be needed in tx
direction.

Bug: 112226716
Test: 1. Make ipv4 traffic in ipv6-only network and check data
         usage.
      2. Make ipv4 traffic in a client which connect to
         ipv6-only hotspot.
      3. runtest frameworks-net
      4. cts-tradefed run cts -m CtsNetTestCases -t \
                 android.net.cts.TrafficStatsTest
      5. cts-tradefed run cts -m CtsUsageStatsTestCases

Change-Id: Ic9a84f5446eddc943c255d5f3b89dad171f53cac
2018-10-30 21:23:38 +08:00
Treehugger Robot
d1d3b374b7 Merge "Refactor UidRange by using stable aidl structure" 2018-10-29 00:17:34 +00:00
Luke Huang
14f7544c3e interface-related commands porting
Test: runtest frameworks-net passes
Test: manual testing of interface related function works(tethering)
Change-Id: Ie1a1ac00c28ef914d62e7d75b0db8c2434c810d2
2018-10-25 16:40:47 +09:00
Luke Huang
1acfa7de1b Merge "Firewall-related commands porting" 2018-10-25 00:20:12 +00:00
Luke Huang
77017913a4 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
a01c77a499 Merge "To support skip464xlat per Network" 2018-10-24 07:15:20 +00:00
Luke Huang
a241db9df7 Firewall-related commands porting
Test: runtest frameworks-net passes
Test: manual testing of firewall works
Change-Id: Ic19c3872988a2b5dd315feb57e0757797d00a6ac
2018-10-24 13:12:41 +09:00
Mathew Inwood
45d2c252b1 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 8c854f86a4)
2018-10-22 17:28:24 -07:00
Junyu Lai
f709e754ab Merge "Add new callback to inform blocking of network on specific uid." 2018-10-19 15:20:48 +00:00
Chalard Jean
1a1d52ebb4 Fix a bug where Uri can't parse IPv6 literal addresses.
Bug: 25540738
Test: added CTS in aosp change #793137 and ran them
Change-Id: Ibf870b7e87799090fae9ed456286c11990b01461
2018-10-19 11:25:27 +09:00
Lorenzo Colitti
3889ff53ed Merge "Change permissions checks for setAirplaneMode." 2018-10-15 13:36:45 +00:00
Lorenzo Colitti
f5845d14e1 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
8f54b61a9a 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
4b48dca2e8 Merge "Add log for debugging ConnectivityManager" 2018-10-12 03:14:48 +00:00
junyulai
05986c638b 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
85eca488e5 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
dee2aa4e55 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
2e31a7c004 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
0ac2c0945b 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
Tobias Thierer
149e506efc Fix typo in android.net.Uri documentation.
This typo has been present since before the "auto import"
of cupcake sources in 2009.

Bug: 114704047
Test: Treehugger
Test: Checked through source inspection that this really returns
      the encoded form: its implementation is ssp.getEncoded(),
      whose implementation in turn is:
      return hasEncoded ? encoded : (encoded = encode(decoded));
Change-Id: I0e4fed702e6b3012429778ccbd18a495a5d69e9f
2018-09-11 10:40:36 +01:00
Remi NGUYEN VAN
e3a0f42e8e Merge "Add DhcpServer" 2018-08-29 03:19:27 +00:00
Treehugger Robot
0e1621296f Merge "Remove ResolveUtil from frameworks/base callers" 2018-08-29 02:58:08 +00:00
Treehugger Robot
7dd3f1dca6 Merge "Use multiple patterns and emails in per-file syntax." 2018-08-28 18:28:23 +00:00
Erik Kline
f4fa982339 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
Remi NGUYEN VAN
a13007ad0f Add DhcpServer
This first version can serve discover/request/release, although there
are some small behavior changes with current implementation which will
be addressed later.

Also removes final modifiers on start() and stop() in FdEventsReader, to
allow mocking the methods in tests with the current mockito lib.

Test: Added tests pass, manual: flashed a device using the server
Change-Id: I025366ff7d51c4ba31152af50f3dd2b5e280a54d
2018-08-28 12:50:47 +09:00
Treehugger Robot
7b7e05459f Merge "Fix typo in IpConfiguration comment" 2018-08-24 03:43:38 +00:00
Chih-Hung Hsieh
f690aebc09 Use multiple patterns and emails in per-file syntax.
Test: build/make/tools/checkowners.py -c -v OWNERS
Change-Id: I1de13d357c4bcc51fd75d0df6f9bc994dfd17efb
2018-08-23 15:11:24 -07:00
Blake Lawson
0c9ed965d3 Fix typo in IpConfiguration comment
Bug: NONE
Test: NONE
Change-Id: Ib2ce166532292266da17ec85c16e400afe4f9111
2018-08-23 08:43:07 -07:00
Remi NGUYEN VAN
a420b57a6b 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
12da4a5efc 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
fa3a7466e1 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
bf66847240 Merge "NetworkAgent: Send primitive integer in explicitlySelected" 2018-08-13 17:09:51 +00:00
Roshan Pius
eaf8dee367 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
7e83b79010 Merge "NetworkAgent: Send primitive integer in score" 2018-08-10 14:33:07 +00:00
Roshan Pius
64e99ef26d 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
d2cb322e93 Add codewiz@, reminv@ to OWNERS for connectivity
Test: m
Change-Id: I11df4c93ac61b620fc576a2ff17192b7c9ecb984
2018-08-08 12:22:20 +09:00
Xin Li
e80b455065 Merge "Merge Android Pie into master" 2018-08-07 16:51:24 +00:00
Treehugger Robot
38c9e614af Merge "Add getter for X509 certificate" 2018-08-07 15:35:27 +00:00
Xin Li
02857a7219 Merge Android Pie into master
Bug: 112104996
Change-Id: Id91836f22f2c9842975ac5b55f0f18b89db9b2f5
2018-08-06 19:20:02 -07:00
Remi NGUYEN VAN
10c593cf7f Merge "Add logging for private DNS probes" 2018-08-07 01:29:14 +00:00
Adam Vartanian
a618570424 Merge "Clarify which methods return connected sockets"
am: bce398bfd3

Change-Id: Idb4fb49af7a2e2e9a7a9cdb0681803628e7ed269
2018-08-06 09:56:11 -07:00
Adam Vartanian
484a866b19 Merge "Add libcore as owners of relevant android/net files"
am: 24f3809258

Change-Id: I43cebb427d67f9dddbc76e1c284ceb8835d541c4
2018-08-06 09:51:22 -07:00
Remi NGUYEN VAN
2595e68176 Merge "Add utils to convert Inet4Address <-> int"
am: 5caebe3415

Change-Id: I347d23f4682eca623e3b10f72bc9000b1c5954a3
2018-08-06 09:34:55 -07:00
Treehugger Robot
bce398bfd3 Merge "Clarify which methods return connected sockets" 2018-08-06 15:00:37 +00:00
Treehugger Robot
24f3809258 Merge "Add libcore as owners of relevant android/net files" 2018-08-06 14:58:28 +00:00
Adam Vartanian
98a8217372 Add libcore as owners of relevant android/net files
Test: build/make/tools/checkowners.py frameworks/base/core/java/android/net/OWNERS frameworks/base/core/java/android/net/http/OWNERS
Change-Id: Iebef4381693d6cfadd437ed9e08a7f02bc96e6b7
2018-08-06 11:59:49 +01:00
Remi NGUYEN VAN
0066bda4cf 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
Adam Vartanian
acca0090fb Clarify which methods return connected sockets
Some methods in SSLCertificateSocketFactory return connected sockets
and some return unconnected sockets.  Be explicit in each method's
documentation about whether it returns a connected or unconnected
socket.

Bug: 37618511
Test: cts -m CtsNetTestCases -t android.net.cts.SSLCertificateSocketFactoryTest
Change-Id: Ia9c6c8bec15a2d3fbd0d86f8accff13627c79565
2018-08-02 14:54:59 +01:00
Adam Vartanian
6309c61d33 Add getter for X509 certificate
Users have requested access to the underlying certificate, which is
usually available (as all non-deprecated constructors set it) and can
give access to additional properties that are useful to developers,
allow them to validate it with an X509TrustManager, or otherwise use
it with APIs that take an X509Certificate object.

Bug: 111696337
Bug: 36984840
Test: cts -m CtsNetTestCases -t android.net.http
Change-Id: I6aebaa38fad683e09e095e5b5e2f3424694ec426
2018-07-27 14:25:01 +01:00