• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2023 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 BASE_PHONE_SERVICE_PROXY_H
17 #define BASE_PHONE_SERVICE_PROXY_H
18 
19 #include "i_core_service.h"
20 #include "core_service_ipc_interface_code.h"
21 
22 namespace OHOS {
23 namespace Telephony {
24 class CoreServiceProxy : public IRemoteProxy<ICoreService> {
25 public:
CoreServiceProxy(const sptr<IRemoteObject> & impl)26     explicit CoreServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<ICoreService>(impl) {}
27     virtual ~CoreServiceProxy() = default;
28     int32_t GetPsRadioTech(int32_t slotId, int32_t &psRadioTech) override;
29     int32_t GetCsRadioTech(int32_t slotId, int32_t &csRadioTech) override;
30     int32_t GetSignalInfoList(int32_t slotId, std::vector<sptr<SignalInformation>> &signals) override;
31     std::u16string GetOperatorNumeric(int32_t slotId) override;
32     std::string GetResidentNetworkNumeric(int32_t slotId) override;
33     int32_t GetOperatorName(int32_t slotId, std::u16string &operatorName) override;
34     int32_t GetBasebandVersion(int32_t slotId, std::string &version) override;
35     int32_t GetNetworkState(int32_t slotId, sptr<NetworkState> &networkState) override;
36     int32_t SetRadioState(int32_t slotId, bool isOn, const sptr<INetworkSearchCallback> &callback) override;
37     int32_t GetRadioState(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override;
38     int32_t SetNrOptionMode(int32_t slotId, int32_t mode, const sptr<INetworkSearchCallback> &callback) override;
39     int32_t GetNrOptionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override;
40     int32_t GetImei(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
41     int32_t GetImeiSv(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
42     int32_t GetMeid(int32_t slotId, std::u16string &meid) override;
43     int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId) override;
44     int32_t GetNetworkSearchInformation(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override;
45     int32_t GetNetworkSelectionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override;
46     int32_t SetNetworkSelectionMode(int32_t slotId, int32_t selectMode,
47         const sptr<NetworkInformation> &networkInformation, bool resumeSelection,
48         const sptr<INetworkSearchCallback> &callback) override;
49     bool IsNrSupported(int32_t slotId) override;
50 
51     bool IsSimActive(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
52     int32_t GetIsoCountryCodeForNetwork(int32_t slotId, std::u16string &countryCode) override;
53     int32_t HasSimCard(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
54     int32_t GetSlotId(int32_t simId) override;
55     int32_t GetSimId(int32_t slotId) override;
56     int32_t GetSimIccId(int32_t slotId, std::u16string &iccId) override;
57     int32_t GetSimState(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
58     int32_t GetDsdsMode(int32_t &dsdsMode) override;
59     int32_t GetCardType(int32_t slotId, CardType &cardType) override;
60     int32_t GetSimSpn(int32_t slotId, std::u16string &spn) override;
61     int32_t GetIMSI(int32_t slotId, std::u16string &imsi) override;
62     int32_t IsCTSimCard(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
63     int32_t GetSimGid1(int32_t slotId, std::u16string &gid1) override;
64     int32_t GetSimOperatorNumeric(int32_t slotId, std::u16string &operatorNumeric) override;
65     int32_t GetISOCountryCodeForSim(int32_t slotId, std::u16string &countryCode) override;
66     std::u16string GetLocaleFromDefaultSim() override;
67     std::u16string GetSimGid2(int32_t slotId) override;
68     std::u16string GetSimEons(int32_t slotId, const std::string &plmn, int32_t lac, bool longNameRequired) override;
69     int32_t GetSimAccountInfo(int32_t slotId, IccAccountInfo &info) override;
70     int32_t SetDefaultVoiceSlotId(int32_t slotId) override;
71     int32_t GetDefaultVoiceSlotId() override;
72     int32_t GetDefaultVoiceSimId(const sptr<IRawParcelCallback> &callback) override;
73     int32_t GetPrimarySlotId(int32_t &slotId) override;
74     int32_t SetPrimarySlotId(int32_t slotId) override;
75     int32_t SetShowNumber(int32_t slotId, const std::u16string &number,
76         const sptr<IRawParcelCallback> &callback) override;
77     int32_t GetShowNumber(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
78     int32_t SetShowName(int32_t slotId, const std::u16string &name, const sptr<IRawParcelCallback> &callback) override;
79     int32_t GetShowName(int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
80     int32_t GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList) override;
81     int32_t GetOperatorConfigs(int32_t slotId, OperatorConfig &poc) override;
82     bool IsValidSlotId(int32_t slotId);
83     bool IsValidSlotIdEx(int32_t slotId);
84     bool IsValidSlotIdForDefault(int32_t slotId);
85     bool IsValidStringLength(std::u16string str);
86     bool IsValidServiceType(ImsServiceType serviceType);
87 
88     int32_t UnlockPin(const int32_t slotId, const std::u16string &pin,
89         const sptr<IRawParcelCallback> &callback) override;
90     int32_t UnlockPuk(const int32_t slotId, const std::u16string &newPin, const std::u16string &puk,
91         const sptr<IRawParcelCallback> &callback) override;
92     int32_t AlterPin(const int32_t slotId, const std::u16string &newPin, const std::u16string &oldPin,
93         const sptr<IRawParcelCallback> &callback) override;
94     int32_t UnlockPin2(const int32_t slotId, const std::u16string &pin2,
95         const sptr<IRawParcelCallback> &callback) override;
96     int32_t UnlockPuk2(const int32_t slotId, const std::u16string &newPin2, const std::u16string &puk2,
97         const sptr<IRawParcelCallback> &callback) override;
98     int32_t AlterPin2(const int32_t slotId, const std::u16string &newPin2, const std::u16string &oldPin2,
99         const sptr<IRawParcelCallback> &callback) override;
100     int32_t SetLockState(const int32_t slotId, const LockInfo &options,
101         const sptr<IRawParcelCallback> &callback) override;
102     int32_t GetLockState(int32_t slotId, LockType lockType, const sptr<IRawParcelCallback> &callback) override;
103     int32_t RefreshSimState(int32_t slotId) override;
104     int32_t SetActiveSim(int32_t slotId, int32_t enable) override;
105     int32_t SetActiveSimSatellite(int32_t slotId, int32_t enable) override;
106     int32_t GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback) override;
107     int32_t SetPreferredNetwork(
108         int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback) override;
109     int32_t GetNetworkCapability(
110         int32_t slotId, int32_t networkCapabilityType, int32_t &networkCapabilityState) override;
111     int32_t SetNetworkCapability(
112         int32_t slotId, int32_t networkCapabilityType, int32_t networkCapabilityState) override;
113     int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber) override;
114     std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) override;
115     int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) override;
116     int32_t QueryIccDiallingNumbers(
117         int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result) override;
118     int32_t AddIccDiallingNumbers(
119         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override;
120     int32_t DelIccDiallingNumbers(
121         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override;
122     int32_t UpdateIccDiallingNumbers(
123         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override;
124     int32_t SetVoiceMailInfo(
125         const int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber) override;
126     int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) override;
127     int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) override;
128     int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) override;
129     int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) override;
130     int32_t GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info) override;
131     int32_t GetMaxSimCount() override;
132     int32_t GetOpKey(int32_t slotId, std::u16string &opkey) override;
133     int32_t GetOpKeyExt(int32_t slotId, std::u16string &opkeyExt) override;
134     int32_t GetOpName(int32_t slotId, std::u16string &opname) override;
135     int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response) override;
136     int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo) override;
137     int32_t GetNeighboringCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo) override;
138     int32_t SendEnvelopeCmd(int32_t slotId, const std::string &cmd) override;
139     int32_t SendTerminalResponseCmd(int32_t slotId, const std::string &cmd) override;
140     int32_t SendCallSetupRequestResult(int32_t slotId, bool accept) override;
141     int32_t SendUpdateCellLocationRequest(int32_t slotId) override;
142     int32_t HasOperatorPrivileges(const int32_t slotId, const sptr<IRawParcelCallback> &callback) override;
143     int32_t SimAuthentication(
144         int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) override;
145     int32_t RegisterImsRegInfoCallback(
146         int32_t slotId, ImsServiceType imsSrvType, const sptr<ImsRegInfoCallback> &callback) override;
147     int32_t UnregisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType) override;
148     int32_t FactoryReset(int32_t slotId) override;
149     int32_t GetNrSsbIdInfo(int32_t slotId, const std::shared_ptr<NrSsbInformation> &nrSsbInformation) override;
150     bool IsAllowedInsertApn(std::string &value) override;
151     int32_t GetTargetOpkey(int32_t slotId, std::u16string &opkey) override;
152     int32_t GetOpkeyVersion(std::string &versionInfo) override;
153     int32_t GetOpnameVersion(std::string &versionInfo) override;
154     int32_t GetSimIO(int32_t slotId, int32_t command, int32_t fileId,
155         const std::string &data, const std::string &path, SimAuthenticationResponse &response) override;
156     int32_t GetAllSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList) override;
157     int32_t GetSimLabel(int32_t slotId, SimLabel &simLabel, const sptr<IRawParcelCallback> &callback) override;
158     int32_t SendApduData(int32_t slotId, const std::u16string &aid, const EsimApduData &apduData,
159         ResponseEsimResult &responseResult) override;
160 
161 private:
162     template<class T>
ProcessReply(MessageParcel & reply,std::vector<sptr<CellInformation>> & cells)163     void ProcessReply(MessageParcel &reply, std::vector<sptr<CellInformation>> &cells)
164     {
165         std::unique_ptr<T> cell = std::make_unique<T>();
166         if (cell != nullptr) {
167             cell->ReadFromParcel(reply);
168             cells.emplace_back(cell.release());
169         }
170     }
171     bool WriteInterfaceToken(MessageParcel &data);
172     void ProcessSignalInfo(MessageParcel &reply, std::vector<sptr<SignalInformation>> &result);
173     void ProcessCellInfo(MessageParcel &reply, std::vector<sptr<CellInformation>> &cells);
174     int32_t SerializeImsRegInfoData(int32_t slotId, ImsServiceType imsSrvType, MessageParcel &data);
175     bool WriteEsimApduData(MessageParcel &data, const EsimApduData &apduData);
176 
177 private:
178     static inline BrokerDelegator<CoreServiceProxy> delegator_;
179     std::vector<IccAccountInfo> activeIccAccountInfo_;
180     std::mutex mutex_;
181     static const int32_t DISABLE = 0;
182     static const int32_t ENABLE = 1;
183 };
184 } // namespace Telephony
185 } // namespace OHOS
186 #endif // BASE_PHONE_SERVICE_PROXY_H
187