1 /* 2 * Copyright (C) 2024 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 #ifndef TELEPHONY_CALL_WIRED_HEADSET_H 17 #define TELEPHONY_CALL_WIRED_HEADSET_H 18 19 #include <memory> 20 #include "key_event.h" 21 #include "singleton.h" 22 #include "key_option.h" 23 24 namespace OHOS { 25 namespace Telephony { 26 class CallWiredHeadSet : public std::enable_shared_from_this<CallWiredHeadSet> { 27 DECLARE_DELAYED_SINGLETON(CallWiredHeadSet) 28 public: 29 bool Init(); 30 void DeInit(); 31 32 std::shared_ptr<MMI::KeyOption> InitOption( 33 const std::set<int32_t> &preKeys, int32_t finalKey, bool isFinalKeyDown, int32_t duration); 34 bool RegistKeyMutePressedUp(); 35 void UnregistKeyMutePressedUp(); 36 bool RegistKeyMutePressedDown(); 37 void UnregistKeyMutePressedDown(); 38 39 void DealKeyMutePressedUp(const std::shared_ptr<OHOS::MMI::KeyEvent>); 40 void DealKeyMutePressedDown(const std::shared_ptr<OHOS::MMI::KeyEvent>); 41 void DealKeyMuteShortPressed(); 42 void DealKeyMuteLongPressed(); 43 44 private: 45 time_t GetCurrentTimeMS(); 46 private: 47 bool isProcessed_; 48 time_t downFirstTime_; 49 int32_t subscribeIdForPressedUp_; 50 int32_t subscribeIdForPressedDown_; 51 }; 52 } // namespace Telephony 53 } // namespace OHOS 54 #endif // TELEPHONY_CALL_WIRED_HEADSET_H 55