diff --git a/services/native/include/usb_port_manager.h b/services/native/include/usb_port_manager.h index 3354467e9d510013bd09bbc0f802bf07893a0024..dec0b34334125b12f25fd5627ea1c816ff6c5c52 100644 --- a/services/native/include/usb_port_manager.h +++ b/services/native/include/usb_port_manager.h @@ -71,6 +71,7 @@ private: int32_t currentMode, int32_t currentDataRole, int32_t currentPowerRole); void AddSupportedMode(); std::mutex mutex_; + std::mutex setPortRoleMutex_; std::map portMap_; std::map supportedModeMap_; sptr usbd_ = nullptr; diff --git a/services/native/src/usb_port_manager.cpp b/services/native/src/usb_port_manager.cpp index 48d65b98cfa41f9d73d975383d4098d5187e1e14..8e4d33043b0fb525a9afc9befe333305b9642da8 100644 --- a/services/native/src/usb_port_manager.cpp +++ b/services/native/src/usb_port_manager.cpp @@ -177,6 +177,8 @@ bool UsbPortManager::IsReverseCharge() int32_t UsbPortManager::SetPortRole(int32_t portId, int32_t powerRole, int32_t dataRole) { + USB_HILOGI(MODULE_USB_SERVICE, "UsbPortManager SetPortRole enter"); + std::lock_guard guard(setPortRoleMutex_); #ifdef USB_MANAGER_V2_0 if (usbPortInterface_ == nullptr) { USB_HILOGE(MODULE_USB_SERVICE, "UsbPortManager::SetPortRole usbPortInterface_ is nullptr");