Commit Graph

312 Commits

Author SHA1 Message Date
Sooraj Sasindran
e7aee2736e Add a method to apply a set of network preferences to a user profile
Add a method to apply a set of network preferences to a user profile

Bug: 194332512
CTS-Coverage-Bug: 211133973
Test: CTS
Change-Id: I97730ea14e7c96922236fd77a591e5acadd875ba
2022-01-11 21:07:23 -08:00
Anton Hansson
df40109271 Qualify references to WifiNetworkSuggestions
Connectivity's metalava invocation does not depend on framework-wifi,
so these references fail to resolve, and as a result metalava currently
removes the import.

Fully qualify the references instead, to avoid both metalava trying
to resolve the dependency, and having to depend on framework-wifi just
for javadoc.

Bug: 186197911
Test: build the sdk (with connectivity module stubs as input)
Change-Id: I7129821b9a0d08d06f8e977a3c17fa5f5f6f9cee
2021-10-20 11:34:48 +01:00
Chalard Jean
7f40360e32 Merge "Add a small usage comment" am: a898f0a039
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1844182

Change-Id: Ibe27d64cd16a2ef44d6a41b94f81a0daa06c523b
2021-10-05 11:14:01 +00:00
Chalard Jean
025f40bc4f Add a small usage comment
Test: comment-only change
Bug: 201972281
Change-Id: Ifbdadbaacfaf364f6770e56ccb816eb3269003d5
2021-10-04 18:33:36 +09:00
Chiachang Wang
e129460c46 Merge "Remove reference when active listener is unregistered" am: a39b107812
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1833145

Change-Id: I7b05b33c2a0c02c298d42ab4891ce543fe5ab9bd
2021-10-01 00:54:16 +00:00
Chiachang Wang
a39b107812 Merge "Remove reference when active listener is unregistered" 2021-10-01 00:37:00 +00:00
Chiachang Wang
2de41686e7 Remove reference when active listener is unregistered
The registered listeners are added into internal ArrayMap as a
reference but are not removed when the listeners are
unregistered. The actions for registration should be done in
pairs.

Test: atest FrameworksNetTests
Change-Id: Id9e674f5104d1471dd81224b6a271a8a92172e34
2021-09-30 10:30:35 +00:00
Chalard Jean
9f61ab08bd Merge "Small doc improvement" am: a997db7f40
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1838427

Change-Id: Id3afa12d046e1666978840fee0918f4f160a21c9
2021-09-30 08:01:44 +00:00
Chalard Jean
0d05151b5c Small doc improvement
Test: comment-only change
Bug: 191744296
Change-Id: I80447783c9fd89f3b6685a4276cc555a7075a70f
2021-09-28 15:31:15 +09:00
Chiachang Wang
7c04a51a95 Merge "Correct the calling method in removeDefaultNetworkActiveListener" am: a6e3069c27
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1827914

Change-Id: I69a199d8253aca744a43b04e89a88da65f6bd8b9
2021-09-16 06:39:32 +00:00
Chiachang Wang
e54c8199aa Correct the calling method in removeDefaultNetworkActiveListener
The removeDefaultNetworkActiveListener should do the
unregisteration but it's incorrectly calling
registerNetworkActivityListener into the ConnectivityService.

Bug: 199753782
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I65a2ddc82989d736316d51f5058e707f5b261a82
2021-09-16 02:25:48 +00:00
lifr
538f079d20 Cleanup the public API getActiveNetworkForUid on AOSP
In order to make ConnectivityService the mainline module in ANDROID 12,
The earliest ConnectivityService API getActiveNetworkForUid was exposed.

But after that public api getActiveNetworkForUid and all callers
(Outside the module) has been deleted or replaced in android 12
version. So we should delete the public API in AOSP to keep the APIs
of Android 12 & AOSP consistent and also avoid using it again in AOSP.
The commit is equivalent to ag/14029494, but done in a different repo.

Bug: 183465229
Test: atest ConnectivityControllerTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: I50a39d6391c88bbb914a63fdb17bae6851591c01
2021-07-14 21:13:45 +08:00
Remi NGUYEN VAN
df1ab0aa2b Merge "Remove workarounds to use core platform API" am: 78dcc73e4c am: 31dbe8b122
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1754889

Change-Id: Ib01bbc0cfec540a6e811ac874c4e731734490dfb
2021-07-02 04:44:46 +00:00
Remi NGUYEN VAN
b2e919f9da Remove workarounds to use core platform API
Core platform API stubs are now correctly included in module_current and
system_server_current, so workarounds used to use such APIs can be
removed.

