• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "mock_hardware_handler.h"
17 
18 #include "distributed_hardware_errno.h"
19 
20 namespace OHOS {
21 namespace DistributedHardware {
Initialize()22 int32_t MockHardwareHandler::Initialize()
23 {
24     return DH_FWK_SUCCESS;
25 }
26 
Query()27 std::vector<DHItem> MockHardwareHandler::Query()
28 {
29     DHItem item;
30     return std::vector<DHItem> { item };
31 }
32 
QueryExtraInfo()33 std::map<std::string, std::string> MockHardwareHandler::QueryExtraInfo()
34 {
35     std::map<std::string, std::string> extraInfo;
36     return extraInfo;
37 }
38 
IsSupportPlugin()39 bool MockHardwareHandler::IsSupportPlugin()
40 {
41     return true;
42 }
43 
RegisterPluginListener(std::shared_ptr<PluginListener> listener)44 void MockHardwareHandler::RegisterPluginListener(std::shared_ptr<PluginListener> listener)
45 {
46     listener_ = listener;
47 }
48 
UnRegisterPluginListener()49 void MockHardwareHandler::UnRegisterPluginListener()
50 {
51     listener_ = nullptr;
52 }
53 
PluginHardware(const std::string & dhId,const std::string & attr)54 int32_t MockHardwareHandler::PluginHardware(const std::string &dhId, const std::string &attr)
55 {
56     if (listener_ != nullptr) {
57         listener_->PluginHardware(dhId, attr);
58     }
59     return DH_FWK_SUCCESS;
60 }
61 
UnPluginHardware(const std::string & dhId)62 int32_t MockHardwareHandler::UnPluginHardware(const std::string &dhId)
63 {
64     if (listener_ != nullptr) {
65         listener_->UnPluginHardware(dhId);
66     }
67     return DH_FWK_SUCCESS;
68 }
69 } // namespace DistributedHardware
70 } // namespace OHOS