/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SMS_MISC_MANAGER_H #define SMS_MISC_MANAGER_H #include #include #include #include #include #include "event_handler.h" #include "event_runner.h" #include "i_sms_service_interface.h" namespace OHOS { namespace Telephony { class SmsMiscManager : public AppExecFwk::EventHandler { public: enum { SET_CB_CONFIG_FINISH = 0, SET_SMSC_ADDR_FINISH, GET_SMSC_ADDR_FINISH, }; using gsmCBRangeInfo = struct RangeInfo { RangeInfo(uint32_t fromId, uint32_t toId) { fromMsgId = fromId; toMsgId = toId; } uint32_t fromMsgId = 0; uint32_t toMsgId = 0; bool operator<(const RangeInfo &other) const { return fromMsgId < other.fromMsgId; } }; SmsMiscManager(const std::shared_ptr &runner, int32_t slotId); virtual ~SmsMiscManager() {}; int32_t SetCBConfig(bool enable, uint32_t fromMsgId, uint32_t toMsgId, uint8_t netType); std::list GetRangeInfo() const; virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; int32_t AddSimMessage( const std::string &smsc, const std::string &pdu, ISmsServiceInterface::SimMessageStatus status); int32_t DelSimMessage(uint32_t msgIndex); int32_t UpdateSimMessage(uint32_t msgIndex, ISmsServiceInterface::SimMessageStatus newStatus, const std::string &pdu, const std::string &smsc); int32_t GetAllSimMessages(std::vector &message); int32_t SetSmscAddr(const std::string &scAddr); int32_t GetSmscAddr(std::u16string &smscAddress); int32_t SetDefaultSmsSlotId(int32_t slotId); int32_t GetDefaultSmsSlotId(); int32_t GetDefaultSmsSimId(int32_t &simId); protected: bool OpenCBRange(uint32_t fromMsgId, uint32_t toMsgId); bool CloseCBRange(uint32_t fromMsgId, uint32_t toMsgId); void NotifyHasResponse(); bool IsEmpty() const; std::string RangeListToString(const std::list &rangeList); std::list fairList_; int32_t fairVar_ = -1; int32_t conditonVar_ = 0; bool isSuccess_ = false; int32_t slotId_; private: using infoData = struct info { info(uint32_t fromMsgId, uint32_t toMsgId) { startPos = fromMsgId; endPos = toMsgId; } bool isMerge = false; uint32_t startPos = 0; uint32_t endPos = 0; }; bool SendDataToRil(bool enable, std::list &list); bool ExpandMsgId( uint32_t fromMsgId, uint32_t toMsgId, const std::list::iterator &oldIter, infoData &data); void SplitMsgId( uint32_t fromMsgId, uint32_t toMsgId, const std::list::iterator &oldIter, infoData &data); std::list rangeList_; std::condition_variable condVar_; std::mutex mutex_; std::string smscAddr_; std::string codeScheme_ {"0-255"}; std::list oldRangeList_; int32_t smsCapacityOfSim_ = 0; }; } // namespace Telephony } // namespace OHOS #endif