OsCompat and InetAddressCompat were only necessary because manually
adding the stubs did not resolve the problem for classes that had
public API stubs, which shadowed the module API stubs.

The manual stubs dependency was already removed in another change. Also
remove the service jar dependency on android_system_server_stubs_current
as it is already included in sdk_version system_server_current.

Bug: 183097033
Test: atest CtsNetTestCases

Change-Id: Id448be03b679f832edb24f1b77f471227faf5268
2021-07-02 10:05:07 +09:00
Chiachang Wang
403836f671 Merge "Provide a way to override the avoid bad wifi configuration" am: 38e8c2c94b am: 4ef85d615b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1733788

Change-Id: Ibe05bc988f0020eec8485023c3529bcc1696bd80
2021-06-23 02:08:44 +00:00
Chiachang Wang
38e8c2c94b Merge "Provide a way to override the avoid bad wifi configuration" 2021-06-23 00:48:17 +00:00
Chiachang Wang
6eac9fb787 Provide a way to override the avoid bad wifi configuration
ConnectivityManager.setAvoidUnvalidated only works if the
config_networkAvoidBadWifi configuration is set to 0 and the
NETWORK_AVOID_BAD_WIFI setting is unset. There is no easy way
for a testing app to temporary set a test value to verify the
behavior of the API. Thus, add a mechanism to allow test app
to set a period of time to temporary unstrict the resource
configuration, i.e. Temporary simulate config_networkAvoidBadWifi
configured to 0.

Bug: 186061922
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: If772078c61a9b12926f104d5dfc9c9071e844732
2021-06-22 14:54:02 +08:00
Remi NGUYEN VAN
d061ad4a60 Merge "Initialize TetheringManager lazily" am: 7c5902df7e am: b0504221b4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736505

Change-Id: I828ded55c5d478808abffda4259248cfcad7586c
2021-06-21 10:34:22 +00:00
Remi NGUYEN VAN
e4d1cd970e Initialize TetheringManager lazily
Many applications use ConnectivityManager without needing
TetheringManager (or without calling legacy ConnectivityManager methods
that delegate to TetheringManager), so initializing TetheringManager
when ConnectivityManager is created wastes resources.

This is especially true considering that TetheringManager is not trivial
to initialize (worst case scenario it starts a thread and does multiple
Binder requests), and ConnectivityManager is created in ActivityThread
when setting up the app proxy on startup.

Bug: 190556328
Test: atest FrameworksNetTests CtsNetTestCases TetheringTests
Change-Id: I2ba7b8f2b9e1c934cfb082776b8d643f2f2c17e5
2021-06-21 10:59:14 +09:00
Chalard Jean
0354d8c7e0 [NS05] Feed network offer callbacks
The design is very simply expressed :
An offer is needed for a request if and only if that offer
might beat the satisfier for that request.

The implementation of "might beat" is NetworkRanker#mightBeat.

Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests
Bug: 167544279
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I0fe911eef2483ecbac48c733d56283b81538690a
Change-Id: I0fe911eef2483ecbac48c733d56283b81538690a
  (cherry-picked from 7b6a33bd50)
2021-06-07 10:57:48 +00:00
Junyu Lai
9756b5d4f9 Merge changes Ia930b3d3,If614da81,I975a9439
* changes:
  [NS04.8] Address comments from NS04 and NS04.5
  [NS04.7] Reinstate a necessary change
  [NS04.5] Have NetworkOffer embark a provider ID
2021-06-04 20:52:38 +00:00
Chalard Jean
a88fd95294 [NS04.8] Address comments from NS04 and NS04.5
Bug: 167544279
Test: ConnectivityServiceTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: Ia930b3d3e723075cb47e267d589c576ee2d4490f
Change-Id: Ia930b3d3e723075cb47e267d589c576ee2d4490f
  (cherry-picked from ag/13982288)
2021-06-04 02:37:53 +00:00
Chalard Jean
30689b8fd7 [NS04.5] Have NetworkOffer embark a provider ID
...instead of a Messenger.
This will be useful later to compare whether a given offer is
offered by the same provider satisfying a request.

Bug: 167544279
Test: ConnectivityServiceTest
Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Merged-In: I975a9439021c7fa511c50ac982819b6dd146291e
Change-Id: I975a9439021c7fa511c50ac982819b6dd146291e
  (cherry-picked from 148dcce559)
2021-06-04 02:36:58 +00:00
Aaron Huang
cff22949d2 Remove framework-connectivity-annotations library
This library can be removed because the annotations are no longer
used out of module.

