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

Commit 1f45f29d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix getWifiManager exception if phone is encrypted"

parents 54fffdc8 21f96258
Loading
Loading
Loading
Loading
+13 −4
Original line number Original line Diff line number Diff line
@@ -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) {
@@ -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);