Commit Graph

1105 Commits

Author SHA1 Message Date
Hugo Benichi
bc3edde9c6 Merge "MacAddress: add @NonNull annotations" 2018-01-16 07:10:50 +00:00
Hugo Benichi
8f21758d4a MacAddress: add @NonNull annotations
This patch adds to the MacAddress class:
  - getAddressType() method which replaces addressType(), for naming
  consistency
  - @NonNull annotations on all input and output reference values for
  all public methods (@hide and public).

TYPE_UNKNOWN, which currently cannot be observed with a non @hide
method, is also removed from the public api.

Bug: 71866627
Test: $ runtest frameworks-net
Change-Id: I2af70408d46f431b7b32183e6b48ddae9a261a2c
2018-01-16 13:32:59 +09:00
Lorenzo Colitti
5183e57449 Change the netId to nethandle mapping.
Being able to update this handle is necessary to ensure that
system-only OTAs do not break vendor code that relies on
nethandles.

Bug: 63052780
Test: walleye builds, boots, networking works
Test: MultinetworkApiTest CTS tests passes
Change-Id: I049a4ad2610ca68b8f56377b63be7e5e8ce76039
2018-01-16 02:08:09 +09:00
Lorenzo Colitti
d207b1faa3 Merge "Move more core networking tests to framework/base/tests/net." 2018-01-11 03:09:40 +00:00
Lorenzo Colitti
a4fdc1204e Move more core networking tests to framework/base/tests/net.
Test: "runtest frameworks-net" passes except for already-failing IpConnectivityMetricsTest
Change-Id: I2a20d546089699ac67bc819f10a8fcd50c637ac4
2018-01-10 23:35:16 +09:00
Malcolm Chen
acf59b8403 Add isMobileDataEnabled in TelephonyManager.
Added a new hidden API isMobileDataEnabled in TelephonyManager.
Rename related APIs to isUserMobileDataEnabled,
isUserMobileDataEnabled and setUserMobileDataEnabled to better
clarify their functionality.

Bug: 69814555
Test: build
Change-Id: I2f186f1e7550cafbe4ee3a5af293c39274cbfeaa
Merged-In: I2f186f1e7550cafbe4ee3a5af293c39274cbfeaa
2018-01-08 18:08:22 -08:00
Hugo Benichi
3f83b8ad4e MacAddress: address api review comments
1) toSafeString() is renamed to toOuiString()
2) toOuiString() returns a String that only contains the first 3 bytes
   of the mac address.

Bug: 70336442
Test: runtest frameworks-net
Change-Id: I798d8fec32dbff5687a682028e5d90eb941f81c1
2017-12-18 09:22:47 +09:00
Hugo Benichi
3f33d23522 Expose the MacAddress class in the api
Test: built,  flashed, $ runtest frameworks-net
Bug: 69390696
Change-Id: Ica5efdf5ffe8ad2500a87f574508a2bcd074b33d
Merged-In: Ica5efdf5ffe8ad2500a87f574508a2bcd074b33d

(cherry picked from commit d411cf61ed5b948aaf6f6234217d6c6999c35159)
2017-12-18 09:21:26 +09:00
Hugo Benichi
a31109c229 Merge "Fix bug in MacAddress.fromString()"
am: cdb84d2fc7

Change-Id: If4c85f0a5ea259f53f9cffa6eacb58fcde1fd1df
2017-12-05 09:47:50 +00:00
Hugo Benichi
21c7a52042 Fix bug in MacAddress.fromString()
Test: runtest frameworks-net
Bug: 69390696
Change-Id: I83f01e4915092e08ed201d9b6738bb02498d3bba
2017-12-05 13:14:08 +09:00
Hugo Benichi
56eeb80dc5 Merge "MacAddress: light refactors and improve documentation"
am: d871cab32d

Change-Id: I51bb8786ecd7f53e3342625c7a2625007eedfc0f
2017-12-04 23:38:27 +00:00
Hugo Benichi
5bc3546cf6 MacAddress: light refactors and improve documentation
This patch does some light refactoring in MacAddress to prepare for
exposing MacAddress in the public api:
 - documention is improved
 - some method names are renamed
 - a toSafeString method is added
 - a padding bug in the conversion methods outputting strings for
   mac addresses is fixed

