• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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     int32_t GetSignalInfoList(int32_t slotId, std::vector<sptr<SignalInformation>> &signals);
36     bool IsNrSupported(int32_t slotId);
37     int32_t GetPsRadioTech(int32_t slotId, int32_t &psRadioTech);
38     int32_t GetCsRadioTech(int32_t slotId, int32_t &csRadioTech);
39     int32_t GetNrOptionMode(int32_t slotId, NrMode &mode);
40     int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId);
41     int32_t GetMeid(int32_t slotId, std::u16string &meid);
42     std::u16string GetOperatorNumeric(int32_t slotId);
43     int32_t GetOperatorName(int32_t slotId, std::u16string &operatorName);
44     int32_t GetNetworkState(int32_t slotId, sptr<NetworkState> &networkState);
45     int32_t SetRadioState(int32_t slotId, bool isOn, const sptr<INetworkSearchCallback> &callback);
46     int32_t GetRadioState(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
47     int32_t GetImei(int32_t slotId, std::u16string &imei);
48     int32_t HasSimCard(int32_t slotId, bool &hasSimCard);
49     int32_t GetSimState(int32_t slotId, SimState &simState);
50     int32_t GetSimOperatorNumeric(int32_t slotId, std::u16string &operatorNumeric);
51     int32_t GetISOCountryCodeForSim(int32_t slotId, std::u16string &countryCode);
52     int32_t GetSimSpn(int32_t slotId, std::u16string &spn);
53     int32_t GetSimIccId(int32_t slotId, std::u16string &iccId);
54     int32_t GetIMSI(int32_t slotId, std::u16string &imsi);
55     bool IsSimActive(int32_t slotId);
56     int32_t GetSlotId(int32_t simId);
57     int32_t GetSimId(int32_t slotId);
58     int32_t GetNetworkSearchInformation(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
59     int32_t GetNetworkSelectionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
60     std::u16string GetLocaleFromDefaultSim();
61     int32_t GetSimGid1(int32_t slotId, std::u16string &gid1);
62     std::u16string GetSimGid2(int32_t slotId);
63     std::u16string GetSimEons(int32_t slotId, const std::string &plmn, int32_t lac, bool longNameRequired);
64     int32_t SetNetworkSelectionMode(int32_t slotId, int32_t selectMode,
65         const sptr<NetworkInformation> &networkInformation, bool resumeSelection,
66         const sptr<INetworkSearchCallback> &callback);
67     int32_t GetIsoCountryCodeForNetwork(int32_t slotId, std::u16string &countryCode);
68     int32_t GetSimAccountInfo(int32_t slotId, IccAccountInfo &info);
69     int32_t SetDefaultVoiceSlotId(int32_t slotId);
70     int32_t GetDefaultVoiceSlotId();
71     int32_t SetShowNumber(int32_t slotId, const std::u16string &number);
72     int32_t GetShowNumber(int32_t slotId, std::u16string &showNumber);
73     int32_t SetShowName(int32_t slotId, const std::u16string &name);
74     int32_t GetShowName(int32_t slotId, std::u16string &showName);
75     int32_t GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList);
76     int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc);
77 
78     int32_t UnlockPin(int32_t slotId, const std::u16string &pin, LockStatusResponse &response);
79     int32_t UnlockPuk(
80         int32_t slotId, const std::u16string &newPin, const std::u16string &puk, LockStatusResponse &response);
81     int32_t AlterPin(
82         int32_t slotId, const std::u16string &newPin, const std::u16string &oldPin, LockStatusResponse &response);
83     int32_t UnlockPin2(int32_t slotId, const std::u16string &pin2, LockStatusResponse &response);
84     int32_t UnlockPuk2(
85         int32_t slotId, const std::u16string &newPin2, const std::u16string &puk2, LockStatusResponse &response);
86     int32_t AlterPin2(
87         int32_t slotId, const std::u16string &newPin2, const std::u16string &oldPin2, LockStatusResponse &response);
88     int32_t SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response);
89     int32_t GetLockState(int32_t slotId, LockType lockType, LockState &lockState);
90     int32_t RefreshSimState(int32_t slotId);
91     int32_t SetActiveSim(const int32_t slotId, int32_t enable);
92     int32_t GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback);
93     int32_t SetPreferredNetwork(int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback);
94     int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber);
95     int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier);
96     int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber);
97     int32_t QueryIccDiallingNumbers(int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result);
98     int32_t AddIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);
99     int32_t DelIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);
100     int32_t UpdateIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber);
101     int32_t SetVoiceMailInfo(int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber);
102     int32_t GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info);
103     int32_t GetMaxSimCount();
104     int32_t GetOpKey(int32_t slotId, std::u16string &opkey);
105     int32_t GetOpKeyExt(int32_t slotId, std::u16string &opkey);
106     int32_t GetOpName(int32_t slotId, std::u16string &opname);
107     int32_t GetCardType(int32_t slotId, CardType &cardType);
108     int32_t SendEnvelopeCmd(int32_t slotId, const std::string &cmd);
109     int32_t SendTerminalResponseCmd(int32_t slotId, const std::string &cmd);
110     int32_t SendCallSetupRequestResult(int32_t slotId, bool accept);
111     int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response);
112     int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges);
113     int32_t SimAuthentication(
114         int32_t slotId, const std::string &aid, const std::string &authData, SimAuthenticationResponse &response);
115     int32_t GetPrimarySlotId(int32_t &slotId);
116     int32_t SetPrimarySlotId(int32_t slotId);
117     int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo);
118     int32_t SendUpdateCellLocationRequest(int32_t slotId);
119     int32_t RegisterImsRegInfoCallback(
120         int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback);
121     int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType);
122 
123 private:
124     void RemoveDeathRecipient(const wptr<IRemoteObject> &remote, bool isRemoteDied);
125     class CoreServiceDeathRecipient : public IRemoteObject::DeathRecipient {
126     public:
CoreServiceDeathRecipient(CoreServiceClient & client)127         explicit CoreServiceDeathRecipient(CoreServiceClient &client) : client_(client) {}
128         ~CoreServiceDeathRecipient() override = default;
OnRemoteDied(const wptr<IRemoteObject> & remote)129         void OnRemoteDied(const wptr<IRemoteObject> &remote) override
130         {
131             client_.OnRemoteDied(remote);
132         }
133 
134     private:
135         CoreServiceClient &client_;
136     };
137 
138 private:
139     std::mutex mutexProxy_;
140     sptr<ICoreService> proxy_ { nullptr };
141     sptr<IRemoteObject::DeathRecipient> deathRecipient_ { nullptr };
142 };
143 } // namespace Telephony
144 } // namespace OHOS
145 #endif // CORE_SERVICE_CLIENT_H
146