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 OHOS_STK_CONTROLLER_H 17 #define OHOS_STK_CONTROLLER_H 18 19 #include "i_tel_ril_manager.h" 20 #include "inner_event.h" 21 #include "sim_state_manager.h" 22 #include "tel_event_handler.h" 23 #include "want.h" 24 25 namespace OHOS { 26 namespace Telephony { 27 class StkController : public TelEventHandler { 28 public: 29 explicit StkController(const std::weak_ptr<Telephony::ITelRilManager> &telRilManager, 30 const std::weak_ptr<Telephony::SimStateManager> &simStateManager, int32_t slotId); 31 virtual ~StkController() = default; 32 void Init(); 33 std::string initStkBudleName(); 34 int32_t SendTerminalResponseCmd(const std::string &strCmd); 35 int32_t SendEnvelopeCmd(const std::string &strCmd); 36 int32_t SendCallSetupRequestResult(bool accept); 37 void UnRegisterEvents(); 38 39 public: 40 enum { 41 RETRY_SEND_RIL_PROACTIVE_COMMAND = 0, 42 }; 43 44 private: 45 void RegisterEvents(); 46 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 47 void OnIccStateChanged(const AppExecFwk::InnerEvent::Pointer &event); 48 void OnSendRilSessionEnd(const AppExecFwk::InnerEvent::Pointer &event); 49 void OnSendRilProactiveCommand(const AppExecFwk::InnerEvent::Pointer &event); 50 void OnSendRilAlphaNotify(const AppExecFwk::InnerEvent::Pointer &event); 51 void OnSendRilEventNotify(const AppExecFwk::InnerEvent::Pointer &event); 52 void OnIccRefresh(const AppExecFwk::InnerEvent::Pointer &event); 53 bool PublishStkEvent(AAFwk::Want &want); 54 void OnSendTerminalResponseResult(const AppExecFwk::InnerEvent::Pointer &event); 55 void OnSendEnvelopeCmdResult(const AppExecFwk::InnerEvent::Pointer &event); 56 void OnSendCallSetupRequestResult(const AppExecFwk::InnerEvent::Pointer &event); 57 bool CheckIsSystemApp(const std::string &bundleName); 58 sptr<OHOS::IRemoteObject> GetBundleMgr(); 59 void RetrySendRilProactiveCommand(); 60 61 private: 62 std::weak_ptr<Telephony::ITelRilManager> telRilManager_; 63 std::weak_ptr<Telephony::SimStateManager> simStateManager_; 64 int slotId_ = 0; 65 int32_t iccCardState_ = 0; 66 int32_t envelopeResponseResult_ = 0; 67 int32_t terminalResponseResult_ = 0; 68 int32_t callSetupResponseResult_ = 0; 69 bool responseFinished_ = false; 70 std::string stkBundleName_ = ""; 71 std::mutex stkMutex_; 72 std::condition_variable stkCv_; 73 AAFwk::Want retryWant_; 74 int32_t remainTryCount_ = 0; 75 }; 76 } // namespace Telephony 77 } // namespace OHOS 78 #endif // OHOS_STK_CONTROLLER_H 79