Merge "Do not debounce disconnect while resetUsbGadget" into tm-qpr-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
4006d5462c
@@ -535,7 +535,6 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
|||||||
private boolean mInHostModeWithNoAccessoryConnected;
|
private boolean mInHostModeWithNoAccessoryConnected;
|
||||||
private boolean mSourcePower;
|
private boolean mSourcePower;
|
||||||
private boolean mSinkPower;
|
private boolean mSinkPower;
|
||||||
private boolean mConfigured;
|
|
||||||
private boolean mAudioAccessoryConnected;
|
private boolean mAudioAccessoryConnected;
|
||||||
private boolean mAudioAccessorySupported;
|
private boolean mAudioAccessorySupported;
|
||||||
|
|
||||||
@@ -568,7 +567,12 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
|||||||
private final UsbPermissionManager mPermissionManager;
|
private final UsbPermissionManager mPermissionManager;
|
||||||
private NotificationManager mNotificationManager;
|
private NotificationManager mNotificationManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not debounce for the first disconnect after resetUsbGadget.
|
||||||
|
*/
|
||||||
|
protected boolean mResetUsbGadgetDisableDebounce;
|
||||||
protected boolean mConnected;
|
protected boolean mConnected;
|
||||||
|
protected boolean mConfigured;
|
||||||
protected long mScreenUnlockedFunctions;
|
protected long mScreenUnlockedFunctions;
|
||||||
protected boolean mBootCompleted;
|
protected boolean mBootCompleted;
|
||||||
protected boolean mCurrentFunctionsApplied;
|
protected boolean mCurrentFunctionsApplied;
|
||||||
@@ -713,15 +717,29 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
|||||||
Slog.e(TAG, "unknown state " + state);
|
Slog.e(TAG, "unknown state " + state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (configured == 0) removeMessages(MSG_UPDATE_STATE);
|
|
||||||
if (connected == 1) removeMessages(MSG_FUNCTION_SWITCH_TIMEOUT);
|
if (connected == 1) removeMessages(MSG_FUNCTION_SWITCH_TIMEOUT);
|
||||||
Message msg = Message.obtain(this, MSG_UPDATE_STATE);
|
Message msg = Message.obtain(this, MSG_UPDATE_STATE);
|
||||||
msg.arg1 = connected;
|
msg.arg1 = connected;
|
||||||
msg.arg2 = configured;
|
msg.arg2 = configured;
|
||||||
// debounce disconnects to avoid problems bringing up USB tethering
|
if (DEBUG) {
|
||||||
sendMessageDelayed(msg,
|
Slog.i(TAG, "mResetUsbGadgetDisableDebounce:" + mResetUsbGadgetDisableDebounce
|
||||||
|
+ " connected:" + connected + "configured:" + configured);
|
||||||
|
}
|
||||||
|
if (mResetUsbGadgetDisableDebounce) {
|
||||||
|
// Do not debounce disconnect after resetUsbGadget.
|
||||||
|
sendMessage(msg);
|
||||||
|
if (connected == 1) mResetUsbGadgetDisableDebounce = false;
|
||||||
|
} else {
|
||||||
|
if (configured == 0) {
|
||||||
|
removeMessages(MSG_UPDATE_STATE);
|
||||||
|
if (DEBUG) Slog.i(TAG, "removeMessages MSG_UPDATE_STATE");
|
||||||
|
}
|
||||||
|
if (connected == 1) removeMessages(MSG_FUNCTION_SWITCH_TIMEOUT);
|
||||||
|
// debounce disconnects to avoid problems bringing up USB tethering.
|
||||||
|
sendMessageDelayed(msg,
|
||||||
(connected == 0) ? (mScreenLocked ? DEVICE_STATE_UPDATE_DELAY
|
(connected == 0) ? (mScreenLocked ? DEVICE_STATE_UPDATE_DELAY
|
||||||
: DEVICE_STATE_UPDATE_DELAY_EXT) : 0);
|
: DEVICE_STATE_UPDATE_DELAY_EXT) : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHostState(UsbPort port, UsbPortStatus status) {
|
public void updateHostState(UsbPort port, UsbPortStatus status) {
|
||||||
@@ -971,7 +989,10 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
|||||||
int operationId = sUsbOperationCount.incrementAndGet();
|
int operationId = sUsbOperationCount.incrementAndGet();
|
||||||
mConnected = (msg.arg1 == 1);
|
mConnected = (msg.arg1 == 1);
|
||||||
mConfigured = (msg.arg2 == 1);
|
mConfigured = (msg.arg2 == 1);
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.i(TAG, "handleMessage MSG_UPDATE_STATE " + "mConnected:" + mConnected
|
||||||
|
+ " mConfigured:" + mConfigured);
|
||||||
|
}
|
||||||
updateUsbNotification(false);
|
updateUsbNotification(false);
|
||||||
updateAdbNotification(false);
|
updateAdbNotification(false);
|
||||||
if (mBootCompleted) {
|
if (mBootCompleted) {
|
||||||
@@ -2116,9 +2137,16 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// MSG_ACCESSORY_MODE_ENTER_TIMEOUT has to be removed to allow exiting
|
||||||
|
// AOAP mode during resetUsbGadget.
|
||||||
|
removeMessages(MSG_ACCESSORY_MODE_ENTER_TIMEOUT);
|
||||||
|
if (mConfigured) {
|
||||||
|
mResetUsbGadgetDisableDebounce = true;
|
||||||
|
}
|
||||||
mUsbGadgetHal.reset();
|
mUsbGadgetHal.reset();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Slog.e(TAG, "reset Usb Gadget failed", e);
|
Slog.e(TAG, "reset Usb Gadget failed", e);
|
||||||
|
mResetUsbGadgetDisableDebounce = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user