1 /* 2 * Copyright (c) 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 16 #include "input_interface_implement.h" 17 #include <memory> 18 #include "hdf_log.h" 19 #include "input_interface_device_info.h" 20 #include "input_interface_reporter.h" 21 22 #define HDF_LOG_TAG InputIfImpl 23 24 namespace OHOS { 25 namespace Input { 26 using namespace std; Init()27RetStatus InputIfImpl::Init() 28 { 29 reporterSptr_ = std::make_shared<InputIfReporter>(); 30 if (reporterSptr_ == nullptr) { 31 HDF_LOGE("input interface init reporter failed"); 32 return INPUT_NOMEM; 33 } 34 deviceInfoSptr_ = std::make_shared<DeviceInfo>(reporterSptr_); 35 if (deviceInfoSptr_ == nullptr) { 36 HDF_LOGE("input interface init device info failed"); 37 return INPUT_NOMEM; 38 } 39 return deviceInfoSptr_->Init(); 40 } 41 ~InputIfImpl()42InputIfImpl::~InputIfImpl() 43 { 44 deviceInfoSptr_->Stop(); 45 } 46 RegisterReportCallback(InputEventCb * callback)47RetStatus InputIfImpl::RegisterReportCallback(InputEventCb *callback) 48 { 49 return reporterSptr_->RegisterReportCallback(callback); 50 } 51 UnregisterReportCallback()52RetStatus InputIfImpl::UnregisterReportCallback() 53 { 54 return reporterSptr_->UnregisterReportCallback(); 55 } 56 } 57 } 58