summaryrefslogtreecommitdiff
path: root/framework/src/android/net/NetworkAgent.java
Commit message (Collapse)AuthorAgeFilesLines
* Make a defensive copy when sending NetworkInfo changeTreehugger Robot2022-04-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The issue scenario is: - Telephony registers a network agent and calls markConnected(). - NetworkAgent set mNetworkInfo to CONNECTED and call queueOrSendNetworkInfo() with mNetworkInfo, but NetworkAgent don't actually send a message to CS yet because the agent is not registered. - Telephony calls unregister because the cellular network is disconnected. - NetworkAgent set mNetworkInfo to DISCONNECTED, overwriting the previous CONNECTED state, and then call queueOrSendNetworkInfo again with mNetworkInfo. Again this doesn't send any message because the agent is not connected. - EVENT_AGENT_CONNECTED arrives. NetworkAgent replies all the messages in mPreConnectedQueue, but NetworkAgent send two DISCONNECTED NetworkInfos eventually. The CONNECTED state should be sent to CS instead of latest state DISCONNECTED. Thus, make a defensive copy when sending NetworkInfo change to prevent state overwriting. Without the NetworkAgent fix, the test will fail with no onAvailable callback. Because the Network has never been martk as CONNECTED. Bug: 228623362 Test: atest FrameworksNetTests CtsNetTestCases Original-Change: https://android-review.googlesource.com/2076406 Merged-In: I11681743d3ff87ff9affd0b7e766894dc5111028 Change-Id: I11681743d3ff87ff9affd0b7e766894dc5111028
* Move the DscpPolicy status constants and IntDef to NetworkAgent.Lorenzo Colitti2022-03-251-1/+42
| | | | | | | | | | As requested by API council. Also fix lint errors in the test. Fix: 217366078 Test: existing tests modified in this CL Change-Id: I8f7cd0e78bf29aeb52ec6a08a5d635d25fa2205d
* Rename destroyAndAwaitReplacement to unregisterAfterReplacement.Lorenzo Colitti2022-03-241-3/+3
| | | | | | | | Rename requested by API council. Fix: 224764301 Test: existing CTS tests updated Change-Id: Ibab9c9cd64bf0dde1e22705e81cff11d356fc719
* Add a NetworkAgent API to indicate that a network will be replaced.Lorenzo Colitti2022-03-141-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is useful for link layers that disconnect but know they will reconnect to a similar network soon, and do not want the device to switch to another network until the reconnect happens. An example is wifi switching to another network that is on a different subnet without the device switching to cellular data. This works by immediately destroying the network, so the link layer can reuse the same interface name for the new network. It would be possible to delay destroying the network until the new network connects, but in practice this does not seem useful, because the if the link layer reuses the interface, then the interface will be undergoing reconfiguration, and will likely not be usable for app traffic. This CL also moves the call to onNetworkDestroyed into destroyNativeNetwork. This is needed to ensure that the new API calls onNetworkDestroyed even though most teardown operations have not happened. This causes onNetworkDestroyed to happen before the netId is marked free, but that shouldn't cause any behavioural changes because netId allocation is an implementation detail of ConnectivityService and is not observable by apps or system components. Bug: 216567577 Test: builds, boots Test: atest FrameworksNetTests FrameworksNetIntegrationTests Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest Test: atest CtsNetTestCases:android.net.cts.NetworkAgentTest#testDestroyAndAwaitReplacement Change-Id: I9f9e022fef66b31a29cce560413321075e992756
* Process DSCP QoS events for policiesTyler Wear2022-01-271-0/+72
| | | | | | | | | | New events to handle adding and removing of DSCP QoS policies. Async indication sends status back to client if the policy has been added, failed, or if the policy limit has been reached. Bug: 202871011 Change-Id: I7988d22ae625ad0dd415927d2943de4a749e6fb8
* Allow network providers to set the linger duration.Chalard Jean2021-06-081-0/+29
| | | | | | | | | | Test: atest CtsNetTestCases:NetworkAgentTest#testSetLingerDuration CTS-Coverage-Bug: 184796264 Bug: 184227264 Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f Merged-In: I7f420faa40863385114705d6971cf00887d03318 Change-Id: I7f420faa40863385114705d6971cf00887d03318 (cherry-picked from ag/14100410)
* Expose sendNetworkScore that takes a NetworkScoreChalard Jean2021-06-081-1/+0
| | | | | | | | | | Bug: 167544279 Test: FrameworksNetTests CTS-Coverage-Bug: 184037351 Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f Merged-In: I5dd9b526c53cb99a5e4ae87f1e3724a7a1870e78 Change-Id: I5dd9b526c53cb99a5e4ae87f1e3724a7a1870e78 (cherry-picked from ag/14048551)
* Address API review feedbackChiachang Wang2021-04-231-4/+4
| | | | | | | | | | | | | | | | | | 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
* Add a setTeardownDelayMs API to NetworkAgent.Lorenzo Colitti2021-03-291-7/+43
| | | | | | | | | | | This allows transports to request that when the network is disconnected, the system should delay destroying the native network until the specified time has passed after the network disconnected. Bug: 181941583 Test: next CL in the stack Change-Id: I9765f1c9d1e55c23c6d583d6709dbe06505975b1
* [TL02]Remove hidden API usage of NetworkAgentlifr2021-03-291-3/+4
| | | | | | | | | | | | The connection service will become the mainline module. Remove the hidden API usage of NetworkAgent. Bug: 170598012 CTS-Coverage-Bug: 170598012 Test: atest FrameworksNetTests FrameworksTelephonyTests atest FrameworksWifiTests Change-Id: I4e4040ae7f94bdf479c7df9ec2ffabafbe06331c Merged-In: I4e4040ae7f94bdf479c7df9ec2ffabafbe06331c
* Add network disconnected callbackChiachang Wang2021-03-261-0/+23
| | | | | | | | | | | | | Create a network callback to notify network agent after the native network being destroyed by netd which means the network is fully disconnected. The NetworkAgent may handle this event after sending disconnect state to ConnectivityService to proceed its pending works that have to be done after it. Bug: 178725261 Test: make update-api Change-Id: I602ff2c688909473b03b72c9407d4286608cff4c Merged-In: I602ff2c688909473b03b72c9407d4286608cff4c
* Merge "Add network created callback support"Chiachang Wang2021-03-251-0/+22
|\
| * Add network created callback supportChiachang Wang2021-03-251-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | Create a network callback to notify network agent after netd has created the network, so that the NetworkAgent may wait for this callback and ensure the pre-work to communicate with netd completed. Bug: 178725261 Test: make update-api Change-Id: I8c2ff7bd6980ae838abc5669f9419d62741b8666 Merged-In: I8c2ff7bd6980ae838abc5669f9419d62741b8666
* | Merge changes Ic2357dcf,Iddf8c71aLucas Lin2021-03-251-1/+0
|\ \ | |/ |/| | | | | | | * changes: Expose NetworkAgent constructor taking a NetworkScore parameter Expose NetworkScore to external caller
| * Expose NetworkAgent constructor taking a NetworkScore parameterChiachang Wang2021-03-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Vpn constructs NetworkAgent with this exposed NetworkAgent constructor. Given NetworkAgent is moving into the incoming connectivity module, Vpn which is outside the module will not be able to access it if it's not in the API surface. Thus, expose it to allow Vpn to use it. Bug: 182963397 Test: make update-api Change-Id: Ic2357dcfff3233e0dd17b48b0e376a5095ef60fa Merged-In: Ic2357dcfff3233e0dd17b48b0e376a5095ef60fa CTS-Coverage-Bug: 172183305 (cherry-picked from ag/13966707)
* | Add 5G/NR QOS supportJayachandran C2021-03-231-11/+20
|/ | | | | | | | | Bug: 155176305 Bug: 182317794 Test: atest ConnectivityServiceTest atest QosCallbackTrackerTest Change-Id: Idf6d8a7c3b80bc50a2c1244ceaefea9381d40c2f
* Merge changes from topics ↵Treehugger Robot2021-03-211-3/+2
|\ | | | | | | | | | | | | | | | | "revert-1645768-revert-1626206-replaceUidRange-MSYTKFNGUE-HIUTVTIGIR", "ti_redaction" * changes: TransportInfo: Add a generic redaction mechanism Revert "Revert "Expose uids related APIs in NetworkRequest and N..." Revert^2 "Replace the usage of UidRange"
| * TransportInfo: Add a generic redaction mechanismRoshan Pius2021-03-191-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces the existing mechanism for redacting location sensitive fields with a more extensible mechanism. Currently supported redactions are for the following permissions: i. ACCESS_FINE_LOCATION ii. LOCAL_MAC_ADDRESS iii. NETWORK_SETTINGS Also, removed WifiInfo from ConnectivityServiceTest to reduce cross dependencies on wifi code. Bug: 156867433 Bug: 162602799 Test: atest android.net Test: atest com.android.server Change-Id: I2bb980c624667a55c1383f13ab71b9b97ed6eeab
* | Move connectivity AIDLs to android.netRemi NGUYEN VAN2021-03-201-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | java_sdk_libraries and apexes need to contain bootclasspath classes under predefined packages. Tethering currently uses android.net, so make sure all the connectivity bootclasspath classes are under android.net. This avoids maintaining two packages for the tethering APEX, where com.android.connectivity.aidl is only used by internal AIDL files. Bug: 182984842 Test: m Change-Id: I611f1941698c574e37aea912ee76dadc8b32e41a Merged-In: I611f1941698c574e37aea912ee76dadc8b32e41a
* | Remove Protocol.BASE_* usage in ConnectivityRemi NGUYEN VAN2021-03-171-2/+4
|/ | | | | | | | | | | | ConnectivityManager and NetworkAgent do not share their handler with any other component, so there is no reason to use addresses that do not overlap. Protocol.BASE_* was written to allow for interaction "between different StateMachine implementations without a conflict", but the classes do not use StateMachine, and they do not have such interactions. Bug: 177046265 Test: atest FrameworksNetTests Change-Id: I18c341d4a2c01cb9559d682a9ad1ff259e6b5855
* [NS01] Add NetworkScoreChalard Jean2021-03-151-11/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As attested by numerous TODOs in the code, a new way of representing network quality and policy is needed instead of an int. An int representing the quality of the network requires all parties using it to know how all other parties are using it, and implementation details about the decision algorithm. For all intents and purposes, the selection is left to individual network factories who try to achieve a desired result while piecing together all possible states of the system. As the number of such cases and desires increases, this becomes both intractable and unmaintainable. Indeed, at this time in the codebase nobody can really predict exactly how a given change in score will affect selection across the board, and it is essentially impossible to figure out the behavior of network selection by inspecting the code because the moving parts are scattered throughout the entire codebase. Having an object encapsulating policy and quality values will let us centralize the selection and make it again possible to maintain without knowledge of all behaviors of all network factories. It will also provide better guarantees of respecting policy, and allow bugfixes that were not possible before because they'd touch too many parts of the code. Test: FrameworksNetTests FrameworksWifiTests NetworkStackTests Change-Id: I3185a6412b9b659798faf0c6882699e9c63cc115
* API: Suppress existing NullableCollections lintsAdrian Roos2021-02-011-1/+3
| | | | | | | Bug: 152525509 Bug: 154763999 Test: make checkapi Change-Id: Iecd0927e6be5496b2fbd1a49396db5439257ffe4
* Move module sources to packages/ConnectivityRemi NGUYEN VAN2021-02-011-0/+1185
Files that are planned to be part of the connectivity module are grouped in packages/Connectivity, so they can be built separately and moved in one operation with their history into packages/modules/Connectivity. This places the files in the existing framework-connectivity-sources filegroup instead of the current framework-core-sources filegroup. Both are used the same way in framework-non-updatable-sources. Bug: 171540887 Test: m Change-Id: I62d9d91574ace6f5c4624035d190260c3126b91e