Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60d2beff authored by Ye Jiao's avatar Ye Jiao Committed by android-build-merger
Browse files

Merge "Fix getWifiManager exception if phone is encrypted"

am: 1f45f29d

Change-Id: I47d47742083f38367fec31850db9d0e7fc9b3c13
parents 8dd52036 1f45f29d
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -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);