Bug: 69390696
Test: runtest frameworks-net
Change-Id: I399a97dabc2dfa8df9c5518c8b12484e43ca05c9
2017-12-04 22:34:43 +09:00
Jeff Sharkey
8c089f392e Merge "Clarify docs, sanity check roaming state."
am: c80a1f23f3

Change-Id: Ic30d5aaadf2c59978162c53d7e7781847244ce52
2017-11-27 21:30:57 +00:00
Jeff Sharkey
9ff2ddd7e7 Clarify docs, sanity check roaming state.
Update public docs to hide the fact that NetworkCapabilities is only
used inside NetworkRequest as an implementation detail.

Take up less room on the wire when passing NetworkCapabilities around
via NetworkRequest.

Sanity check that the roaming state between NetworkInfo and
NetworkCapabilities is in agreement.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.,com.android.server.ConnectivityServiceTest
Bug: 67040695
Change-Id: I982b4c3c41a140934bbad3b8ca8f12dc3814e86c
2017-11-27 12:47:14 -07:00
Xin Li
acae66beee Merge commit '98e12851336b7db16e583f9afac63ecc97465980' from
oc-mr1-dev-plus-aosp-without-vendor into stage-aosp-master.

Change-Id: Ia7b8da4a00d215160e4a4fa40f6044208d1297b7
Merged-In: I19846d2a3ee27aecbae2367a74ee49082eea154d
2017-11-14 12:31:11 -08:00
Hugo Benichi
d380d14c4d MacAddress follow-up: define the core of the class
Test: new unit test parts of $ runtest frameworks-net
Change-Id: I08c57d2d656802f7bdd7a93fde711a7e77247583
2017-11-09 16:36:45 +09:00
Hugo Benichi
88ad29b907 Define MacAddress class
Test: new unit tests part of $ runtest frameworks-net
Change-Id: I5a6a868ff86e9bffdc551d4e2bb486b585525c30
2017-11-08 11:09:49 +09:00
Erik Kline
b0be3e6682 Replace dns_tls with private_dns_mode setting
Also includes:
    - SettingsLib strings used in PrivateDnsModeDialogPreference
      interaction in the Settings app
    - rename ContentResolver "resolver" in methods working with
      DNS resolvers (too confusing)

Test: as follows
    - built
    - flashed
    - booted
    - runtest frameworks-net
    - no new failures in SettingsBackupTest nor in SettingsProviderTest
    - manual interaction with developer option works
Bug: 34953048
Bug: 64133961
Change-Id: Ia7502916db9ffa0792e1e500a35e34d06a88e79d
2017-11-07 12:47:36 +09:00
Jeff Sharkey
07e19362de Define NOT_ROAMING network capability.
The "roaming" state of a network really belongs on NetworkCapabilities
instead of being published through NetworkInfo.isRoaming().  One major
reason is to support developers creating NetworkRequests for a
non-roaming network.

Watch for any capability changes that network statistics are
interested in (either metered or roaming) and notify it to perform
an update pass; fixes bug where we previously only triggered on
roaming changes.

Fix bug in VPNs where metered/roaming capabilities of underlying
networks weren't being propagated; this was probably preventing
some jobs from running over unmetered networks, and causing other
jobs to run over roaming networks!  Also passes along link bandwidth
information from underlying networks, and propegates any changes
to underlying networks.

Fix race condition by reading prevNc inside lock.  Utility methods
correctly calculate min/max link bandwidth values.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.,com.android.server.connectivity.,com.android.server.ConnectivityServiceTest
Bug: 68397798, 16207332
Change-Id: I3e1a6544c902bf3a79356b72d3616af1fd2b0f49
2017-11-01 19:05:42 -06:00
Tobias Thierer
3af8a3d48a Merge "Track moving of OkHttp facade API to new package." 2017-10-30 17:40:36 +00:00
Tobias Thierer
c8d921a034 Track moving of OkHttp facade API to new package.
Another CL in this topic moves the classes from
  libcore.net.http
to
  com.squareup.okhttp.internalandroidapi.
In jarjar'ed build targets, this becomes
  com.android.okhttp.internalandroidapi.

