• 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 "hardkey_input.h"
17 #include "input_manager.h"
18 #include "multimode_manager.h"
19 #include "wukong_define.h"
20 #include "report.h"
21 
22 namespace OHOS {
23 namespace WuKong {
24 namespace {
25 const int HARDKEY_COUNT = 2;
26 const int DOWN_TIME = 10;
27 }  // namespace
HardkeyInput()28 HardkeyInput::HardkeyInput() : InputAction()
29 {
30     std::shared_ptr<MultimodeInputMsg> multimodeInputMsg = std::make_shared<MultimodeInputMsg>();
31     multimodeInputMsg->inputType_ = INPUTTYPE_HARDKEYINPUT;
32     inputedMsgObject_ = multimodeInputMsg;
33 }
34 
~HardkeyInput()35 HardkeyInput::~HardkeyInput() {}
36 
OrderInput(const std::shared_ptr<SpcialTestObject> & specialTestObject)37 ErrCode HardkeyInput::OrderInput(const std::shared_ptr<SpcialTestObject>& specialTestObject)
38 {
39     ErrCode result = MultimodeManager::GetInstance()->SingleKeyCodeInput(MMI::KeyEvent::KEYCODE_POWER, DOWN_TIME);
40     return result;
41 }
42 
RandomInput()43 ErrCode HardkeyInput::RandomInput()
44 {
45     int keycode = MMI::KeyEvent::KEYCODE_VOLUME_UP + rand() % HARDKEY_COUNT;
46     ErrCode result = MultimodeManager::GetInstance()->SingleKeyCodeInput(keycode, DOWN_TIME);
47     Report::GetInstance()->SyncInputInfo(inputedMsgObject_);
48     return result;
49 }
50 
GetInputInfo()51 ErrCode HardkeyInput::GetInputInfo()
52 {
53     return OHOS::ERR_OK;
54 }
55 }  // namespace WuKong
56 }  // namespace OHOS
57