Loading services/core/java/com/android/server/connectivity/Tethering.java +13 −4 Original line number Original line Diff line number Diff line Loading @@ -409,21 +409,25 @@ public class Tethering extends BaseNetworkObserver { } } private int setWifiTethering(final boolean enable) { private int setWifiTethering(final boolean enable) { int rval = TETHER_ERROR_MASTER_ERROR; final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity(); try { try { synchronized (mPublicSync) { synchronized (mPublicSync) { mWifiTetherRequested = enable; final WifiManager mgr = getWifiManager(); final WifiManager mgr = getWifiManager(); if (mgr == null) { mLog.e("setWifiTethering: failed to get WifiManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } if ((enable && mgr.startSoftAp(null /* use existing wifi config */)) || if ((enable && mgr.startSoftAp(null /* use existing wifi config */)) || (!enable && mgr.stopSoftAp())) { (!enable && mgr.stopSoftAp())) { rval = TETHER_ERROR_NO_ERROR; mWifiTetherRequested = enable; return TETHER_ERROR_NO_ERROR; } } } } } finally { } finally { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); } } return rval; return TETHER_ERROR_MASTER_ERROR; } } private void setBluetoothTethering(final boolean enable, final ResultReceiver receiver) { private void setBluetoothTethering(final boolean enable, final ResultReceiver receiver) { Loading Loading @@ -942,6 +946,11 @@ public class Tethering extends BaseNetworkObserver { public int setUsbTethering(boolean enable) { public int setUsbTethering(boolean enable) { if (VDBG) Log.d(TAG, "setUsbTethering(" + enable + ")"); if (VDBG) Log.d(TAG, "setUsbTethering(" + enable + ")"); UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE); UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE); if (usbManager == null) { mLog.e("setUsbTethering: failed to get UsbManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } synchronized (mPublicSync) { synchronized (mPublicSync) { usbManager.setCurrentFunctions(enable ? UsbManager.FUNCTION_RNDIS usbManager.setCurrentFunctions(enable ? UsbManager.FUNCTION_RNDIS : UsbManager.FUNCTION_NONE); : UsbManager.FUNCTION_NONE); Loading Loading
services/core/java/com/android/server/connectivity/Tethering.java +13 −4 Original line number Original line Diff line number Diff line Loading @@ -409,21 +409,25 @@ public class Tethering extends BaseNetworkObserver { } } private int setWifiTethering(final boolean enable) { private int setWifiTethering(final boolean enable) { int rval = TETHER_ERROR_MASTER_ERROR; final long ident = Binder.clearCallingIdentity(); final long ident = Binder.clearCallingIdentity(); try { try { synchronized (mPublicSync) { synchronized (mPublicSync) { mWifiTetherRequested = enable; final WifiManager mgr = getWifiManager(); final WifiManager mgr = getWifiManager(); if (mgr == null) { mLog.e("setWifiTethering: failed to get WifiManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } if ((enable && mgr.startSoftAp(null /* use existing wifi config */)) || if ((enable && mgr.startSoftAp(null /* use existing wifi config */)) || (!enable && mgr.stopSoftAp())) { (!enable && mgr.stopSoftAp())) { rval = TETHER_ERROR_NO_ERROR; mWifiTetherRequested = enable; return TETHER_ERROR_NO_ERROR; } } } } } finally { } finally { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); } } return rval; return TETHER_ERROR_MASTER_ERROR; } } private void setBluetoothTethering(final boolean enable, final ResultReceiver receiver) { private void setBluetoothTethering(final boolean enable, final ResultReceiver receiver) { Loading Loading @@ -942,6 +946,11 @@ public class Tethering extends BaseNetworkObserver { public int setUsbTethering(boolean enable) { public int setUsbTethering(boolean enable) { if (VDBG) Log.d(TAG, "setUsbTethering(" + enable + ")"); if (VDBG) Log.d(TAG, "setUsbTethering(" + enable + ")"); UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE); UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE); if (usbManager == null) { mLog.e("setUsbTethering: failed to get UsbManager!"); return TETHER_ERROR_SERVICE_UNAVAIL; } synchronized (mPublicSync) { synchronized (mPublicSync) { usbManager.setCurrentFunctions(enable ? UsbManager.FUNCTION_RNDIS usbManager.setCurrentFunctions(enable ? UsbManager.FUNCTION_RNDIS : UsbManager.FUNCTION_NONE); : UsbManager.FUNCTION_NONE); Loading