diff --git a/bundle.json b/bundle.json index 8fb7dac91f0f8626f02fb2fce0aa0afd9051fbc4..0038f4a729609cf4d0eede249f685489a57b5b68 100644 --- a/bundle.json +++ b/bundle.json @@ -28,7 +28,6 @@ "components": [ "hilog", "ability_base", - "eventhandler", "napi", "bundle_framework", "common_event_service", diff --git a/services/BUILD.gn b/services/BUILD.gn index c04fc315daa1163a15e349f9c82373d0ba517b50..ed429af6982595e5c791e3c26b3a335ac3f272ca 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -49,7 +49,6 @@ ohos_shared_library("usbservice") { "native/src/usb_right_db_helper.cpp", "native/src/usb_right_manager.cpp", "native/src/usb_serial_reader.cpp", - "native/src/usb_server_event_handler.cpp", "native/src/usb_service.cpp", "native/src/usb_service_subscriber.cpp", "native/src/usbd_bulkcallback_impl.cpp", @@ -84,7 +83,6 @@ ohos_shared_library("usbservice") { "common_event_service:cesfwk_innerkits", "drivers_interface_usb:libusb_proxy_1.1", "drivers_peripheral_usb:libusb_interface_service_1.1", - "eventhandler:libeventhandler", "hilog:libhilog", "hisysevent:libhisysevent", "hitrace:hitrace_meter", diff --git a/services/native/include/usb_server_event_handler.h b/services/native/include/usb_server_event_handler.h deleted file mode 100644 index 2d689ecf406ec2b66c09fd0fa2b415daf06b3843..0000000000000000000000000000000000000000 --- a/services/native/include/usb_server_event_handler.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef USBMGR_USB_SERVER_EVENT_HANDLER_H -#define USBMGR_USB_SERVER_EVENT_HANDLER_H - -#include "event_handler.h" -#include "refbase.h" - -namespace OHOS { -namespace USB { -class UsbService; -class UsbServerEventHandler : public AppExecFwk::EventHandler { -public: - UsbServerEventHandler(const std::shared_ptr &runner, const wptr &service); - ~UsbServerEventHandler() override = default; - void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; - -private: - wptr service_; -}; -} // namespace USB -} // namespace OHOS - -#endif // USBMGR_USB_SERVER_EVENT_HANDLER_H diff --git a/services/native/include/usb_service.h b/services/native/include/usb_service.h index 85e58d0dd89866764d9a9056011d8eec3d87459e..7dd8dcc24f627a8c4dcb15e2f666e6c16b1177cc 100644 --- a/services/native/include/usb_service.h +++ b/services/native/include/usb_service.h @@ -34,7 +34,6 @@ #include "usb_host_manager.h" #include "usb_port_manager.h" #include "usb_right_manager.h" -#include "usb_server_event_handler.h" #include "usb_server_stub.h" #include "usb_service_subscriber.h" #include "usbd_type.h" @@ -64,10 +63,6 @@ public: return ready_; } - std::shared_ptr GetHandler() const - { - return handler_; - } static sptr GetGlobalInstance(); int32_t SetUsbd(const sptr &usbd); int32_t OpenDevice(uint8_t busNum, uint8_t devAddr) override; @@ -187,8 +182,6 @@ private: std::shared_ptr usbRightManager_; std::shared_ptr usbPortManager_; std::shared_ptr usbDeviceManager_; - std::shared_ptr eventRunner_; - std::shared_ptr handler_; sptr usbdSubscriber_; sptr hdiCb_ = nullptr; sptr usbd_ = nullptr; diff --git a/services/native/src/usb_server_event_handler.cpp b/services/native/src/usb_server_event_handler.cpp deleted file mode 100644 index f09f81a916c8d378873f13a1e45790746f7cf681..0000000000000000000000000000000000000000 --- a/services/native/src/usb_server_event_handler.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "usb_server_event_handler.h" -#include "usb_service.h" - -namespace OHOS { -namespace USB { -UsbServerEventHandler::UsbServerEventHandler(const std::shared_ptr &runner, - const wptr &service) - : AppExecFwk::EventHandler(runner), service_(service) -{ - USB_HILOGI(MODULE_USB_SERVICE, "UsbServerEventHandler::UsbServerEventHandler instance created."); -} - -void UsbServerEventHandler::ProcessEvent([[maybe_unused]] const AppExecFwk::InnerEvent::Pointer &event) {} -} // namespace USB -} // namespace OHOS diff --git a/services/native/src/usb_service.cpp b/services/native/src/usb_service.cpp index 89ede8259d536800ae8676450de7e2d9a4183c7b..566f9a11bc8058825f1d0232cf5b30f37b4f208d 100644 --- a/services/native/src/usb_service.cpp +++ b/services/native/src/usb_service.cpp @@ -51,7 +51,6 @@ using namespace OHOS::HDI::Usb::V1_1; namespace OHOS { namespace USB { namespace { -constexpr const char *USB_SERVICE_NAME = "UsbService"; constexpr int32_t COMMEVENT_REGISTER_RETRY_TIMES = 10; constexpr int32_t COMMEVENT_REGISTER_WAIT_DELAY_US = 20000; constexpr uint32_t CURSOR_INIT = 18; @@ -211,21 +210,11 @@ void UsbService::OnStart() bool UsbService::Init() { USB_HILOGI(MODULE_USB_SERVICE, "usb_service Init enter"); - if (!eventRunner_) { - eventRunner_ = AppExecFwk::EventRunner::Create(USB_SERVICE_NAME); - if (eventRunner_ == nullptr) { - USB_HILOGE(MODULE_USB_SERVICE, "Init failed due to create EventRunner"); - return false; - } + if (!Publish(g_serviceInstance)) { + USB_HILOGE(MODULE_USB_SERVICE, "OnStart register to system ability manager failed."); + return false; } - if (handler_ == nullptr) { - handler_ = std::make_shared(eventRunner_, g_serviceInstance); - if (!Publish(g_serviceInstance)) { - USB_HILOGE(MODULE_USB_SERVICE, "OnStart register to system ability manager failed."); - return false; - } - } while (commEventRetryTimes_ <= COMMEVENT_REGISTER_RETRY_TIMES) { if (!IsCommonEventServiceAbilityExist()) { ++commEventRetryTimes_; @@ -270,8 +259,6 @@ void UsbService::OnStop() if (!ready_) { return; } - eventRunner_.reset(); - handler_.reset(); ready_ = false; if (usbd_ == nullptr) {