Commit Graph

315 Commits

Author SHA1 Message Date
Chalard Jean
cdd68bcc3a [NS04] Introduce Network Offers and their callbacks
This patch introduces the concept of a network offer that
providers send to Connectivity to register for relevant
requests. This lets them see only requests that they can
hope to satisfy considering their capabilities and score
filters.

This is meant to replace the filtering mechanism currently
implemented by NetworkFactory. The reason for replacing
this mechanism is that the old mechanism does caps and
score filtering on the factory side, which requires these
two filters to be contextless and available system-wide,
including in separate processes from the system server.
These constraints severely limit and complexify in
particular what the score comparisons may look like. In
the past the score comparison was only integer-based,
making the code duplication not much of a problem, but as
this scheme is becoming unsustainable by spreading the
complexity of the selection across the entire stack, a
centralized mechanism is now necessary.

This patch only introduces the new objects and has CS
keep track of them, but does not actually use them yet.
Followup patches will implement the logic of calling
the offer callbacks.

Test: FrameworksNetTests NetworkStackTests FrameworksWifiTests
Bug: 167544279
Merged-In: Idec1fe8eb4ac6f562bf098e3dd470f11024d04f2
(clean cherry-pick)

Change-Id: Idec1fe8eb4ac6f562bf098e3dd470f11024d04f2
2021-05-13 13:20:43 +00:00
paulhu
84b4e1bbb1 Add RESTRICTED_ALLOWED_APPS setting
This setting is OEM upstream requirement for third party apps
using restricted networks.

Bug: 185149952
Test: atests FrameworksNetTests
Change-Id: I5e16b46cf2935f38ee1e516bb8b85fa487cf9f61
2021-05-13 10:09:31 +08:00
Lucas Lin
6813b1b794 Merge "Update PrivateDnsMode from StringDef to IntDef" 2021-05-12 17:09:50 +00:00
Chalard Jean
d09b89bca8 Merge "Allow any transport with TEST if the network is restricted" 2021-05-12 13:57:31 +00:00
Remi NGUYEN VAN
aaf18dd305 Merge "Use jniThrowErrnoException from JNIHelp" 2021-05-12 13:12:32 +00:00
Remi NGUYEN VAN
8ec3067e56 Merge "Move NetworkUtils JNI out of core/jni" 2021-05-12 13:12:09 +00:00
Remi NGUYEN VAN
d93c6b7585 Merge "Build framework-connectivity using module_current" 2021-05-12 13:11:22 +00:00
Lorenzo Colitti
172abc194e Merge "Rename unwanted capabilities to forbidden capabilities." 2021-05-12 09:00:17 +00:00
David Su
10ee7c54c2 Merge "Emphasize possibility of multiple networks with same transport" 2021-05-11 15:51:28 +00:00
Remi NGUYEN VAN
5accf986ea Use jniThrowErrnoException from JNIHelp
Use the jniThrowErrnoException that is available in JNIHelp, instead of
reimplementing in NetworkUtils.

Bug: 179229316
Test: device boots and has connectivity
Merged-In: I257a9d55ce1f5a7c588e209b4a89d3e7a3e09994

Change-Id: I257a9d55ce1f5a7c588e209b4a89d3e7a3e09994
2021-05-11 14:18:27 +00:00
Remi NGUYEN VAN
d7ab21a379 Move NetworkUtils JNI out of core/jni
Keep the utilities included via a library, but move them out of
core/jni, and prepare a library to package them together with
framework-connectivity.

Also remove unnecessary dependencies in framework-connectivity.

Bug: 171540887
Test: device boots and has connectivity

Merged-In: I0b55dfe92f3cb6e848d79ac7953756f39aaa2597

Change-Id: I0b55dfe92f3cb6e848d79ac7953756f39aaa2597
2021-05-11 13:02:39 +00:00
Remi NGUYEN VAN
0c00f40374 Build framework-connectivity using module_current
framework-connectivity needs to build only against stable APIs.

