alps\frameworks\base\services\usb\java\com\android\server\usb\UsbDeviceManager.java
private void setScreenUnlockedFunctions() {
// setEnabledFunctions(mScreenUnlockedFunctions, false);
setEnabledFunctions(UsbManager.FUNCTION_MTP, false);
}//将解锁后usb模式改为MTP,默认是UsbManager.FUNCTION_NONE
protected void finishBoot() {
if (mBootCompleted && mCurrentUsbFunctionsReceived && mSystemReady) {
if (mPendingBootBroadcast) {
updateUsbStateBroadcastIfNeeded(getAppliedFunctions(mCurrentFunctions));
mPendingBootBroadcast = false;
}
if (!mScreenLocked
&& mScreenUnlockedFunctions != UsbManager.FUNCTION_NONE) {
setScreenUnlockedFunctions();
} else {
//setEnabledFunctions(UsbManager.FUNCTION_NONE, false);
setEnabledFunctions(UsbManager.FUNCTION_MTP, false);
}
if (mCurrentAccessory != null) {
mUsbDeviceManager.getCurrentSettings().accessoryAttached(mCurrentAccessory);
}
updateUsbNotification(false);
updateAdbNotification(false);
updateUsbFunctions();
}
}
Android USB模式设置解析
本文解析了Android系统中USB模式的设置逻辑,特别是在设备解锁后如何自动切换到MTP模式的过程。通过源代码分析,详细介绍了`UsbDeviceManager`类中的`setScreenUnlockedFunctions`和`finishBoot`方法实现细节。
2180

被折叠的 条评论
为什么被折叠?