@RestrictBackgroundStatus and @MultipathPreference are defined
in connectivity mainline module. Annotate these in non-updatable
platform is not going to be manageable long term. For example,
if the module gets updated and the annotation gets more values
then it's a problem in non-updatable platform. So, it should
not have IntDef cross module boundaries.

Ignore-AOSP-First: AOSP doesn't include this change yet
Bug: 183972925
Test: build
Change-Id: I63f1fde73c4ffdaff9fda914e33cbb5a110ba64e
2021-06-01 06:47:47 +00:00
Orion Hodson
1cb94175ea Use updated NetworkEventDispatcher API
(cherry picked from commit 1f4fa9ffd5)

Bug: 185153775
Test: m

Merged-In: Iae3cec4f751e1f74ccd26db6f22f55cf21dfc04a
Change-Id: I3259d8f23eebca7cb3e8ac507bb8c5b8774e85f1
2021-05-26 16:44:18 +01:00
Orion Hodson
1f4fa9ffd5 Use updated NetworkEventDispatcher API
Bug: 185153775
Ignore-AOSP-First: addressing API council comments with deadline
Test: m
Change-Id: Iae3cec4f751e1f74ccd26db6f22f55cf21dfc04a
2021-05-25 21:25:17 +01:00
Lorenzo Colitti
86714b1fd2 Allow unprivileged NetworkCallbacks to see other UIDs' networks.
Currently, unprivileged apps can call getAllNetworks() to see
all networks on the system, even networks that do not apply to
them. Allow them to do this via NetworkCallbacks as well.

This is the last piece of information that was only available
through getAllNetworks, so this CL deprecates that API.

Bug: 187921303
Test: new unit tests
Test: CTS test in other CL in topic
Change-Id: I30f1021927d3c8eae6525116c61ff4a4acecff6d
2021-05-18 12:24:07 +09:00
Aaron Huang
6a7e6ad55c Add ConnectivityAnnotations class
This change is to address API review, add respective
@IntDef for network policy API.

Typedef cannot be exposed as SystemApi so add
ConnectivityAnnotations class and add an annotation library
so that it can be used in module and platform.

Bug: 183972925
Test: m, build doc target framework-doc-stubs_annotations.zip
      and check the APIs have an attribute IntDef annotation
Change-Id: Ie3ec40cf48818edd422a4550377774eae387d3b2
2021-05-14 10:30:49 +08:00
Chalard Jean
823f81c36e [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
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
lucaslin
57f9ba8b40 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
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
2e3d79675b Merge "Add doc to getNetworkCapabilities" am: 59d89299c9 am: 622e129d00 am: efca123280
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1690668

Change-Id: I0c41878350ffe4015fe9e6034651f50366503dfe
2021-05-03 04:06:34 +00:00
Junyu Lai
59d89299c9 Merge "Add doc to getNetworkCapabilities" 2021-05-03 03:16:24 +00:00
Junyu Lai
8ee3a33ee6 Merge "Add doc to getNetworkCapabilities" 2021-05-03 03:16:24 +00:00
Chalard Jean
070bdd4b77 Add doc to getNetworkCapabilities
Test: doc-only change
Fixes: 158092418
Change-Id: Ic20fb55e1bdd4e836468794d1f86d3e9d0bc5965
2021-04-30 11:24:00 +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
984e51670e Merge "Rename getAllNetworkStateSnapshot which should be pluralized" 2021-04-29 04:40:51 +00:00
Treehugger Robot
bd9d954805 Merge "Rename getAllNetworkStateSnapshot which should be pluralized" 2021-04-29 04:40:51 +00:00
Chiachang Wang
5e2a729668 Merge "Address API review feedback" 2021-04-26 00:22:27 +00:00
Chiachang Wang
79a90c3b8e Merge "Address API review feedback" 2021-04-26 00:22:27 +00:00
lucaslin
57ee606244 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
2021-04-23 21:03:39 +08:00
Chiachang Wang
9075ae36be 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
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
Chiachang Wang
6f7ac6860e Merge "Address API review feedback" into sc-dev 2021-04-23 00:30:51 +00:00
Aaron Huang
da103b3365 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
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
9eea7b3d09 Merge "Add the related extra information in the javadoc" am: f78aabbf82 am: db0c8c32b1 am: 7663d1760d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1681465

Change-Id: I9eb3c2543787a91f211be5eb7b92b66fe696489f
2021-04-21 09:19:13 +00:00
Treehugger Robot
f78aabbf82 Merge "Add the related extra information in the javadoc" 2021-04-21 08:22:43 +00:00
Treehugger Robot
e3a86b7ebf Merge "Add the related extra information in the javadoc" 2021-04-21 08:22:43 +00:00