• 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 CORE_SERVICE_CLIENT_H
17 #define CORE_SERVICE_CLIENT_H
18 
19 #include <cstdint>
20 #include <iremote_object.h>
21 #include <singleton.h>
22 #include <string_ex.h>
23 
24 #include "i_core_service.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class CoreServiceClient : public DelayedRefSingleton<CoreServiceClient> {
29     DECLARE_DELAYED_REF_SINGLETON(CoreServiceClient);
30 
31 public:
32     sptr<ICoreService> GetProxy();
33     void OnRemoteDied(const wptr<IRemoteObject> &remote);
34 
35     std::vector<sptr<SignalInformation>> GetSignalInfoList(int32_t slotId);
36     bool IsNrSupported(int32_t slotId);
37     int32_t GetPsRadioTech(int32_t slotId);
38     int32_t GetCsRadioTech(int32_t slotId);
39     NrMode GetNrOptionMode(int32_t slotId);
40     std::u16string GetUniqueDeviceId(int32_t slotId);
41     std::u16string GetMeid(int32_t slotId);
42     std::u16string GetOperatorNumeric(int32_t slotId);
43     std::u16string GetOperatorName(int32_t slotId);
44     const sptr<NetworkState> GetNetworkState(int32_t slotId);
45     bool SetRadioState(int32_t slotId, bool isOn, const sptr<INetworkSearchCallback> &callback);
46     bool GetRadioState(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
47     std::u16string GetImei(int32_t slotId);
48     bool HasSimCard(int32_t slotId);
49     int32_t GetSimState(int32_t slotId);
50     std::u16string GetSimOperatorNumeric(int32_t slotId);
51     std::u16string GetISOCountryCodeForSim(int32_t slotId);
52     std::u16string GetSimSpn(int32_t slotId);
53     std::u16string GetSimIccId(int32_t slotId);
54     std::u16string GetIMSI(int32_t slotId);
55     bool IsSimActive(int32_t slotId);
56     bool GetNetworkSearchInformation(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
57     bool GetNetworkSelectionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
58     std::u16string GetLocaleFromDefaultSim();
59     std::u16string GetSimGid1(int32_t slotId);
60     bool SetNetworkSelectionMode(int32_t slotId, int32_t selectMode,
61         const sptr<NetworkInformation> &networkInformation, bool resumeSelection,
62         const sptr<INetworkSearchCallback> &callback);
63     std::u16string GetIsoCountryCodeForNetwork(int32_t slotId);
64     bool GetSimAccountInfo(int32_t slotId, IccAccountInfo &info);
65     bool SetDefaultVoiceSlotId(int32_t slotId);
66     int32_t GetDefaultVoiceSlotId();
67     bool SetShowNumber(int32_t slotId, const std::u16string number);
68     std::u16string GetShowNumber(int32_t slotId);
69     bool SetShowName(int32_t slotId, const std::u16string name);
70     std::u16string GetShowName(int32_t slotId);
71     bool GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList);
72     bool GetOperatorConfigs(int32_t slotId, OperatorConfig &poc);
73 
74     bool UnlockPin(int32_t slotId, std::u16string pin, LockStatusResponse &response);
75     bool UnlockPuk(int32_t slotId, std::u16string newPin, std::u16string puk, LockStatusResponse &response);
76     bool AlterPin(int32_t slotId, std::u16string newPin, std::u16string oldPin, LockStatusResponse &response);
77     bool UnlockPin2(int32_t slotId, std::u16string pin2, LockStatusResponse &response);
78     bool UnlockPuk2(int32_t slotId, std::u16string newPin2, std::u16string puk2, LockStatusResponse &response);
79     bool AlterPin2(int32_t slotId, std::u16string newPin2, std::u16string oldPin2, LockStatusResponse &response);
80     bool SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response);
81     int32_t GetLockState(int32_t slotId, LockType lockType);
82     int32_t RefreshSimState(int32_t slotId);
83     bool SetActiveSim(const int32_t slotId, int32_t enable);
84     bool GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
85     bool SetPreferredNetwork(int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback);
86     std::u16string GetSimTelephoneNumber(int32_t slotId);
87     std::u16string GetVoiceMailIdentifier(int32_t slotId);
88     std::u16string GetVoiceMailNumber(int32_t slotId);
89     std::vector<std::shared_ptr<DiallingNumbersInfo>> QueryIccDiallingNumbers(int slotId, int type);
90     bool AddIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);
91     bool DelIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);
92     bool UpdateIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);
93     bool SetVoiceMailInfo(int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber);
94     bool GetImsRegStatus(int32_t slotId);
95     int32_t GetMaxSimCount();
96     int32_t GetCardType(int32_t slotId);
97     bool SendEnvelopeCmd(int32_t slotId, const std::string &cmd);
98     bool SendTerminalResponseCmd(int32_t slotId, const std::string &cmd);
99     bool UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response);
100     bool HasOperatorPrivileges(const int32_t slotId);
101     int32_t GetPrimarySlotId();
102     bool SetPrimarySlotId(int32_t slotId);
103     std::vector<sptr<CellInformation>> GetCellInfoList(int32_t slotId);
104     bool SendUpdateCellLocationRequest(int32_t slotId);
105 
106 private:
107     class CoreServiceDeathRecipient : public IRemoteObject::DeathRecipient {
108     public:
CoreServiceDeathRecipient(CoreServiceClient & client)109         explicit CoreServiceDeathRecipient(CoreServiceClient &client) : client_(client) {}
110         ~CoreServiceDeathRecipient() override = default;
OnRemoteDied(const wptr<IRemoteObject> & remote)111         void OnRemoteDied(const wptr<IRemoteObject> &remote) override
112         {
113             client_.OnRemoteDied(remote);
114         }
115 
116     private:
117         CoreServiceClient &client_;
118     };
119 
120 private:
121     std::mutex mutexProxy_;
122     sptr<ICoreService> proxy_ {nullptr};
123     sptr<IRemoteObject::DeathRecipient> deathRecipient_ {nullptr};
124 };
125 } // namespace Telephony
126 } // namespace OHOS
127 #endif // CORE_SERVICE_CLIENT_H
128