1 /* 2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #include "app_event_handler.h" 16 17 #include "app_event_observer_mgr.h" 18 #include "hiappevent_base.h" 19 #include "hilog/log.h" 20 21 #undef LOG_DOMAIN 22 #define LOG_DOMAIN 0xD002D07 23 24 #undef LOG_TAG 25 #define LOG_TAG "AppEventHandler" 26 27 namespace OHOS { 28 namespace HiviewDFX { AppEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner)29AppEventHandler::AppEventHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner) 30 : AppExecFwk::EventHandler(runner) 31 { 32 HILOG_INFO(LOG_CORE, "AppEventHandler instance created"); 33 } 34 ~AppEventHandler()35AppEventHandler::~AppEventHandler() 36 { 37 HILOG_INFO(LOG_CORE, "AppEventHandler instance destroyed"); 38 } 39 ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)40void AppEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) 41 { 42 if (event->GetInnerEventId() == AppEventType::WATCHER_TIMEOUT) { 43 AppEventObserverMgr::GetInstance().HandleTimeout(); 44 } else { 45 HILOG_WARN(LOG_CORE, "invalid event id=%{public}u", event->GetInnerEventId()); 46 } 47 } 48 } // namespace HiviewDFX 49 } // namespace OHOS 50