• 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_SIM_SMS_CONTROLLER_H
17 #define OHOS_SIM_SMS_CONTROLLER_H
18 
19 #include "icc_file_controller.h"
20 #include "sim_state_manager.h"
21 #include "sim_file_manager.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 enum {
26     SIM_SMS_STATE_DELETE = 0,
27     SIM_SMS_STATE_READ = 1,
28     SIM_SMS_STATE_UNREAD = 3,
29     SIM_SMS_STATE_SENT = 5,
30     SIM_SMS_STATE_UNSENT = 7,
31 };
32 
33 enum {
34     SIM_SMS_GET_COMPLETED = 1,
35     SIM_SMS_UPDATE_COMPLETED = 2,
36     SIM_SMS_WRITE_COMPLETED = 3,
37     SIM_SMS_DELETE_COMPLETED = 4
38 };
39 
40 class SimSmsController : public AppExecFwk::EventHandler {
41 public:
42     SimSmsController(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
43         std::shared_ptr<SimStateManager> simStateManager);
44     ~SimSmsController();
45     void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
46     int32_t AddSmsToIcc(int status, std::string &pdu, std::string &smsc);
47     int32_t UpdateSmsIcc(int index, int status, std::string &pduData, std::string &smsc);
48     int32_t DelSmsIcc(int index);
49     std::vector<std::string> ObtainAllSmsOfIcc();
50     void SetRilAndFileManager(
51         std::shared_ptr<Telephony::ITelRilManager> ril, std::shared_ptr<SimFileManager> fileMgr);
52     void Init(int slotId);
53 
54 protected:
55     std::shared_ptr<SimFileManager> fileManager_ = nullptr;
56     std::shared_ptr<Telephony::ITelRilManager> telRilManager_ = nullptr;
57     std::shared_ptr<SimStateManager> stateManager_ = nullptr;
58     bool responseReady_ = false;
59     bool loadDone_ = false;
60     int slotId_ = 0;
61 
62 private:
63     bool IsCdmaCardType() const;
64     std::vector<std::string> smsList_;
65     static std::mutex mtx_;
66     std::condition_variable processWait_;
67     void ProcessLoadDone(const AppExecFwk::InnerEvent::Pointer &event);
68     void ProcessUpdateDone(const AppExecFwk::InnerEvent::Pointer &event);
69     void ProcessWriteDone(const AppExecFwk::InnerEvent::Pointer &event);
70     void ProcessDeleteDone(const AppExecFwk::InnerEvent::Pointer &event);
71     AppExecFwk::InnerEvent::Pointer BuildCallerInfo(int eventId);
72 };
73 } // namespace Telephony
74 } // namespace OHOS
75 #endif // OHOS_SIM_SMS_CONTROLLER_H