This facade constitutes the API via which non-libcore parts
of the Android platform (currently framework) may access
OkHttp. It's moving because libcore.net.http is already
part of libcore, and the overlap of packages is problematic
for builds with EXPERIMENTAL_USE_OPENJDK9 set to true.

Bug: 68220880
Test: Treehugger
Change-Id: Ia79966563cc0b5ab0923d54c21e54b6192d8c990
Exempt-From-Owner-Approval: Jeff Sharkey is an owner, but only one of his accounts is listed as an owner (@android.com vs. @google.com)
2017-10-30 17:40:23 +00:00
Jeff Sharkey
20f339b7df Improve NetworkCapabilities docs.
Add IntDef for constants, and rely on new auto-documentation feature
to expand all of them at usage sites.

Test: docs-only change
Bug: 64133169
Change-Id: I8a6b5f54c8eb9d4fc7ae3d0d3fb673d52320664b
2017-10-24 21:26:04 -06:00
Hugo Benichi
cf9ab489de Merge "Import a few android.net unit tests into frameworks-net" am: f851fef87f am: bf80e2f376
am: 3d4d464f0a

Change-Id: Icf9ccd265754f1b85720bb778633dc5ef515646e
2017-10-12 12:34:55 +00:00
Hugo Benichi
87d306b45f Import a few android.net unit tests into frameworks-net
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I3c7c60bcfeffec5c5ec287810312349237a2868a
2017-10-12 15:55:22 +09:00
Hugo Benichi
454cfa238a Merge "LinkProperties: fix some indentation issues" am: 4dea4936c7 am: 2d91ade1d8
am: a63788076a

Change-Id: Ife901fd1c9c30b3864ddce61326f2d5caacd0bae
2017-10-10 14:31:48 +00:00
Hugo Benichi
875e9a419c LinkProperties: fix some indentation issues
Test: no functional change
Change-Id: I469bba154feb382156e56043d83f066a5bd658aa
2017-10-10 18:25:50 +09:00
Hugo Benichi
1cae2642ad Merge "DO NOT MERGE Ignore DUN in describeImmutableDifferences" into oc-mr1-dev
am: b2f4b2e05d

Change-Id: I0236132b8b497af5b1c26aa44e6494fe0510cb6d
2017-10-02 11:10:37 +00:00
Hugo Benichi
b2f4b2e05d Merge "DO NOT MERGE Ignore DUN in describeImmutableDifferences" into oc-mr1-dev 2017-10-02 10:57:01 +00:00
Hugo Benichi
7f9a223134 DO NOT MERGE Ignore DUN in describeImmutableDifferences
This patch changes describeImmutableDifferences in NetworkCapabilities
to ignore differences in NET_CAPABILITY_DUN, so that updateCapabilities
in ConnectivityService to not report wtf errors when a NetworkAgent
degrades its NetworkCapabilities object by removing NET_CAPABILITY_DUN.

Bug: 65257223
Test: runtest frameworks-net
Change-Id: I115ed1b366da01a3f8c3c6e97e0db8ce995fd377
2017-10-02 15:03:57 +09:00
Chalard Jean
eb137aebc9 Do not throw on call to isTetheringSupported w/o permission
...just return false instead.

Test: Made an app to test this. Made sure it doesn't have
Test: the required permission. Checked it crashes with
Test: SecurityException without this change. Checked that it
Test: doesn't with it.

Merged-In: Ib5b17a7f68c1327f47fe1f54c0454c51f4226907
Change-Id: Id20d3c240ec5d70d085e0366b92ab3a514f3e7c8
(cherry picked from commit ffacaef813)
2017-09-28 16:34:39 +09:00
Udam Saini
b4f31a2f56 Adds necessary permissions to system apis
adds privileged permission for getCaptivePortalServerUrl
adds tether privileged permission for
startTethering,isTetheringSupported

bug:62348162

Test: make and manual testing
Change-Id: I8eb8e3c9dcd7201abe9ea303ee57fe99073d67eb
2017-09-27 12:14:37 +09:00
Chalard Jean
8522ec6dcc Merge "Do not throw on call to isTetheringSupported w/o permission" into oc-mr1-dev
am: e545f00e10

