Commit Graph

2376 Commits

Author SHA1 Message Date
Remi NGUYEN VAN
00c5e70471 Use IPV6_MIN_MTU from NetworkConstants in Ikev2Vpn
Instead of sharing the constant from LinkProperties, use the already
defined constant in the NetworkConstants class.

This allows Ikev2VpnProfile to allow depending on non-public
LinkProperties APIs, as LinkProperties is planned to move to
framework-connectivity.

Bug: 174436414
Test: m
Change-Id: I594bb7e81bc7681799c16eff621a5ffd1b29624c
2020-11-30 17:18:51 +09:00
Chalard Jean
746cdc28af Migrate VPN to the public NetworkAgent API.
On top of being a cleanup this is useful for the S Network
Selection project that will need to enrich the Network
Agent API, and as such should not have to support legacy
agents.

Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: Id3e5f6e19829c64074cd6a52c5f950cee56b860b
2020-11-30 16:15:18 +09:00
Remi NGUYEN VAN
d707e7f5ae Do not query CS in NetworkProvider constructor
ConnectivityService may not be available in a NetworkProvider
constructor, if it is created (but still unused) before
ConnectivityService starts.

As ConnectivityManager is only necessary in
declareNetworkRequestUnfulfillable, which should not be called often,
just query ConnectivityManager at that point.

This is necessary for VcnManagementService, which is started before
ConnectivityService and creates its NetworkProvider in its constructor.
Fortunately VcnManagementService does not call
declareNetworkRequestUnfulfillable at this point.

ConnectivityManager may be migrated to classic service getters that
cache "null" when the service was not available the first time it is
queried, so no system service must query it before it starts.

Bug: 171540887
Test: atest FrameworksNetTests:NetworkProviderTest
Change-Id: I8dadcd0e1360a9464192f330493e13aa69dd9fe2
2020-11-30 12:42:15 +09:00
Lorenzo Colitti
f3963fa279 Allow tests to create TRANSPORT_TEST|TRANSPORT_VPN networks.
This CL allows an app that has the MANAGE_TEST_NETWORKS
permission to create test VPN networks.

The code enforces that such networks can never apply to any UIDs
and thus will never carry any traffic.

Bug: 173331190
Test: passes existing tests, moved tests pass
Change-Id: I5befea0e3b4b6dce4ca0c6a04471a055186b644c
2020-11-27 15:35:38 +09:00
Lorenzo Colitti
129c01eabf Move applying underlying caps from Vpn to ConnectivityService.
Add support to ConnectivityService to track underlying networks
directly instead of through the Vpn class.

1. Communicate all information necessary to propagate underlying
   network capabilities to ConnectivityService via NetworkAgent.
   This includes:
   a. Underlying networks:
      - Add SystemApi for NetworkAgent to declare its underlying
        networks to ConnectivityService, and use it in Vpn.
      - Add a new declaredUnderlyingNetworks member to
        NetworkAgentInfo and store the underlying networks in it.
	Move propagation of underlying network capabilities to
	mixInCapabilities, which is a natural place for it.
   b. "Always metered" bit:
      - Communicate this to ConnectivityService via the existing
        NOT_METERED capability. Store it in a new declaredMetered
	boolean in NetworkAgentInfo to separate it cleanly from
	the NOT_METERED bit in the capabilities, which depends on
	whether the underlying networks are metered or not. In
	order to ensure that this is only ever changed when a NC
	update is received from a NetworkAgent, define a new
	processCapabilitiesFromAgent similar to the existing
        processLinkPropertiesFromAgent.

2. Ensure that propagating underlying network capabilities does
   not read the VPN's NetworkCapabilities. In order to do this,
   ensure that all relevant information on underlying networks
   and metering is sent to ConnectivityService at NetworkAgent
   registration time. CS still calls Vpn#updateCapabilities when
   a user is added/removed, but that is deleted in a future CL.

3. Slightly generalize propagating underlying network
   capabilities because there may be other network types that
   also have underlying networks that aren't VPNs (e.g., VCN).
   - Introduce a new supportsUnderlyingNetworks() boolean method
     in NetworkAgentInfo.
   - Rename updateAllVpnsCapabilities to
     propagateUnderlyingNetworkCapabilities.

This commit does not move the actual logic of calculating the
underlying capabilities out of Vpn.java. That can be done in a
subsequent change once CS stops calling getUnderlyingNetworks().