Bug: 171540887
Test: m framework-connectivity.impl
Merged-In: I2d51d37d067bf6fe86e4dedf05855a2dd67ed57c

Change-Id: I2d51d37d067bf6fe86e4dedf05855a2dd67ed57c
2021-05-11 13:00:42 +00:00
Lorenzo Colitti
1291166c38 Rename unwanted capabilities to forbidden capabilities.
Addresses API council feedback.

Bug: 184890428
Test: atest FrameworksNetTests CtsNetTestCases
Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device
Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
2021-05-11 17:46:13 +09:00
Chalard Jean
0fb0c47869 Allow any transport with TEST if the network is restricted
This will allow CTS to add the WIFI transport and others,
letting them test a number of essential features of the
ranking algorithm.
It's relatively safe because restricted networks can never
become the default, and NOT_RESTRICTED is a default
capability so very few apps would be affected by the shell
creating such a network.

Bug: 184037351
Test: NetworkScoreTest (which is under review)
Change-Id: I21055dc613fead6130adc2122f2cdd0af9b49adf
2021-05-11 15:42:10 +09:00
lucaslin
b1ff1b2139 Update PrivateDnsMode from StringDef to IntDef
Update PrivateDnsMode from StringDef to IntDef because IntDef is
the normal way of representing multiple choices in public API.
Also update other related files.

Bug: 185311744
Test: 1. make update-api
      2. atest FrameworksNetTests CtsNetTestCases CtsNetTestCasesLatestSdk
      3. atest FrameworksServicesTests:DevicePolicyManagerTest
Change-Id: I23e7ec140066979726d769cabc5f7057bb2167e6
Merged-In: I23e7ec140066979726d769cabc5f7057bb2167e6
    (Cherry-picked from ag/14227609)
2021-05-05 03:19:51 +00:00
Junyu Lai
8ee3a33ee6 Merge "Add doc to getNetworkCapabilities" 2021-05-03 03:16:24 +00:00
Chalard Jean
53a8bccf94 Add doc to getNetworkCapabilities
Test: doc-only change
Fixes: 158092418
Change-Id: Ic20fb55e1bdd4e836468794d1f86d3e9d0bc5965
2021-04-30 11:24:00 +00:00
Treehugger Robot
bd9d954805 Merge "Rename getAllNetworkStateSnapshot which should be pluralized" 2021-04-29 04:40:51 +00:00
Chiachang Wang
79a90c3b8e Merge "Address API review feedback" 2021-04-26 00:22:27 +00:00
Chiachang Wang
6ec9b8daed Address API review feedback
Address API review feedback to:
 - Rename NetworkAgent#setTeardownDelayMs to
   NetworkAgent#setTeardownDelayMillis
 - Use getters instead of fields in VpnTransportInfo
 - Rename registerDefaultNetworkCallbackAsUid to
   registerDefaultNetworkCallbackForUid in ConnectiivityManager

Bug: 183972850
Bug: 185246410
Fix: 184735863
Test: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
Merged-In: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
2021-04-23 02:46:05 +00:00
Aaron Huang
ee78b1fbbf Rename getAllNetworkStateSnapshot which should be pluralized
Address API review feedback, ConnectivityManager#getAllNetworkStateSnapshot
should be pluralized so rename the method to getAllNetworkStateSnapshots

(cherry picked from ag/14221105)
Bug: 183972554
Test: make, FrameworksNetTests
      FrameworksServicesTests
Merged-In: Ic18d17d05984fa2466c962c7843c0ef7183ce77c
Change-Id: Ic18d17d05984fa2466c962c7843c0ef7183ce77c
2021-04-22 17:45:22 +08:00
Treehugger Robot
935946812a Merge "[VCN19] Rename get/setSubIds to get/setSubscriptionIds" 2021-04-22 04:43:26 +00:00
Treehugger Robot
7056276574 Merge "Do not deduce VCN capability if Builder is derived from request" 2021-04-21 14:06:14 +00:00
junyulai
561a7467c8 Do not deduce VCN capability if Builder is derived from request
If the caller constructed the builder from a request, it means
the user might explicitly want the capabilities from the request.
Thus, the NOT_VCN_MANAGED capabilities should not be touched
later.

