update services/storage_daemon/mtp/src/mtp_device_monitor.cpp.

Signed-off-by: 李尚 <lishang21@huawei.com>
This commit is contained in:
李尚 2024-11-22 03:01:43 +00:00 committed by Gitee
parent e724904133
commit 61b8d5142d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -72,6 +72,9 @@ void MtpDeviceMonitor::MonitorDevice()
{
LOGI("MonitorDevice: mtp device monitor thread begin.");
while (g_keepMonitoring) {
if (IsNeedDisableMtp()) {
break;
}
sleep(SLEEP_TIME);
CheckAndUmountRemovedMtpDevice();
@ -152,6 +155,10 @@ void MtpDeviceMonitor::MountMtpDevice(const std::vector<MtpDeviceInfo> &monitorD
LOGE("MountMtpDevice: invalid mtp device, no need to mount.");
continue;
}
if (lastestMtpDevList_.size() > 0) {
LOGW("Multiple devices detected. Only one device is supported. Ignoring additional devices.");
return;
}
int32_t ret = DelayedSingleton<MtpDeviceManager>::GetInstance()->MountDevice(device);
if (ret == E_OK) {
lastestMtpDevList_.push_back(device);