This commit also does not modify any of the other code in CS that
directly accesses VPNs' underlying networks.

Bug: 173331190
Test: passes existing tests in ConnectivityServiceTest
Test: CTS test in r.android.com/1511114
Test: atest CtsNetTestCases:Ikev2VpnTest HostsideVpnTests
Change-Id: I5f76cb1aa4866efed3d5c4590e931fdb0e994f8d
2020-11-27 15:35:38 +09:00
Benedict Wong
3b0f85c921 Merge "Expose MIN_MTU_V6 as a public, @hide constant" 2020-11-20 01:30:18 +00:00
Sarah Chin
b4b3693558 Merge "Clarify documentation on TEMP_NOT_METERED API" 2020-11-19 17:50:35 +00:00
Sarah Chin
2cb619acfd Clarify documentation on TEMP_NOT_METERED API
Test: build
Bug: 165337240
Change-Id: Ifc0843b529e7a205b0e1caf98420adfc377c28e7
2020-11-19 01:15:48 -08:00
Benedict Wong
f3215117bc Expose MIN_MTU_V6 as a public, @hide constant
MIN_MTU_V6 is increasingly used, and the LinkProperties version is used
as a source of truth for the constant.

Bug: 163602123
Test: atest FrameworksNetTests
Change-Id: I67134cd4fb7e2cf59c36947b62f681ac9b94ea4a
2020-11-19 00:21:53 -08:00
Lorenzo Colitti
1ea1cda675 Minor fixes to NetworkCapabilities#toString.
1. The current code only prints the array of administrator UIDs
   if it's empty. This is clearly an oversight. Print it only if
   it's non-empty.
2. Only print requestor UID and package name if they are set.
   This makes output shorter in the common case that they are
   unset.
3. Reorder the output at the end: group all UIDs together, and
   place SSID and private DNS broken bit after that.
4. Make the private DNS broken indication a single word instead
   of a sentence. This saves space and makes it easier to write
   regexps.

New format:
... SignalStrength: -72 OwnerUid: 1000 AdminUids: [1000] SSID: ...
... Uid: 1000 RequestorUid: 1000 RequestorPkg: android ...

Test: manual
Change-Id: I2f5ccc1d9e4af6ddacc4d193185a17723822972b
2020-11-18 17:10:11 +09:00
James Mattis
82d1b93dfd Updating network preference comments
Updating comments for network preferences to better clarify that
preferences which include more than one network type will then rely on
scoring to determine which of those networks are chosen.

Bug: 171795464
Test: atest FrameworksNetTests
Change-Id: I9eb5683f2cd69281bbee9fb70028d45f07720914
2020-11-09 21:06:09 -08:00
Mathew Inwood
8b7da06e85 Merge "Add maxTargetSdk restriction to unused APIs." 2020-11-09 14:41:20 +00:00
James Mattis
356a879404 Adding API stubs for application network routing
Bug: 171795464
Test: atest FrameworksNetTests
Change-Id: Ib055aa37a7bf0c48c335307afc2258aa869c4267
2020-11-06 00:08:13 -08:00
Mathew Inwood
e1a17baab9 Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
2020-11-04 09:45:53 +00:00
Chalard Jean
3a7110e160 Fix a bug where modern network agents start in UNKNOWN
Modern network agents are supposed to have the following
lifecycle :
• Construct the agent
• Declare itself to connectivity by calling #register()
• Possibly do some setup
• Declare connected by calling #markConnected()
• Declare disconnected by calling #unregister()

Internally ConnectivityService still manages the state
with deprecated NetworkInfo, which has a lot of possible
detailed states, most of which are now unused. Internally,
the steps above translate to the states below :
• When the agent calls #register() it starts in state
  CONNECTING
• When it calls #markConnected() it goes to CONNECTED
• When it calls #unregister() it goes to DISCONNECTED which
  triggers the flow that disconnects it immediately
• ConnectivityService also synthesizes the SUSPENDED state
  under some situations, but that's not relevant here.

The translation above is done by the NetworkAgent class,
which translates #register(), #markConnected() and
The only valid lifecyle for new agents is thus :

CONNECTING → CONNECTED → disconnect
                 ↕         ↑
             SUSPENDED ───┘

