1 /* 2 * Copyright (C) 2021 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_STATE_PROCESSOR_H 17 #define TELEPHONY_CALL_STATE_PROCESSOR_H 18 19 #include <mutex> 20 #include <set> 21 #include <string> 22 23 #include "call_manager_inner_type.h" 24 #include "singleton.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 constexpr uint16_t EMPTY_VALUE = 0; 29 constexpr uint16_t EXIST_ONLY_ONE_CALL = 1; 30 31 class CallStateProcessor : public std::enable_shared_from_this<CallStateProcessor> { 32 DECLARE_DELAYED_SINGLETON(CallStateProcessor) 33 public: 34 void AddCall(int32_t callId, TelCallState state); 35 void DeleteCall(int32_t callId, TelCallState state); 36 bool UpdateCurrentCallState(); 37 bool ShouldStopSoundtone(); 38 int32_t GetCurrentActiveCall(); 39 int32_t GetCallNumber(TelCallState state); 40 bool ShouldSwitchState(TelCallState callState); 41 int32_t GetAudioForegroundLiveCall(); 42 43 private: 44 std::set<int32_t> activeCalls_; 45 std::set<int32_t> holdingCalls_; 46 std::set<int32_t> alertingCalls_; 47 std::set<int32_t> incomingCalls_; 48 std::set<int32_t> dialingCalls_; 49 std::mutex mutex_; 50 }; 51 } // namespace Telephony 52 } // namespace OHOS 53 #endif // TELEPHONY_CALL_STATE_PROCESSOR_H