Commit Graph

4734 Commits

Author SHA1 Message Date
Erik Kline
471ce709e8 Move the logic of (re)evaluation of Private DNS
Moves this out of ConnectivityService and into each NetworkMonitor
(where it's more self-contained).

Test: as follows
    - builds, flashes, boots
    - runtest frameworks-net passes
    - manual testing with working and non-working hostnames behaves
      somewhat (but not entirely) as expected, and not always quickly
Bug: 64133961
Bug: 72345192
Bug: 73872000
Bug: 77140445
Merged-In: I5dc90ecfe6f6f10967b7501645ad8e030cb38982
Merged-In: Ida4967d22f0781524f0f269e30e653b8ec867258
Change-Id: Ic4322af3cb49149f2d975cb31f54b2ac7927f907
(cherry picked from commit 736353a584aa89a29e737e21e29c49fad0d38a63)
2018-04-05 19:18:47 -07:00
TreeHugger Robot
3d735d02d6 Merge "Add hasUnwantedCapability method" into pi-dev 2018-04-04 16:55:14 +00:00
TreeHugger Robot
4f58ec4b83 Merge "Mark networks with OEM_PAID always restricted" into pi-dev 2018-04-04 16:54:46 +00:00
Lorenzo Colitti
9b58dd356c Mark networks with OEM_PAID always restricted
Bug: 68762530
Test: runtest -x frameworks/base/tests/net/ -c android.net.NetworkCapabilitiesTest

Cherry-picked from AOSP with no conflicts

Merged-in: I173ee0a3bc1797d03ba34c5f025844eaada87ee4
Change-Id: I173ee0a3bc1797d03ba34c5f025844eaada87ee4
(cherry picked from commit efbacc0ccb70917b2782272e6b8f1a0fb3f56cbe)
2018-04-04 05:35:54 +00:00
Erik Kline
9a30db497c Support bypassing TLS in the framework
This change comprises the following parts:

    [1] android.net.dns.ResolvUtil, containing methods that encapsulate the
        use of the high bit in netids used in DNS resolution contexts.

    [2] Updates to captive portal apps to call the ResolvUtil method that
        enables DNS-over-TLS bypass for the captive portal app process.

Test: as follows
    - builds
    - flashes
    - boots
    - runtest frameworks-net passes
Bug: 64133961
Bug: 72345192

Merged-In: I0994b53d24ed25a2eb9e65429c61cf6fa87c7513
Merged-In: I4c49e23d8caa4d485df1c1d2f135a7282d439c0b
Change-Id: I2072c1f68d6978fa0d7e9d8693135a2c51bb0f87
(cherry picked from commit 2140529d9b8e116d88c2a385a0b3179c2ede5ad7)
2018-04-03 15:36:02 -07:00
Nathan Harold
68a7edf1cb Add AppOps Checks for MANAGE_IPSEC_TUNNELS
Adds support for a new AppOp to permit services to
use IpSec tunnel mode. The IpSecService now needs
a context so change the service mode to a cached
service rather than a static service.

Bug: 66955045
Test: runtest frameworks-net
Change-Id: I17a4a286225b432c3e15ea1587d946189931b4f4
2018-04-03 18:23:11 +00:00
TreeHugger Robot
a9a759bea0 Merge "Refactor isTetheringSupported() calls" into pi-dev 2018-04-03 02:25:49 +00:00
Erik Kline
126502d506 Refactor isTetheringSupported() calls
Tethering currently wants access to complex isTetheringSupported
logic that is only available in ConnectivityService. Instead of
trying to access that via ConnectivityManager, pass this capability
in to Tethering directly, in the TetheringDependencies object.

Also:
    - ConnectivityManager is only a source of static constants now,
      so "import static" all the constants that are actually used.

Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net works
    - manual USB towards WiFi tethering works
Bug: 68951715

Merged-In: Ifa121b057f9959ddb980edc940327929e48ea973
Merged-In: Iad6358dc2f1d10b322d22ec90543adc50882962d
Change-Id: Ia64faaadefb4a5d84a50da98bdebd544b6fda101
(cherry picked from commit 465ff3a0c1da8afd5cb13b25ed9a3c95ee0dd2c4)
2018-04-02 16:59:23 -07:00
Remi NGUYEN VAN
e4bcfd8889 Merge "Fix network usage stats on 464xlat tethered." into pi-dev 2018-04-02 23:09:50 +00:00
Pavel Maltsev
a389a03bd5 Add hasUnwantedCapability method
If you put values into the Builder, you should be able to observe
those values on the built object.

Test: atest android.net.cts.NetworkRequestTest

Bug: 74945408
Bug: 72828388
Change-Id: Ib4026b8d7370d570f1b606f0d221d00fed6e787d
2018-04-02 11:10:13 -07:00
TreeHugger Robot
95f4b59348 Merge "Make addUnwantedCapability method public" into pi-dev 2018-04-02 15:07:25 +00:00
Remi NGUYEN VAN
1720e75aa2 Fix network usage stats on 464xlat tethered.
Usage stats corrections for 464xlat in NetworkStatsFactory are not applied
to tethered traffic. Add adjustments in NetworkStatsService. After
migrating external callers off NetworkStatsFactory, we will be able to
only apply adjustments in NetworkStatsService and remove stacked
interface tracking from NetworkStatsFactory.
Bug: 72107146
Fixes: 72107146
Test: runtest frameworks-net & manual - checked corrected network usage
Merged-In: Ieb25c41c651499fdd01225ae5ac21d95e3d823f5
Merged-In: I016722f3a0ae2ae0a1d48bfacc4fe07ee3578ef7
(cherry-pick of aosp I5ce450e616b4fddf21f2a491fe5d0c9e9f969bda)

Change-Id: Id41cf22a0f9a63cb1832e9375bfb045861f08e52
2018-04-02 13:30:02 +00:00
Chalard Jean
94de1787a4 Fix PermissionMonitorTest that has been failing.
The fail is related to a recent fix to PermissionMonitor
that went into pi-dev only : ag/3799094, which fixed getting
the remote package name for the correct macro user instead of
the default. That fix had broken the test, this change fixes it.

Test: test now passes
Bug: 77315205
Change-Id: I26f8276eafe80478d5fefcff92e7dc2f12128bb4
2018-04-02 07:44:21 +00:00
Remi NGUYEN VAN
d197642ba8 Merge "Add method to NetworkStatsService for UID stats." into pi-dev 2018-04-02 05:40:04 +00:00
Benedict Wong
c37a5742a2 Merge changes from topic "encap-api" into pi-dev
* changes:
  Require explicitly supplied truncation length
  Clarify UDP encapsulation socket API
2018-03-30 20:28:19 +00:00
Pavel Maltsev
07019bb20f Merge "Add OEM_PAID capability to system api" into pi-dev 2018-03-30 16:32:52 +00:00
Jeff Sharkey
93fc2b5049 Merge "API council requested tweaks to NetworkRequest." into pi-dev 2018-03-30 16:30:24 +00:00
Remi NGUYEN VAN
ef7e3afa1e Add method to NetworkStatsService for UID stats.
Useful for clients such as BatteryStats which currently rely
on NetworkStatsFactory. Data at that stage is incomplete as
it does not account for tethering, VT data and corresponding
464xlat corrections.

Test: runtest frameworks-net, CTS tests pass.
Bug: b/72107146
Merged-In: I31c5b9b4a7c6e72910152415894a137f000a5858
Merged-In: I2527d95000c7500c824ede70f87ecb38e21ed323
(cherry picked from aosp 088ff6824f13145ea52207bdead0d7e454a6f3ce)

Change-Id: Ie80f1bb21124241f3414f9be77aceac9a44ec6d1
2018-03-30 18:58:18 +09:00
TreeHugger Robot
f26c5341a5 Merge "Fix socket leaks in various android.net.Network methods." into pi-dev 2018-03-30 09:47:51 +00:00
TreeHugger Robot
dd8a3c78c5 Merge "Limit the number of routes for performance" into pi-dev 2018-03-30 08:48:25 +00:00
TreeHugger Robot
039947df6a Merge "Clarify documentation for getActiveNetworkInfo and friends" into pi-dev 2018-03-30 08:22:29 +00:00
Remi NGUYEN VAN
38468e9f2f Merge "Allow null subscriberId in NetworkStatsManager." into pi-dev 2018-03-30 07:39:23 +00:00
Chalard Jean
f0473e8650 Limit the number of routes for performance
In evaluating whether "most" of the addressing space is
covered, the list of routes are obtained from a third-party
app, so it's possbile the system service stalls unless
some limit is enforced on how much work it has to do.
This change limits the number of routes to 400, as determined
by time measurement on various devices.

Bug: 74176086
Test: runtest framework-net
Change-Id: Ie4a96098bc044ade87b188839586f14dd101c100
2018-03-30 15:41:50 +09:00
Benedict Wong
2e1ebb60e6 Require explicitly supplied truncation length
Instead of providing default truncation lengths (based on RFC or
otherwise), this change imposes a restriction that the truncation length
must be supplied for all auth or aead algorithms.

Bug: 77204048
Test: Updated tests, ran on walleye
Merged-In: I4a0e2e71aa97259e56f44e7c8a2ce53135708d97
Change-Id: I4a0e2e71aa97259e56f44e7c8a2ce53135708d97
(cherry picked from commit bb7f2820f5bcccf8618078c2cbe4ea9836797e3b)
2018-03-29 23:07:42 -07:00
Benedict Wong
c165885206 Clarify UDP encapsulation socket API
This change updates the getSocket() methods for IPsec to improve clarity
of the return types, both for public APIs, and internal-only methods.

Bug: 72473753
Test: APIs updated, CTS + unit tests ran.
Merged-In: I0afebd432c5d04c47c93daa1ce616d712aa323d7
Change-Id: I0afebd432c5d04c47c93daa1ce616d712aa323d7
(cherry picked from commit 4c987ebade580d4abc8a3d549e0df90baab33140)
2018-03-29 23:05:42 -07:00
Chalard Jean
96d10a75b6 Clarify documentation for getActiveNetworkInfo and friends
For VPNs it's unobvious what these methods do, so document that.

Bug: 70917007
Test: Comment changes only. Checkdoc passes.
Change-Id: I31ec1aea356d88d969eaf9fc7d8c2ed13ce924eb
2018-03-30 12:22:06 +09:00
Remi NGUYEN VAN
65ffbafe88 Allow null subscriberId in NetworkStatsManager.
Use a MATCH_MOBILE_WILDCARD template to avoid filtering by
subscriberId when querying statistics from NetworkStatsService.

Bug: 74038898
Change-Id: I8296220472a9ba37044dd1a5ede9bdb45d3ed339
Fixes: 74038898
Test: runtest frameworks-net, CTS tests pass
Merged-In: I1e4e283c6eaecf33d12488e41e0c524f6ff83954
Merged-In: Ia84d2c7cc63bf8b8bf30f133e0382fd7103bf490
(cherry-picked from aosp I4b39e7031416cb33b23d89aa36ff0f774eaa942f)
2018-03-30 12:18:23 +09:00
Paul Jensen
55eaa09f96 Fix socket leaks in various android.net.Network methods.
Bug: 72124526
Test: make CtsNetTestCases
Change-Id: I3398b67272360f894e01a8cdfbc47b17d77c2330
2018-03-29 07:43:01 -04:00
Paul Jensen
b895ac0fe6 Add Network.fromNetworkHandle()
This is the counterpart to Network.getNetworkHandle() and facilitates
native code calling back to Java with network handle values from
getNetworkHandle.

Bug: 77210159
Bug: 64148938
Test: make CtsNetTestCases

Change-Id: I032b959d84180c063a79ddd97c35e7384b0f50a1
2018-03-29 07:24:59 -04:00
Pavel Maltsev
089fe77ba7 Make addUnwantedCapability method public
Allow apps to specify a list of capabilities that network must not have
in order to satisfy the request.

Bug: 72828388
Test: m -j
Change-Id: I91ee54963f7b92899c7a107b3a450b268c62fd8d
2018-03-28 15:09:50 -07:00
Jeff Sharkey
e5886f37ec API council requested tweaks to NetworkRequest.
If you put values into the Builder, you should be able to observe
those values on the built object.

Test: atest android.net.cts.NetworkRequestTest
Bug: 74945408
Change-Id: I9aacceb82c98f7881f0eb5e1106d89d469b816a7
2018-03-28 14:02:00 -06:00
Pavel Maltsev
1868811e8f Add OEM_PAID capability to system api
Some system apps should be able to request OEM_PAID networks.  This
makes a lot of sense when Android is used as in-vehicle infotainment
systems.

Bug: 68762530

Test: runtest -x frameworks/base/tests/net/ -c android.net.NetworkCapabilitiesTest

Change-Id: Ic916de7522a9f803a2410bc4e3e82101fd9d0dbd
2018-03-27 23:17:14 -07:00
Pavel Maltsev
51f4d8a11d Merge "Minor clean-up in NetworkCapabilities" am: 539f85a18d am: b1e2bfe4df
am: 8a956a5141

Bug: 72828388
Test: frameworks/base/tests/net/ -c android.net.NetworkCapabilitiesTest

Change-Id: I2f45d2c70c7c0142ae3b3ce9e6329c5f25b63380
(cherry picked from commit feb8d1498a822730e29cf346fe3382e3f5293a58)
2018-03-27 22:45:49 +00:00
Tony Mak
28a696afb4 Merge "Get application info in the correct user id" into pi-dev 2018-03-26 17:04:47 +00:00
Ricky Wai
2ce1e6ce2a Merge "Improve ConnectivityManager.getNetworkWatchlistConfigHash() javadoc" into pi-dev 2018-03-26 16:46:20 +00:00
Michael West
e0c1ee6414 Merge "add airplane mode shell commands to connectivity" into pi-dev 2018-03-26 16:38:03 +00:00
Tony Mak
2f6bcd9c06 Get application info in the correct user id
Fixes: 76396560

Test: Create work profile and launch hangouts in work profile.
Change-Id: Ic3727ac899153b6a96dd9b6d6921c32ba0bbd93e
2018-03-26 11:58:38 +00:00
Erik Kline
c54b9cb71a Pass all relevant resolver info to netd
Test: runtest frameworks-net passes
Test: manual testing of opportunistic and strict mode works
Bug: 34953048
Bug: 64133961
Bug: 72345192
Merged-In: I96f7747b8f0bb38d95579b688b4c2d068f1229cf
Merged-In: Ia4d896c4cc33c02f0c46d5d4c760cc33b13dff0b
Change-Id: Ia4f1905e1fa60e7a468c2246fb809191d2ba796b
(cherry picked from commit e5dac904d361a349f1cfc48500a678d22e3a7316)
2018-03-23 21:59:24 -07:00
mswest46
32928412a2 add airplane mode shell commands to connectivity
Fixes: 74410990
Test: Manually checked that commands enable/disable airplane mode.

Change-Id: I942bd4679fcd498a39b9b2cab68e8d3c00ce62d3
2018-03-24 01:53:45 +00:00
TreeHugger Robot
749299b1c5 Merge "Have the status bar listen to all macro-users VPN changes." into pi-dev 2018-03-23 09:26:46 +00:00
Chalard Jean
38354d1f60 Have PermissionMonitor arbiter which app can access background networks
This will let ConnectivityService send the right callbacks to the
relevant apps.

Test: manual with apps
      runtest frameworks-net
      cts
      new tests for this functionality
Bug: 67408339

Change-Id: I6f08efd9e73c7e191f833d7f307a3bf4c9e2f0b4
2018-03-23 13:37:56 +09:00
Ricky Wai
04baf117bf Improve ConnectivityManager.getNetworkWatchlistConfigHash() javadoc
Test: NULL
Bug: 74831039
Change-Id: I227ba1377a51821204cd5830e7da6ff3a15bca02
2018-03-22 20:13:05 +00:00
Chalard Jean
7c74b9f311 Have the status bar listen to all macro-users VPN changes.
Bug: 73217368
Test: manual
      Using Datally on work profile. Before this, enabling the VPN
      does not show the key icon. After this it does.

Change-Id: I454eb8f3881a48af1b0187c2b14a2a399d3c2445
2018-03-22 13:25:52 +09:00
Nathan Harold
bfcc17cc20 Check mOwnedByTransform to avoid DELSA on SPI
The owned by transform flag prevents the removal
of an SPI from accidentally deleting an associated
SA in the kernel. That flag wasn't actually being
checked, so deleting an SPI would result in the
transform being removed.

The existing code already guarantees that the SA is
deleted when the transform is deleted

Bug: 73258845
Test: runtest frameworks-net
Merged-In: I4c26aea7af817a5d9e54da5db1cdf4f943bcae06
Change-Id: I4c26aea7af817a5d9e54da5db1cdf4f943bcae06
(cherry picked from commit 22795302be4ec35449908cf566aa7c16945df836)
2018-03-20 18:29:02 -07:00
Benedict Wong
76df78ffbf Added implementation for VTI add/remove address
This change adds implementation details for add/remove addresses onto a
VTI.

Bug: 73675031
Test: New tests added, passing on Walleye
Merged-In: Idde9d943a5285d2c13c5c6b0f7b8a9faf718e6a5
Change-Id: Idde9d943a5285d2c13c5c6b0f7b8a9faf718e6a5
(cherry picked from commit ecc9f7cc08804e3fa15fea04ae94ea1bc74edbfe)
2018-03-20 16:01:27 -07:00
Chalard Jean
bf7610aa8a Merge "Deprecate most of NetworkInfo." into pi-dev 2018-03-10 07:51:11 +00:00
Chalard Jean
7eaf3b10e5 Deprecate most of NetworkInfo.
getType, getTypeName, isConnectedOrConnecting, isConnected,
isAvaisable, isFailover, isRoaming, getState, getDetailedState,
getReason, and the TYPE_* constants in ConnectivityManager
along with methods that use them are now stacked on a boat
bound for the other side of the Styx.

Test: no code changes
Bug: 62844794
Change-Id: Idd70763de5b1af5580b4734cd443ac4b570069cc
2018-03-09 16:52:20 +09:00
Chad Brubaker
caced413da Expose CONNECTIVITY_ACTION to Instant Apps
Test: Broadcast is visible to Instant Apps
Bug: 69421898
Change-Id: I8435e7723cf7a722668b97ff087d1f4453d3e7b7
2018-03-08 10:37:09 -08:00
Andreas Gampe
85c8c3d822 Connectivity: Fix map access
Found by Errorprone.

Bug: 73288226
Test: mmma frameworks/base/services
Merged-In: I1c4b35811c72d389e53e28c3eb1b411009471b92
Merged-In: Ice91ac58257551485231da4664027a281237de4b
Merged-In: I7d2f578b54c69139be8b887a2381ac1b2e0673a3
Change-Id: I63edad58dbc909c1e772bde85a1b9dd98c551fb1
(cherry picked from commit 3ba8106c23cdf518527f75beaabb48bf3182fb4d)
2018-03-07 11:36:57 +09:00
Pavel Maltsev
1016f7327a Merge "Extend network request to query networks w/o capabilites" am: 47d4d15483 am: 334cde1ec2
am: fa04c2d802

Change-Id: I3bf776767be61577f1bca0d98d4aaf82a0e45336
2018-03-03 00:14:52 +00:00