Test: TH
Fix: 185876442
Change-Id: I92037cc8547fb72de12d6b6402f060f6c98e1853
2021-04-21 19:10:28 +08:00
Treehugger Robot
e3a86b7ebf Merge "Add the related extra information in the javadoc" 2021-04-21 08:22:43 +00:00
lucaslin
311b690343 Add the related extra information in the javadoc
Bug: 185876442
Test: make docs
Change-Id: Ib0abc43e2009dbf5ee7b6c2a076424834d3d53f2
2021-04-21 10:43:15 +08:00
junyulai
2217becf8d [VCN19] Rename get/setSubIds to get/setSubscriptionIds
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215036
Merged-In: I9d90df5fc13b36d2cdc4920b456dcc87fcd2b3a7
Change-Id: I9d90df5fc13b36d2cdc4920b456dcc87fcd2b3a7
  (cherry-picked from ag/14198665)
2021-04-19 17:41:01 +08:00
Junyu Lai
8ef8d57e18 Merge "[VCN20] Change requestBackgroundNetwork argument order" 2021-04-16 16:04:31 +00:00
Lorenzo Colitti
fe3676b6f2 Merge "Don't expose raw IBinder APIs." 2021-04-16 07:22:13 +00:00
junyulai
05738ae9d3 [VCN20] Change requestBackgroundNetwork argument order
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215095
Merged-In: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
Change-Id: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
  (cherry-picked from ag/14198667)
2021-04-16 00:16:21 +08:00
Lorenzo Colitti
34a294fc76 Don't expose raw IBinder APIs.
APIs should not expose raw IBinder objects.

Fix: 184735751
Test: builds, boots
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCases:android.net.cts.DnsResolverTest
Change-Id: Ia0c4170def31123f0b79318fec2cfe02e4fcd3bf
2021-04-15 18:47:21 +09:00
Chiachang Wang
52a55928a8 Remove hidden method link in public addRoute API
The build will complain after moving connectivity framework code
outside framework because the hidden methods/members accesses are
not allowed anymore. Link to a hidden class will not work since
it's not visible in public.

Bug: 182859030
Test: make docs
Change-Id: I5726f80be7cf92b648ce851d9601d5f58bc2b647
2021-04-15 16:21:00 +08:00
Lorenzo Colitti
1295ddf15e Add @RedactionType annotations to VpnTransportInfo.
This is in response to API council feedback.

Test: m
Bug: 185226718
Change-Id: I63d7249e7d14ac00558f311a3583f6adbf80e3d9
2021-04-14 00:28:19 +09:00
Chiachang Wang
34d1abd51d Merge "Make getUid a method on UserHandle itself instead of static" 2021-04-13 08:15:47 +00:00
Chiachang Wang
94335a3198 Merge "Rename APIs in NetworkAgentConfig.Builder" 2021-04-12 14:10:46 +00:00
Chiachang Wang
ef8132e88d Rename APIs in NetworkAgentConfig.Builder
As API review feedback, rename disableProvisioningNotification()
to setEnabledProvisioningNotification and disableNat64Detection()
to setEnabledNat64Detection. Also, update code in caller side
accordingly.

Bug: 184735772
Test: make update-api ; atest FrameworksNetTests
Change-Id: If7305634863d1503c967e5593ebd0c8af2174bea
2021-04-12 17:27:47 +08:00
paulhu
71824f0d35 Remove TcpRepairWindow from module-lib API
Both TcpRepairWindow and TcpKeepaliveController(user) are in the
connectivity module, so TcpRepairWindow doesn't need to be
the module-lib API. Thus, remove TcpRepairWindow from
module-lib API.