Note that in the above scheme, there is no space for the
UNKNOWN state, which is only used by legacy network agents.
However, the constructor for NetworkInfo still starts with
UNKNOWN. Ideally the constructor for NetworkInfo would set
the info to CONNECTING instead, but this would be a very
visible change in behavior affecting many apps (especially
their tests), so for backward compatibility we can't do
that.

New network agents however don't expose their NetworkInfo
to the client code, so they can just be made to start in
CONNECTING the way it was meant.

Note that this didn't really have a concrete impact beyond
printing some logs as by and large the ConnectivityService
code handles UNKNOWN and CONNECTING the same way, or more
exactly it handles transitions to CONNECTED from UNKNOWN
and CONNECTING in the same way. The exception to this is
VPNs, which are not using the new agent API yet, and the
upcoming conversion is why this fix is actually needed now.

Bug: 170904131
Test: FrameworksNetTests NetworkStackTests
Test: new test in aosp/1460705
Change-Id: Ib7d906a7b29a0b9f000b90bc78558a7402852fa3
2020-10-29 12:30:44 +00:00
James Mattis
4fcbb03489 Add OEM_PRIVATE NetworkCapability
Adding network capability to be used with networks to be only used by
OEM apps.

Bug: 171505922
Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest
Change-Id: Ib55ebec0e178b6317d92f17e1aff060dacdfb2b1
2020-10-27 13:14:06 -07:00
Anton Hansson
64b87b5aa5 Merge "Remove @TestApi from @SystemApi symbols" 2020-10-20 13:45:13 +00:00
Aaron Huang
a2d7ef0a8a Merge "Create service-connectivity.jar" 2020-10-20 06:09:41 +00:00
Anton Hansson
9a6fd906e6 Remove @TestApi from @SystemApi symbols
I ran these commands:
    cd frameworks/base
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@SystemApi[\s\n]+(\@\w+[\s\n]+)?\@TestApi/\@SystemApi\1/gs'
    grep -rl '@TestApi' --include '*.java' | xargs perl -i -p0e \
        's/\@TestApi[\s\n]+(\@\w+[\s\n]+)?\@SystemApi/\1\@SystemApi/gs'

Bug: 171179806
Test: m checkapi
Change-Id: I772790b783b0a8730b8bf680c9e569a886b8d789
Merged-In: I772790b783b0a8730b8bf680c9e569a886b8d789
2020-10-19 16:41:01 +01:00
Chalard Jean
bc1d304dcf Merge "Remove unused methods from LinkProperties." am: 561107dd24
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1448415

Change-Id: I7adcc9920cc2bdebe9a1dc22f32ce0955a4524dd
2020-10-19 09:50:44 +00:00
Aaron Huang
9601189364 Create service-connectivity.jar
Create a new target service-connectivity to split
ConnectivityService from services.core.

Add ConnectivityServiceInitializer for initializing
ConnectivityService and add systemReady() in
ConnectivityManager so that SystemServer can call systemReady()
through ConnectivityManager which won't change current behavior.

Bug: 158268939
Test: make target-java, make host-java
      atest FrameworksNetIntegrationTests
      atest FrameworksNetTests
      make, device can boot,
      atest CtsStrictJavaPackagesTestCases
      wifi and mobile data work.
Change-Id: I99401772ba9c1c34adca20040da3c7c72d86ddd9
Merged-In: Ie732bfaf381404af0bb599ca2f421a96e7aa4257
2020-10-16 22:46:14 +08:00
Chalard Jean
4d6c93d315 Remove unused methods from LinkProperties.
LinkProperties.compare{Dnses,ValidatedPrivateDnses,AllRoutes,
AllInterfaceNames} actually have no users.

Test: LinkPropertiesTest
Change-Id: Ic54ab3c5520fbbc2be1309aeaf1e5a7857dbd194
2020-10-16 15:32:19 +09:00
Treehugger Robot
29b63c7ccb Merge "Fix a typo in a comment" am: e7be8034b6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1459885

Change-Id: I9174acc91209d83526901587bf4603d61aa30acc
2020-10-14 11:24:43 +00:00
Chalard Jean
c9fc48652a Fix a typo in a comment
Test: is not necessary for fixing typos in comments
Change-Id: Idf48d2649e728cafda5c1ca32d21102094cf23f5
2020-10-14 04:56:20 +00:00
Xin Li
896aec2ca3 Merge ab/6749736 in stage.
Bug: 167233921
Merged-In: Iecef31f7bf10ad97b7e0075cf302ae94e248474a
Change-Id: I9e9c873bc2e05a0cfe3af0bf74725500f3f108db
2020-10-10 20:38:57 -07:00
Remi NGUYEN VAN
7f3a7512b5 Move IpUtils to frameworks/libs/net
The utility classes are useful for mainline modules and their tests, for
example IpClientIntegrationTest.

