• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "event_handler.h"
20 #include "inner_event.h"
21 #include "i_tel_ril_manager.h"
22 #include "sim_state_manager.h"
23 #include "want.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 class StkController : public AppExecFwk::EventHandler {
28 public:
29     StkController(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
30         const std::weak_ptr<Telephony::ITelRilManager> &telRilManager,
31         const std::weak_ptr<Telephony::SimStateManager> &simStateManager, int32_t slotId);
32     virtual ~StkController() = default;
33     void Init();
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 private:
40     void RegisterEvents();
41     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
42     void OnIccStateChanged(const AppExecFwk::InnerEvent::Pointer &event);
43     void OnSendRilSessionEnd(const AppExecFwk::InnerEvent::Pointer &event) const;
44     void OnSendRilProactiveCommand(const AppExecFwk::InnerEvent::Pointer &event) const;
45     void OnSendRilAlphaNotify(const AppExecFwk::InnerEvent::Pointer &event) const;
46     void OnSendRilEventNotify(const AppExecFwk::InnerEvent::Pointer &event) const;
47     void OnIccRefresh(const AppExecFwk::InnerEvent::Pointer &event) const;
48     bool PublishStkEvent(const AAFwk::Want &want) const;
49     void OnSendTerminalResponseResult(const AppExecFwk::InnerEvent::Pointer &event);
50     void OnSendEnvelopeCmdResult(const AppExecFwk::InnerEvent::Pointer &event);
51     void OnSendCallSetupRequestResult(const AppExecFwk::InnerEvent::Pointer &event);
52 
53 private:
54     std::weak_ptr<Telephony::ITelRilManager> telRilManager_;
55     std::weak_ptr<Telephony::SimStateManager> simStateManager_;
56     int slotId_ = 0;
57     int32_t iccCardState_ = 0;
58     int32_t envelopeResponseResult_ = 0;
59     int32_t terminalResponseResult_ = 0;
60     int32_t callSetupResponseResult_ = 0;
61     bool responseFinished_ = false;
62     std::mutex stkMutex_;
63     std::condition_variable stkCv_;
64 };
65 } // namespace Telephony
66 } // namespace OHOS
67 #endif // OHOS_STK_CONTROLLER_H
68