diff --git a/services/native/driver_extension_manager/src/device_manager/BUILD.gn b/services/native/driver_extension_manager/src/device_manager/BUILD.gn index 6dc848c5d837fc01c8d736e8363090d8175a080c..2f0423b98127128aed428c5ac8f569a3bc36a824 100644 --- a/services/native/driver_extension_manager/src/device_manager/BUILD.gn +++ b/services/native/driver_extension_manager/src/device_manager/BUILD.gn @@ -52,6 +52,7 @@ ohos_shared_library("driver_extension_device_manager") { "${ext_mgr_path}/services/native/driver_extension_manager/src/drivers_pkg_manager:drivers_pkg_manager", ] external_deps = [ + "ability_runtime:ability_manager", "bundle_framework:appexecfwk_core", "c_utils:utils", "hilog:libhilog", diff --git a/services/native/driver_extension_manager/src/device_manager/device.cpp b/services/native/driver_extension_manager/src/device_manager/device.cpp index 780ff61b746e34edc1bf0752aa3f98e2b62524de..dfd70858ca1322b43165f17eff92dd64dc9c9c38 100644 --- a/services/native/driver_extension_manager/src/device_manager/device.cpp +++ b/services/native/driver_extension_manager/src/device_manager/device.cpp @@ -13,8 +13,11 @@ * limitations under the License. */ -#include "device.h" +#include + +#include "ability_manager_errors.h" #include "hilog_wrapper.h" +#include "device.h" namespace OHOS { namespace ExternalDeviceManager { @@ -51,6 +54,18 @@ int32_t Device::Connect() AddDrvExtConnNotify(); int32_t ret = DriverExtensionController::GetInstance().ConnectDriverExtension( bundleName, abilityName, connectNofitier_, busDevId); + // RESOLVE_ABILITY_ERR maybe due to bms is not ready in the boot process, sleep 100ms and try again + if (ret == AAFwk::RESOLVE_ABILITY_ERR) { + EDM_LOGW(MODULE_DEV_MGR, "%{public}s sleep 100ms to reconnect %{public}s %{public}s", __func__, + bundleName.c_str(), abilityName.c_str()); + const int waitTimeMs = 100; + const int msToUs = 1000; + usleep(waitTimeMs * msToUs); + drvExtRemote_ = nullptr; + connectNofitier_->ClearDrvExtConnectionInfo(); + ret = DriverExtensionController::GetInstance().ConnectDriverExtension( + bundleName, abilityName, connectNofitier_, busDevId); + } if (ret != UsbErrCode::EDM_OK) { EDM_LOGE(MODULE_DEV_MGR, "failed to connect driver extension"); return ret;