Bug: 168868607
Test: m && atest NetworkStaticLibTests
Change-Id: If2b1613aa18a7990391e2d31cc2951ca93f1cf3c
2020-10-05 14:38:19 +09:00
Jeff Sharkey
4610b32762 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Test: none
Bug: 168334533
Exempt-From-Owner-Approval: docs updates
Change-Id: I53003332717baf57dc088b2f6b969cdb1863f65e
2020-09-14 09:59:01 -06:00
Xin Li
37db1eb217 Merge RP1A.200720.011
Bug: 167588565
Merged-In: Iec7a26ecd68aca9c7a38cc8f441197a8237b0c8c
Change-Id: Ia8f5f008bc1f77115b644ab996aedc892fab68e7
2020-09-02 12:34:37 -07:00
Xin Li
4afc1e6669 Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
2020-08-31 21:21:38 -07:00
Junyu Lai
c4aaac8af6 Merge "Notify the keepalive is stopped after the slot has been released" 2020-08-28 10:12:44 +00:00
junyulai
75125f2131 Notify the keepalive is stopped after the slot has been released
Currently, the callbacks of stopping were fired when stop procedure
is started, because the upper layer apps only care about the reason
of stopping instead of stopping result. Thus, there is no need to
wait for the result comes back. However, this behavior generates
races if apps want to re-start keepalive immediately since the
resources are not released yet.

Fix: 134891441
Fix: 140305589
Test: atest com.android.server.ConnectivityServiceTest#testPacketKeepalives \
      --rerun-until-failure 1000

Change-Id: I987776a9211a50e964c4675b747bc10e203750f1
2020-08-20 11:00:08 +08:00
Chalard Jean
6f82a0f220 Revert "Revert "Move Inet[4]AddressUtils to libs/net"" am: 059356d83f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1382497

Change-Id: Ia5e7e926bc3a9af8b03f8970738e6abe4c6d15b6
2020-08-07 06:59:26 +00:00
Chalard Jean
059356d83f Revert "Revert "Move Inet[4]AddressUtils to libs/net""
This patch is still needed and should go in now that the
error is fixed.
The patch was submitted into rvc-dev and is already in
rvc-dev-plus-aosp (patch in in ag/11923559, revert
skipped in ag/12072199). A follow-up will remove the
unused services.net-module-wifi target.

Test: originally tested in aosp/1324109
Test: m; manual: flashed, wifi and telephony working
Test: atest NetworkStackCoverageTests
Change-Id: I1074eedb0b0f156a1135e11210ec102de15ea674
Merged-In: Icd141a992c46290c74929785e261a1cd57bc001b
2020-08-07 03:31:04 +00:00
Alex Light
d9b1b9daeb Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 162536543
Test: Treehugger
Change-Id: I971050a2665c177870ff257bd0f41343db702892
Merged-In: I971050a2665c177870ff257bd0f41343db702892
2020-08-03 17:04:58 +00:00
Alex Light
2349cf350b Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 162536543
Test: Treehugger
Change-Id: I971050a2665c177870ff257bd0f41343db702892
2020-07-31 08:18:33 -07:00
Lorenzo Colitti
1c9c0c1514 Set the NetworkInfo subtype to 0.
For non-telephony networks, this was always set to 0 before R.
In R, it is currently set to the same value as the network type.
This is incorrect because the two have different namespaces.
or example, currently, any network of type WIFI (==1) will have
a subtype of NETWORK_TYPE_GPRS (==1). Similarly, all ETHERNET
networks will have subtype NETWORK_TYPE_1XRTT, all VPN networks
will have a subtype of NETWORK_TYPE_TD_SCDMA, etd.

Bug: 161653721
Test: builds, boots
Change-Id: I07e111c1762e0021c931cefc27f193f78578748b
(cherry picked from commit a40ff70cad00a6c298e07c2c38e95d58074a7157)
2020-07-29 04:04:42 +00:00
Junyu Lai
ca54fa5a5c Merge "Gracefully handle integer overflows." am: cdb1f03144 am: fe6c5793ce
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1316217

