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;
}
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;
}
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);
}
}
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;
}
Aggregations