summaryrefslogtreecommitdiff
path: root/packages/Tethering/src
diff options
context:
space:
mode:
author Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2020-02-28 03:42:44 +0000
committer Mark Chien <markchien@google.com> 2020-03-09 02:02:23 +0000
commit06fe92de0fcb85c2bebdd7bccb56c4b761bdbcee (patch)
tree1dd8e89055fe72b8882b81f4cfe662a11847bc37 /packages/Tethering/src
parentfde3c9ac591506a1c69159a0b377aa4cfa01c537 (diff)
Fix crash and duplicated ethernet tethering request
This change fix two things: 1. Handle ethernet callback in internal thread to avoid crash. IpServer should be created from tethering thread, otherwise mIpNeighborMonitor of IpServer would throw IllegalStateException("start() called from off-thread") 2. Ethernet tethering request may be duplicated if multiple startTethering is called but no stopTethering Bug: 130840861 Bug: 148824036 Test: ON/OFF ethernet tehtering manually atest TetheringTests Change-Id: Ibd3ea6bc6751bd65647ff381f9b0124bc3395c09 Merged-In: I7c5127e96d80d077735010d2e62c7227805ccb10 Merged-In: Ibd3ea6bc6751bd65647ff381f9b0124bc3395c09 (cherry picked from commit 72702b979654234c18045f04270040056a74cf90)
Diffstat (limited to 'packages/Tethering/src')
-rw-r--r--packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
index ca74430f706c..864f35c758f6 100644
--- a/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
+++ b/packages/Tethering/src/com/android/server/connectivity/tethering/Tethering.java
@@ -220,6 +220,7 @@ public class Tethering {
private final UserRestrictionActionListener mTetheringRestriction;
private final ActiveDataSubIdListener mActiveDataSubIdListener;
private final ConnectedClientsTracker mConnectedClientsTracker;
+ private final TetheringThreadExecutor mExecutor;
private int mActiveDataSubId = INVALID_SUBSCRIPTION_ID;
// All the usage of mTetheringEventCallback should run in the same thread.
private ITetheringEventCallback mTetheringEventCallback = null;
@@ -296,8 +297,8 @@ public class Tethering {
final UserManager userManager = (UserManager) mContext.getSystemService(
Context.USER_SERVICE);
mTetheringRestriction = new UserRestrictionActionListener(userManager, this);
- final TetheringThreadExecutor executor = new TetheringThreadExecutor(mHandler);
- mActiveDataSubIdListener = new ActiveDataSubIdListener(executor);
+ mExecutor = new TetheringThreadExecutor(mHandler);
+ mActiveDataSubIdListener = new ActiveDataSubIdListener(mExecutor);
// Load tethering configuration.
updateConfiguration();
@@ -315,9 +316,7 @@ public class Tethering {
final WifiManager wifiManager = getWifiManager();
if (wifiManager != null) {
- wifiManager.registerSoftApCallback(
- mHandler::post /* executor */,
- new TetheringSoftApCallback());
+ wifiManager.registerSoftApCallback(mExecutor, new TetheringSoftApCallback());
}
}
@@ -606,14 +605,17 @@ public class Tethering {
Context.ETHERNET_SERVICE);
synchronized (mPublicSync) {
if (enable) {
+ if (mEthernetCallback != null) return TETHER_ERROR_NO_ERROR;
+
mEthernetCallback = new EthernetCallback();
- mEthernetIfaceRequest = em.requestTetheredInterface(mEthernetCallback);
+ mEthernetIfaceRequest = em.requestTetheredInterface(mExecutor, mEthernetCallback);
} else {
- if (mConfiguredEthernetIface != null) {
- stopEthernetTetheringLocked();
+ stopEthernetTetheringLocked();
+ if (mEthernetCallback != null) {
mEthernetIfaceRequest.release();
+ mEthernetCallback = null;
+ mEthernetIfaceRequest = null;
}
- mEthernetCallback = null;
}
}
return TETHER_ERROR_NO_ERROR;