summaryrefslogtreecommitdiff
path: root/Tethering/src/com/android/networkstack/tethering/TetheringService.java
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Add Override anntation for TetheringConnector.setPreferTestNetworks"Treehugger Robot2021-10-041-0/+1
|\
| * Add Override anntation for TetheringConnector.setPreferTestNetworksmarkchien2021-10-041-0/+1
| | | | | | | | | | Test: TH Change-Id: Idfaca3cb59580ffe4ee194466ad2ba8f47d8fac4
* | Use SettingsShim to hide different implementation in shimmarkchien2021-09-301-3/+7
|/ | | | | | | | | | | | TetheringService call different Settings API to check write settings permission between R and S. Bug: 182211575 Test: install S module to R device and both run mts tests build with S and R. Change-Id: I3e7f6525e9776992bd96b17c132b749b12285bbd Merged-In: I3e7f6525e9776992bd96b17c132b749b12285bbd
* Support set test network to tethering upstreammarkchien2021-09-301-0/+12
| | | | | | Test: atest EthernetTetheringTest Change-Id: Ief2a92bc6c573a6bb75c72b7a0630e5c0accfa73
* Merge "No-op Refactoring of startTrackDefaultNetwork"Junyu Lai2021-05-131-15/+0
|\
| * No-op Refactoring of startTrackDefaultNetworkjunyulai2021-05-131-15/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the actual part that track default request is inside UpstreamNetworkMonitor, instead of passing it from Tethering, move it into counter-part CL and use it from UpstreamNetworkMonitor. Since the current code is replaced by registerSystemDefaultCallback in Android S, implement it inside the api30 shim implementation to provide an unified interface to tethering. Test: atest TetheringCoverageTests Bug: 185952829 Change-Id: Iaf21b6b662aa6aba79c2b75379128b8523f81f02
* | Remove mPublicSync.Lorenzo Colitti2021-05-121-3/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is no longer necessary as all the methods that take it are running on on the handler thread, either in Tethering itself or on the state machine thread in IpServer, which runs on the same thread as Tethering. Specifically: - interfaceStatusChanged, interfaceAdded, interfaceRemoved, interfaceLinkStateChanged: run from mNetdCallback, which always posts them to mHandler. - setWifiTethering: only called by enableTetheringInternal, which is called by the following: - startTethering, stopTethering: via lambda posted to mHandler - IpServerCallback#requestEnableTethering: called by IpServer while processing a command. - setEthernetTethering: only called by enableTetheringInternal. - EthernetCallback: runs on mExecutor, which posts to mHandler. - getLastTetherError: only used by the test. Renamed to getLastErrorForTest to ensure no other callers. - sendTetherStateChangedBroadcast: called only by notifyInterfaceStateChange, which is called only by - IpServerCallback#updateInterfaceState, which is called only by sendInterfaceState, which is called by various IpServer state enter methods. - notifyLinkPropertiesChanged: called only by IpServerCallback#updateLinkProperties, which is only called by IpServer#sendLinkProperties, which is only called by: - Code that processes CMD_IPV6_TETHER_UPDATE - IpServer#handleNewPrefixRequest: only called when processing CMD_NEW_PREFIX_REQUEST. - IpServer#sendInterfaceState (see above) - handleWifiApAction, handleWifiP2pAction: only called by mStateReceiver, which runs on the handler thread - tether(String, int): called by: - tether(String, IIntResultListener): posted to mHandler - changeInterfaceState: called by: - EthernetCallback (see above) - enableWifiIpServingLocked: called by handleWifiApAction and handleWifiP2pAction (see above) - tetherMatchingInterfaces: only called by handleUsbAction, which is run from mStateReceiver on the handler thread. - untether(String): called by: - untether(String, IIntResultListener): posted to mHandler - changeInterfaceState (see above) - setUsbTethering: called by: - setUsbTethering(boolean, IIntResultListener): posted to mHandler - enableTetheringInternal (see above) - setNcmTethering: called by enableTetheringInternal (see above) - getTetheredIfaces: called only by TetheringTest. Renamed to getTetheredIfacesForTest to ensure no other callers. - getErroredIfaces: unused, deleted in this CL - getTetheredIfaces: called by: - isTetheringActive: called by onUserRestrictionsChanged, which is only called by mStateReceiver - TetheringTest - dump(): changed to run on handler thread - upstreamWanted: called by - TetherModeAliveState#enter - TetherModeAliveState#updateUpstreamWanted, which is called only by TetherModeAliveState#processMessage. Test: atest TetheringCoverageTests Test: enabled/disabled hotspot, USB tethering Change-Id: Id49d33f027b8df4c97fda480ff239c0ba90bb96a
* Allow callers of startTethering to choose local-only mode.Lorenzo Colitti2021-04-191-1/+1
| | | | | | | | | | | This is useful for OEMs that want to use RNDIS or NCM as a local-only link that is directly connected to some other host. This can be used to implement USB tethering using NCM, which currently only supports local-only mode. Bug: 175090447 Test: TetheringIntegrationTests:EthernetTetheringTest#testLocalOnlyTethering Change-Id: I0ffaa46e4640e5b235340a15d25909106ceb0c07
* Merge "Put tether/untether calls into handler queue"Treehugger Robot2021-04-151-6/+2
|\
| * Put tether/untether calls into handler queuemarkchien2020-12-291-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BT tethering is the only user of #tether and #untether API. Enable BT tethering may fail by race between interface status change and #tether call. In starting BT tethering flow, tethering may receive pan interface DOWN and UP then PanService call #tether to request for processing its pan interface. Tethering put interface status change event into handler queue but it process #tether and #unether calls right away without order them by queue. It makes tethering handle binder call #tether before pan interface DOWN even DOWN event arrived eailer. This cause BT tethering bring down by interface DOWN event unexpectedly. Although this still can't fix all the race cases of tethering, but at lesat this could fix the race mentioned above. Bug: 173310882 Test: manual ON/OFF bt tethering atest TetheringTests Change-Id: I2411378aa36ad4371cca12423bb65542cb8df7a1
* | Load JNI in all classes that have native methods.Lorenzo Colitti2021-02-101-1/+0
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | The tethering module uses JNI in various classes, but only calls System.loadLibrary in TetheringService#makeTethering. This means that: 1. Any test that uses a class that uses JNI must load the library itself. 2. Any code that runs before TetheringService#makeTethering could potentially crash if it uses JNI. We may never have such code though. Instead, make every class that has a native method load the JNI library itself at static initialization time. This guarantees that the class will have the JNI code available in any context (production, test, etc.) System.loadLibrary is documented not to do anything if called more than once with the same library name: https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#loadLibrary(java.lang.String) and the implementation has a lock so it is safe to call from multiple threads concurrently. Test: builds, boots, tethering starts Test: atest TetheringCoverageTests Change-Id: I9c0147ae9a28877f416aaff387b426d304ae552d
* Gate exemptFromEentitlementCheck by Network_STACK permissionmarkchien2020-05-291-2/+15
| | | | | | | | | | Shell has TETHER_PRIVILEGED permission. To avoid any service to adopt shell identity by lunching service with Shell process, gate exemptFromEentitlementCheck by NETWORK_STACK. Bug: 157702014 Test: atest TetheringCoverageTests Change-Id: I6ddfda23d36ea9981e3e1eb5a87767f452a65852
* Fix TetheringServiceTest test WRITE_SETTINGS permission failuremarkchien2020-05-201-3/+4
| | | | | | | | | | | | | | | | | | AdoptShellPermissionIdentity can not pass permission check by Settings#checkAndNoteWriteSettingsOperation. It would compare the caller uid and its package name. See error below: 1. java.lang.SecurityException: Specified package com.android.shell under uid 10239 but it is really 2000 2. java.lang.SecurityException: uid 10245 does not have android.permission.UPDATE_APP_OPS_STATS. Override the method and test if caller hold WRITE_SETTINGS directly. Bug: 154869719 Test: TetheringTests, TetheringCoverageTests, NetworkStackNextTests, NetworkStackCoverageTests Change-Id: I2a60c4d66ef30028f9663159f85464ea815248e2
* Make members final in TetheringServicemarkchien2020-05-131-114/+71
| | | | | | | | | | | | | 1. Move isTetheringSupport logic from TetheringService to Tethering. 2. Small readability improvement in TetheringTest. Also change config_tether_upstream_automatic from false to true in TetheringTest. So TetheringTests would default run automatic select upstream flow instead of selecting by legacy perferred network type list. Bug: 153609486 Test: atest TetheringTest Change-Id: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f Merged-In: I5a82a6347f62d3a7031db5c56e8e0c8530dafd8f
* Allow to exempt from entitlement checkmarkchien2020-05-081-44/+49
| | | | | | | | | | To exempt from entitlement check, caller need to hold TETHER_PRIVILEGED permission. Bug: 141256482 Test: atest TetheringTests Change-Id: I2eb37f5e92f5f5150a7fb7c25b945e28704d27a0
* Set attributionTag for noteOp(WRITE_SETTINGS) callsPhilip P. Moltmann2020-04-201-23/+45
| | | | | | | Test: atest FrameworksNetTests TetheringTests:TetheringServiceTest Bug: 136595429 Merged-In: I33f787644c44d7b0e5ce17a433820cfcd985cdfb Change-Id: Ic3d937e7bb5141798234ed5b2852c1f768e97495
* Change tethering file structure to respect its package namemarkchien2020-04-141-0/+391
Bug: 145099347 Test: atest TetheringTests atest CtsTetheringTest Change-Id: I7401c550fbafd17a5ed2d925b5d0e17e358af467