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 "accessibility_short_key.h"
17 #include "hilog_wrapper.h"
18 
19 namespace OHOS {
20 namespace Accessibility {
21 namespace {
22     constexpr int32_t SUBSCRIBE_ID = 1;
23     constexpr int32_t KEYCODE_VOLUME_UP = 0;
24     constexpr int32_t KEYCODE_VOLUME_DOWN = 1;
25     constexpr int32_t SHORTCUT_TIMEOUT = 3000;
26 }
27 
~AccessibilityShortKey()28 AccessibilityShortKey::~AccessibilityShortKey()
29 {
30     HILOG_DEBUG("start.");
31     subscribeId_ = -1;
32 }
33 
SubscribeShortKey(std::set<int32_t> preKeys,int32_t finalKey,int32_t holdTime)34 void AccessibilityShortKey::SubscribeShortKey(std::set<int32_t> preKeys, int32_t finalKey, int32_t holdTime)
35 {
36     HILOG_DEBUG("start.");
37     (void)preKeys;
38     (void)finalKey;
39     (void)holdTime;
40     subscribeId_ = SUBSCRIBE_ID;
41 }
42 
Register()43 void AccessibilityShortKey::Register()
44 {
45     HILOG_DEBUG("start.");
46     std::set<int32_t> preDownKeysUp;
47     preDownKeysUp.insert(KEYCODE_VOLUME_UP);
48     SubscribeShortKey(preDownKeysUp, KEYCODE_VOLUME_DOWN, SHORTCUT_TIMEOUT);
49 }
50 
Unregister()51 void AccessibilityShortKey::Unregister()
52 {
53     HILOG_DEBUG("start.");
54     subscribeId_ = -1;
55 }
56 
OnShortKey()57 void AccessibilityShortKey::OnShortKey()
58 {
59     HILOG_DEBUG("start.");
60 }
61 } // namespace Accessibility
62 } // namespace OHOS