Search in sources :

Example 1 with UsbManager

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

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) {
                tetherUsb(true);
            } else {
                mUsbTetherRequested = true;
                usbManager.setCurrentFunction(UsbManager.USB_FUNCTION_RNDIS, false);
            }
        } else {
            tetherUsb(false);
            if (mRndisEnabled) {
                usbManager.setCurrentFunction(null, false);
            }
            mUsbTetherRequested = false;
        }
    }
    return ConnectivityManager.TETHER_ERROR_NO_ERROR;
}
Also used : UsbManager(android.hardware.usb.UsbManager)

Example 2 with UsbManager

use of android.hardware.usb.UsbManager in project platform_frameworks_base by android.

the class Tethering method setUsbTethering.

public int setUsbTethering(boolean enable) {
    if (VDBG)
        Log.d(TAG, "setUsbTethering(" + enable + ")");
    UsbManager usbManager = mContext.getSystemService(UsbManager.class);
    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 3 with UsbManager

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

the class DevelopmentSettings method updateUsbConfigurationValues.

private void updateUsbConfigurationValues() {
    if (mUsbConfiguration != null) {
        UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
        String[] values = getResources().getStringArray(R.array.usb_configuration_values);
        String[] titles = getResources().getStringArray(R.array.usb_configuration_titles);
        int index = 0;
        for (int i = 0; i < titles.length; i++) {
            if (manager.isFunctionEnabled(values[i])) {
                index = i;
                break;
            }
        }
        mUsbConfiguration.setValue(values[index]);
        mUsbConfiguration.setSummary(titles[index]);
        mUsbConfiguration.setOnPreferenceChangeListener(this);
    }
}
Also used : UsbManager(android.hardware.usb.UsbManager) IUsbManager(android.hardware.usb.IUsbManager)

Example 4 with UsbManager

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

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 5 with UsbManager

use of android.hardware.usb.UsbManager in project android-uploader by nightscout.

the class SyncingService method isG4Connected.

public static boolean isG4Connected(Context c) {
    // Iterate through devices and see if the dexcom is connected
    // Allowing us to start to start syncing if the G4 is already connected
    // vendor-id="8867" product-id="71" class="2" subclass="0" protocol="0"
    UsbManager manager = (UsbManager) c.getSystemService(Context.USB_SERVICE);
    if (manager == null)
        return false;
    HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
    Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
    boolean g4Connected = false;
    while (deviceIterator.hasNext()) {
        UsbDevice device = deviceIterator.next();
        if (device.getVendorId() == 8867 && device.getProductId() == 71 && device.getDeviceClass() == 2 && device.getDeviceSubclass() == 0 && device.getDeviceProtocol() == 0) {
            g4Connected = true;
        }
    }
    return g4Connected;
}
Also used : UsbDevice(android.hardware.usb.UsbDevice) UsbManager(android.hardware.usb.UsbManager)

Aggregations

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