From fa6a48661576d2bd93b5e817d3629cca0a50e6c6 Mon Sep 17 00:00:00 2001 From: Christopher Wiley Date: Mon, 19 Sep 2016 08:58:06 -0700 Subject: [PATCH] Implement untetherAll as calls to stopTethering (cherry-pick of 5df6ed4a878c778971f388e3cb88e53b8db43b35) Calling untether() on an interface name leaves the system in an inconsistent state, since this is an API for use by network subsystems to start or stop the tethering of a prepared downstream network interface. The proper way to disable tethering is to call stopTethering() with an appropriate technology. untetherAll() is called in parts of the system UI to disable all tethering on system state changes (e.g. on the enabling of data saver). Bug: 31405407 Test: Enabling data saver now correctly disables tethering Change-Id: I8e5724a31e015721910a8d278e100daf697c34d7 --- .../java/com/android/server/connectivity/Tethering.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java index 74fdf6d75bc86..50faf3b72a47b 100644 --- a/services/core/java/com/android/server/connectivity/Tethering.java +++ b/services/core/java/com/android/server/connectivity/Tethering.java @@ -626,12 +626,9 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering } public void untetherAll() { - synchronized (mPublicSync) { - if (DBG) Log.d(TAG, "Untethering " + mTetherStates.keySet()); - for (int i = 0; i < mTetherStates.size(); i++) { - untether(mTetherStates.keyAt(i)); - } - } + stopTethering(ConnectivityManager.TETHERING_WIFI); + stopTethering(ConnectivityManager.TETHERING_USB); + stopTethering(ConnectivityManager.TETHERING_BLUETOOTH); } public int getLastTetherError(String iface) {