Change-Id: I0bba17d0367ebf4e1c868a8cc7471366bc7a4408
2020-07-29 01:55:23 +00:00
Junyu Lai
cdb1f03144 Merge "Gracefully handle integer overflows." 2020-07-29 01:19:07 +00:00
Lorenzo Colitti
fddfe676fd Set the NetworkInfo subtype to 0. am: fd43392b25
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12246826

Change-Id: Ida8cd0788ae34f4861fbcb958163b5074258c6ac
2020-07-28 18:05:15 +00:00
Chiachang Wang
6d70190fcd Merge "Update language to comply with Android's inclusive language guidance" am: f702025bdf am: ef723b7617
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1373160

Change-Id: I9318abb0233e7b8847466914724eeaae769ea9c8
2020-07-28 11:19:47 +00:00
Chiachang Wang
f702025bdf Merge "Update language to comply with Android's inclusive language guidance" 2020-07-28 10:51:53 +00:00
Lorenzo Colitti
fd43392b25 Set the NetworkInfo subtype to 0.
For non-telephony networks, this was always set to 0 before R.
In R, it is currently set to the same value as the network type.
This is incorrect because the two have different namespaces.
or example, currently, any network of type WIFI (==1) will have
a subtype of NETWORK_TYPE_GPRS (==1). Similarly, all ETHERNET
networks will have subtype NETWORK_TYPE_1XRTT, all VPN networks
will have a subtype of NETWORK_TYPE_TD_SCDMA, etd.

Bug: 161653721
Test: builds, boots
Change-Id: I07e111c1762e0021c931cefc27f193f78578748b
2020-07-28 09:20:19 +00:00
Chiachang Wang
3b9549f408 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code
for reference.

Bug: 161896447
Test: m
Change-Id: I6c3c03c0c2d1302af6d5245486823c13a3432900
2020-07-28 15:36:30 +08:00
Pavan Kumar M
e55ab87e5d Gracefully handle integer overflows.
Avoid recording negative data by doing integer-based
math as much as possible, but switch to double-based
math if we detect that we'd end up causing an overflow.

Test :

    - Builds, Boots
    - High data throughput scenarios
    - NetworkStatsHistoryTest, NetworkStatsCollectionTest,
      NetworkStatsTest

Bug: 119527458
Change-Id: I55d4aa649bea3ae201ad513074ff2b71cb918dad
2020-07-28 11:36:49 +05:30
Aaron Huang
8f98e732a0 Merge "Remove ProxyInfo(String) and update callers to use ProxyInfo(Uri)" am: c36f17d32e am: 5463bbece5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1146757

Change-Id: If60a348768c507153c1a9038953b2f6c29fc8f03
2020-07-17 06:05:38 +00:00
Aaron Huang
c36f17d32e Merge "Remove ProxyInfo(String) and update callers to use ProxyInfo(Uri)" 2020-07-17 05:40:31 +00:00
Chalard Jean
9aa3127449 Add some more public doc for MacAddress
Bug: 140807677
Test: doc-only change
Original-Change: https://android-review.googlesource.com/1354447
Merged-In: I0f6e59eda42fd92ec34db0e9bc2d26d2e83d41d0
Change-Id: I0f6e59eda42fd92ec34db0e9bc2d26d2e83d41d0
2020-07-08 09:38:37 +00:00
Chalard Jean
074d5a8e8a Merge "Add some more public doc for MacAddress" am: a9c0a7e2e2 am: 3b3c6ffdc2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1354447

Change-Id: I5c9061fa832c75c9e0476c54bacec3deb114a96d
2020-07-08 05:38:59 +00:00
Aaron Huang
ffb76492e0 Remove ProxyInfo(String) and update callers to use ProxyInfo(Uri)
Update all callers to use ProxyInfo(Uri) and remove ProxyInfo(String).

Bug: 160557668
Test: build pass
      atest FrameworksNetTests

Change-Id: I4c980764c8839c48acf03208bb68cd53eb910121
2020-07-06 11:59:27 +00:00
Chalard Jean
ded38fda42 Add some more public doc for MacAddress
Bug: 140807677
Test: doc-only change
Change-Id: I0f6e59eda42fd92ec34db0e9bc2d26d2e83d41d0
2020-07-04 09:01:58 +09:00