Bug: 172183305
Test: m update-api
Change-Id: I8fde726f8ad73637e6deab69ea83b3699bb2cf45
2021-04-12 14:26:55 +08:00
Chiachang Wang
612cc034a1 Make getUid a method on UserHandle itself instead of static
This commit addresses the API review feedback that getUid()
will be better to make it be a method on UserHandle itself
rather than a static method.

Update as it is and update the corresponding usages.

Fix: 184735865
Test: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I33844309224d84764704255d251fadc8940202ca
2021-04-09 08:33:07 +08:00
Remi NGUYEN VAN
8ee838ce27 Merge "Improve documentation on simulateDataStall" 2021-04-09 00:21:34 +00:00
Remi NGUYEN VAN
9304a15955 Merge "Set ParseException constructors as public" 2021-04-09 00:20:33 +00:00
Remi NGUYEN VAN
b8810ea84d Merge "Replace fields with getters in keepalive API" 2021-04-09 00:20:13 +00:00
Remi NGUYEN VAN
5fe5503275 Merge "Add RequiresPermission to TestNetworkManager" 2021-04-09 00:19:51 +00:00
Remi NGUYEN VAN
e062de00c8 Merge "Use String in CaptivePortalData underlying types" 2021-04-09 00:17:59 +00:00
James Mattis
703ee9ae09 Merge "Adding OEM Network Preferences for testing" 2021-04-08 20:51:05 +00:00
Remi NGUYEN VAN
16d68bae63 Use String in CaptivePortalData underlying types
The venue friendly name comes from the network, and only plain strings
should be used in practice. writeCharSequence is also not usable in
CaptivePortalData, as it must build using module_api.

Use a String as the underlying type in CaptivePortalData, keeping
CharSequence in the API for consistency with UI-related elements.

This brings CaptivePortalData in line with downstream branches.

Bug: 183174863
Test: atest FrameworksNetTests
Merged-In: Ifa3ea9aae0cabf5757791c4ae13e6f551759ed97
Change-Id: Ic662d3b546d52f825f9c3a24c5e0d4ba03818ab0
2021-04-08 08:23:20 +00:00
Remi NGUYEN VAN
d2d60c6aa6 Improve documentation on simulateDataStall
Explain that:
 - The method does not cause an actual data stall.
 - The detectionMethod parameter refers to
   ConnectivityDiagnosticsManager.DataStallReport constants (which
   already use an IntDef).
 - timestampMillis is relative to SystemClock.elapsedRealtime.

Fixes: 183972768
Test: m
Change-Id: I2eeb79e0e8ec6e8fd3b8fe1dcb1abbf2e6338983
2021-04-08 16:30:25 +09:00
Remi NGUYEN VAN
d8d625c5db Add RequiresPermission to TestNetworkManager
All API methods in TestNetworkManager require the MANAGE_TEST_NETWORKS
permission.

Fixes: 183972672
Test: m
Change-Id: Ic5929c24ea88d7259d367a81fec8f223a2e3ecb0
2021-04-08 16:12:23 +09:00
Remi NGUYEN VAN
e236fe9e84 Set ParseException constructors as public
As there is no strong reason to keep the constructors module-lib, set
them as public API.
This is in response to API feedback.

Fixes: 183446251
Test: m
Change-Id: I01daa6f6f8095f7a4db94d1ca05f913166939df3
2021-04-08 15:57:31 +09:00
Remi NGUYEN VAN
c86653cf56 Replace fields with getters in keepalive API
General guidance is to have getters in the API instead of fields.

Fixes: 181014882
Test: m
Change-Id: Id4bfc447701e8d0380163047779fbba043f17b6f
2021-04-08 14:06:53 +09:00
Aaron Huang
ae4646f514 Merge "Remove Network, NetworkRequest metrics from jobscheduler" 2021-04-08 02:27:05 +00:00