Change-Id: Ib5b17a7f68c1327f47fe1f54c0454c51f4226907
2017-09-27 02:12:24 +00:00
Chalard Jean
ffacaef813 Do not throw on call to isTetheringSupported w/o permission
...just return false instead. This will change in P.

Test: Made an app to test this. Made sure it doesn't have
Test: the required permission. Checked it crashes with
Test: SecurityException without this change. Checked it
Test: doesn't with it.

Bug: 65404184

Change-Id: Id20d3c240ec5d70d085e0366b92ab3a514f3e7c8
2017-09-26 19:25:48 +09:00
Charles He
65e8bd2e04 Merge changes from topic "always-on-vpn"
* changes:
  Opt-out for always-on VPN: rename API.
  Opt-out for always-on VPN
2017-09-19 07:50:13 +00:00
Rubin Xu
f49156fd33 Merge "Fix LinkPropertiesTest.testCompareResult" am: 430d8472b2 am: 1c7c93e084
am: 3db86833e6

Change-Id: I72b0ca1b9b50dacb7067eb6ca12ca48a072b5d26
2017-09-19 06:51:07 +00:00
Rubin Xu
830124470a Fix LinkPropertiesTest.testCompareResult
Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Change-Id: Ie97b7a7a1557b14296d7c33e98991cdede8463b0
2017-09-15 11:55:28 +01:00
Rubin Xu
3c737b4acc Merge "Refactor CompareResult<> class and its call sites" am: 414e97272f am: 027607ce4d
am: c345562746

Change-Id: I850f2ceab5949c2fceba5d25eda639a319efa7b3
2017-09-14 10:13:40 +00:00
Rubin Xu
2fa7d9e5cc Refactor CompareResult<> class and its call sites
Move all corner case logic from call sites to CompareResult's implementation,
add a constructor to directly do the comparison.

Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Change-Id: I95bba82ec38d295b18c49c025dffab5f17271cbd
2017-09-08 13:27:58 +01:00
Charles He
a05761a80b Opt-out for always-on VPN: rename API.
Rename the opt-out flag in AndroidManifest to
SERVICE_META_DATA_SUPPORTS_ALWAYS_ON
as directed by the API Council.

Bug: 64331776
Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Change-Id: I24326fad7a89083a2409134640bda81ee0359d08
Merged-In: I24326fad7a89083a2409134640bda81ee0359d08
(cherry picked from commit d681363fd1)
2017-09-08 10:47:34 +01:00
Charles He
738a0a48ab Opt-out for always-on VPN
Always-on VPN is a feature introduced in N. Since then, all VPN apps
targeting N+ are assumed to support the feature, and the user or the DPC
can turn on / off always-on for any such VPN app. However, a few VPN
apps are not designed to support the always-on feature. Enabling
always-on for these apps will result in undefined behavior and confusing
"Always-on VPN disconnected" notification.

This feature provides a new manifest meta-data field through which a VPN
app can opt out of the always-on feature explicitly. This will stop the
always-on feature from being enabled for the app, both by the user and
by the DPC, and will clear its existing always-on state.

A @hide API is provided to check whether an app supports always-on VPN.
Documentation is updated to reflect the behavior change.

Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'

Change-Id: I477897a29175e3994d4ecf8ec546e26043c90f13
Merged-In: I477897a29175e3994d4ecf8ec546e26043c90f13
(cherry picked from commit 9369e61e2d)
2017-09-08 10:18:36 +01:00
Rubin Xu
70b9208871 Always add local subnet routes to the interface's routing table
For some networks such as mobile data connections, its LinkProperties
does not contain routes for the local subnet so no such route is added
to the interface's routing table. This can be problematic especially
if the device is in VPN lockdown mode where there exists high-priority
PROHIBIT routing rule which in turn blocks the network's default gateway
route from being added (next hop address hitting the prohibit rule).

We fix this by patching LinkProperties to always include direct connected routes
when they are received by ConnectivityService. This has the added advantage that
when apps get LinkProperties, they see the directly connected routes as well.

Bug: 63662962
Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest
Test: Start with device with mobile data, set up ics-OpenVPN in always-on
      lockdown mode. Turn off mobile data then turn it back on, observe
      mobile data connectivity is restored and VPN successfully reconnects.

