Search in sources :

Example 6 with UsbManager

use of android.hardware.usb.UsbManager in project android_frameworks_base by DirtyUnicorns.

the class Tethering method setUsbTethering.

public int setUsbTethering(boolean enable) {
    if (VDBG)
        Log.d(TAG, "setUsbTethering(" + enable + ")");
    UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
    synchronized (mPublicSync) {
        if (enable) {
            if (mRndisEnabled) {
                final long ident = Binder.clearCallingIdentity();
                try {
                    tetherMatchingInterfaces(true, ConnectivityManager.TETHERING_USB);
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }
            } else {
                mUsbTetherRequested = true;
                usbManager.setCurrentFunction(UsbManager.USB_FUNCTION_RNDIS, false);
            }
        } else {
            final long ident = Binder.clearCallingIdentity();
            try {
                tetherMatchingInterfaces(false, ConnectivityManager.TETHERING_USB);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
            if (mRndisEnabled) {
                usbManager.setCurrentFunction(null, false);
            }
            mUsbTetherRequested = false;
        }
    }
    return ConnectivityManager.TETHER_ERROR_NO_ERROR;
}
Also used : UsbManager(android.hardware.usb.UsbManager)

Example 7 with UsbManager

use of android.hardware.usb.UsbManager in project android_frameworks_base by AOSPA.

the class Tethering method setUsbTethering.

public int setUsbTethering(boolean enable) {
    if (VDBG)
        Log.d(TAG, "setUsbTethering(" + enable + ")");
    UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
    synchronized (mPublicSync) {
        if (enable) {
            if (mRndisEnabled) {
                final long ident = Binder.clearCallingIdentity();
                try {
                    tetherMatchingInterfaces(true, ConnectivityManager.TETHERING_USB);
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }
            } else {
                mUsbTetherRequested = true;
                usbManager.setCurrentFunction(UsbManager.USB_FUNCTION_RNDIS, false);
            }
        } else {
            final long ident = Binder.clearCallingIdentity();
            try {
                tetherMatchingInterfaces(false, ConnectivityManager.TETHERING_USB);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
            if (mRndisEnabled) {
                usbManager.setCurrentFunction(null, false);
            }
            mUsbTetherRequested = false;
        }
    }
    return ConnectivityManager.TETHER_ERROR_NO_ERROR;
}
Also used : UsbManager(android.hardware.usb.UsbManager)

Example 8 with UsbManager

use of android.hardware.usb.UsbManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DevelopmentSettings method writeUsbConfigurationOption.

private void writeUsbConfigurationOption(Object newValue) {
    UsbManager manager = (UsbManager) getActivity().getSystemService(Context.USB_SERVICE);
    String function = newValue.toString();
    if (function.equals("none")) {
        manager.setCurrentFunction(function, false);
    } else {
        manager.setCurrentFunction(function, true);
    }
}
Also used : UsbManager(android.hardware.usb.UsbManager) IUsbManager(android.hardware.usb.IUsbManager)

Example 9 with UsbManager

use of android.hardware.usb.UsbManager in project android_frameworks_base by ResurrectionRemix.

the class Tethering method setUsbTethering.

public int setUsbTethering(boolean enable) {
    if (VDBG)
        Log.d(TAG, "setUsbTethering(" + enable + ")");
    UsbManager usbManager = (UsbManager) mContext.getSystemService(Context.USB_SERVICE);
    synchronized (mPublicSync) {
        if (enable) {
            if (mRndisEnabled) {
                final long ident = Binder.clearCallingIdentity();
                try {
                    tetherMatchingInterfaces(true, ConnectivityManager.TETHERING_USB);
                } finally {
                    Binder.restoreCallingIdentity(ident);
                }
            } else {
                mUsbTetherRequested = true;
                usbManager.setCurrentFunction(UsbManager.USB_FUNCTION_RNDIS, false);
            }
        } else {
            final long ident = Binder.clearCallingIdentity();
            try {
                tetherMatchingInterfaces(false, ConnectivityManager.TETHERING_USB);
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
            if (mRndisEnabled) {
                usbManager.setCurrentFunction(null, false);
            }
            mUsbTetherRequested = false;
        }
    }
    return ConnectivityManager.TETHER_ERROR_NO_ERROR;
}
Also used : UsbManager(android.hardware.usb.UsbManager)

Aggregations

UsbManager (android.hardware.usb.UsbManager)9 IUsbManager (android.hardware.usb.IUsbManager)2 UsbDevice (android.hardware.usb.UsbDevice)1