Merge "Fix getWifiManager exception if phone is encrypted"
am: 1f45f29d18
Change-Id: I47d47742083f38367fec31850db9d0e7fc9b3c13
This commit is contained in:
@@ -409,21 +409,25 @@ public class Tethering extends BaseNetworkObserver {
|
||||
}
|
||||
|
||||
private int setWifiTethering(final boolean enable) {
|
||||
int rval = TETHER_ERROR_MASTER_ERROR;
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
synchronized (mPublicSync) {
|
||||
mWifiTetherRequested = enable;
|
||||
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 */)) ||
|
||||
(!enable && mgr.stopSoftAp())) {
|
||||
rval = TETHER_ERROR_NO_ERROR;
|
||||
mWifiTetherRequested = enable;
|
||||
return TETHER_ERROR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
return rval;
|
||||
|
||||
return TETHER_ERROR_MASTER_ERROR;
|
||||
}
|
||||
|
||||
private void setBluetoothTethering(final boolean enable, final ResultReceiver receiver) {
|
||||
@@ -942,6 +946,11 @@ public class Tethering extends BaseNetworkObserver {
|
||||
public int setUsbTethering(boolean enable) {
|
||||
if (VDBG) Log.d(TAG, "setUsbTethering(" + enable + ")");
|
||||
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) {
|
||||
usbManager.setCurrentFunctions(enable ? UsbManager.FUNCTION_RNDIS
|
||||
: UsbManager.FUNCTION_NONE);
|
||||
|
||||
Reference in New Issue
Block a user