(cherry picked from commit 1bb5c0818f0c4fb426e13b65a3ba3db7f36c3d88)

Change-Id: Ia14f88bcf49d37286519c26dff6b7180303e2cbe
2017-09-07 14:17:57 +01:00
Rubin Xu
af3207c188 Merge "Always add local subnet routes to the interface's routing table" am: 609dd56140 am: 4bb100dcd0
am: e3469a426e

Change-Id: I21f4231c968b37cdcf1565279eedfb990dbc583b
2017-09-07 12:55:58 +00:00
Rubin Xu
ffd77d8f29 Always add local subnet routes to the interface's routing table
For some networks such as mobile data connections, its LinkProperties
does not contain routes for the local subnet so no such route is added
to the interface's routing table. This can be problematic especially
if the device is in VPN lockdown mode where there exists high-priority
PROHIBIT routing rule which in turn blocks the network's default gateway
route from being added (next hop address hitting the prohibit rule).

We fix this by patching LinkProperties to always include direct connected routes
when they are received by ConnectivityService. This has the added advantage that
when apps get LinkProperties, they see the directly connected routes as well.

Bug: 63662962
Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest
Test: Start with device with mobile data, set up ics-OpenVPN in always-on
      lockdown mode. Turn off mobile data then turn it back on, observe
      mobile data connectivity is restored and VPN successfully reconnects.
Change-Id: I35b614eebccfd22c4a5270f40256f9be1e25abfb
2017-09-07 10:50:20 +01:00
Tobias Thierer
f65e355e1d Merge "Network: Use HttpURLConnectionFactory rather than OkHttp APIs" am: 811e215e2c am: 41ff948711 am: e7776bd372
am: 8f55753777

Change-Id: I1ed6962088be8a0999b81a19d84f5c1c7203dddb
2017-08-22 15:40:30 +00:00
Tobias Thierer
41ff948711 Merge "Network: Use HttpURLConnectionFactory rather than OkHttp APIs"
am: 811e215e2c

Change-Id: I79db2f0dc0870f71ec21397545e2e6abb5c7142b
2017-08-22 15:00:24 +00:00
Tobias Thierer
811e215e2c Merge "Network: Use HttpURLConnectionFactory rather than OkHttp APIs" 2017-08-22 14:07:16 +00:00
Hugo Benichi
3f04e31eee Merge "Allow NetworkAgent "immutable updates" to NetworkCapabilities" into oc-mr1-dev 2017-08-18 11:46:22 +00:00
Hugo Benichi
de7117d3fe Merge "Add convenience methods to IpPrefix and LinkAddress" into oc-mr1-dev 2017-08-17 22:31:59 +00:00
Charles He
0aeecd42a9 Merge "Opt-out for always-on VPN: rename API." into oc-mr1-dev
am: 8b2513e439

Change-Id: Ie511c6f1034b75b4e797dbc0ca31c7c5c30f336e
2017-08-17 08:01:53 +00:00
Hugo Benichi
f2ccd7a219 Add convenience methods to IpPrefix and LinkAddress
Also moving relevant test files into tests/net as part of runtest
framworks-net.

Also removes testHashCode in LinkAddress() because this test relies on
the assumption that hashCode() is stable across releases or jdk
versions, which is absolutely not true.

This creates maintenance work for little benefit since hashCode is
already tested as part of the equality test.

For instance this test is now broken because hashing for InetAddress
changed.

Bug: 62988545
Bug: 62918393
Test: runtest frameworks-net, added coverage in tests
Merged-In: I695bc3f0e801bf13bc4fc0706565758f12b775b4
Merged-In: I6d3f3c50eaec44e3a0787e849ab28e89f6f4a72d
Merged-In: Iddfec82a08f845e728adadfa6ec58a60a078d6af
Merged-In: I8d6dd5efd226a8b1c4b05d1e1102362b58e094a1
Merged-In: Ied0cc53ac34c7c5f5539507b1979cbf9c215262e
Merged-In: I3b2b7dcb1a9a194fc08643b27bbb5a0e84e01412

(cherry picked from commit 1dfb6b67555d04973dfb9d1100dfc1c6a5200633)

Change-Id: I9a17094bfdc54b9dec671306618e132a4beb59fc
2017-08-17 11:03:24 +09:00