• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "dump_event_handler.h"
16 #include "util/dump_cpu_info_util.h"
17 #include "dump_manager_service.h"
18 #include "hilog_wrapper.h"
19 namespace OHOS {
20 namespace HiviewDFX {
21 const int DumpEventHandler::MSG_GET_CPU_INFO_ID = 1;
22 const int DumpEventHandler::GET_CPU_INFO_DELAY_TIME = 5 * 1000;
23 
DumpEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner,const wptr<DumpManagerService> & service)24 DumpEventHandler::DumpEventHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner,
25     const wptr<DumpManagerService>& service)
26     : AppExecFwk::EventHandler(runner), service_(service)
27 {
28 }
29 
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)30 void DumpEventHandler::ProcessEvent([[maybe_unused]] const AppExecFwk::InnerEvent::Pointer& event)
31 {
32     auto dmsptr = service_.promote();
33     if (dmsptr == nullptr) {
34         DUMPER_HILOGD(MODULE_SERVICE, "service is nullptr!");
35         return;
36     }
37 
38     if (event == nullptr) {
39         DUMPER_HILOGD(MODULE_SERVICE, "event is nullptr!");
40         return;
41     }
42     auto eventId = event->GetInnerEventId();
43     DUMPER_HILOGD(MODULE_SERVICE, "debug|eventId=%{public}d", eventId);
44     switch (eventId) {
45         case MSG_GET_CPU_INFO_ID: {
46             DUMPER_HILOGD(MODULE_SERVICE, "MSG_GET_CPU_INFO_ID!");
47             DumpCpuInfoUtil::GetInstance().UpdateCpuInfo();
48             break;
49         }
50         default:
51             break;
52     }
53 }
54 } // namespace HiviewDFX
55 } // namespace OHOS
56