am cd90d1f1: am 44e4b99f: Merge "UsbService: Make USB disconnect handling for accessory mode more robust" into honeycomb-mr1
* commit 'cd90d1f1173c344738362d24bdc637c355b75645': UsbService: Make USB disconnect handling for accessory mode more robust
This commit is contained in:
@@ -561,11 +561,14 @@ public class UsbService extends IUsbManager.Stub {
|
|||||||
case MSG_UPDATE_STATE:
|
case MSG_UPDATE_STATE:
|
||||||
if (mConnected != mLastConnected || mConfiguration != mLastConfiguration) {
|
if (mConnected != mLastConnected || mConfiguration != mLastConfiguration) {
|
||||||
if (mConnected == 0) {
|
if (mConnected == 0) {
|
||||||
// make sure accessory mode is off, and restore default functions
|
if (UsbManager.isFunctionEnabled(
|
||||||
if (mCurrentAccessory != null && UsbManager.setFunctionEnabled(
|
UsbManager.USB_FUNCTION_ACCESSORY)) {
|
||||||
UsbManager.USB_FUNCTION_ACCESSORY, false)) {
|
// make sure accessory mode is off, and restore default functions
|
||||||
Log.d(TAG, "exited USB accessory mode");
|
Log.d(TAG, "exited USB accessory mode");
|
||||||
|
if (!UsbManager.setFunctionEnabled
|
||||||
|
(UsbManager.USB_FUNCTION_ACCESSORY, false)) {
|
||||||
|
Log.e(TAG, "could not disable accessory function");
|
||||||
|
}
|
||||||
int count = mDefaultFunctions.size();
|
int count = mDefaultFunctions.size();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
String function = mDefaultFunctions.get(i);
|
String function = mDefaultFunctions.get(i);
|
||||||
@@ -574,8 +577,10 @@ public class UsbService extends IUsbManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDeviceManager.accessoryDetached(mCurrentAccessory);
|
if (mCurrentAccessory != null) {
|
||||||
mCurrentAccessory = null;
|
mDeviceManager.accessoryDetached(mCurrentAccessory);
|
||||||
|
mCurrentAccessory = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user