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 I_NETWORK_SEARCH_H
17 #define I_NETWORK_SEARCH_H
18 
19 #include <vector>
20 
21 #include "cell_information.h"
22 #include "cell_location.h"
23 #include "event_handler.h"
24 #include "i_network_search_callback.h"
25 #include "ims_reg_info_callback.h"
26 #include "network_search_callback_base.h"
27 #include "network_search_result.h"
28 #include "network_state.h"
29 #include "nr_ssb_information.h"
30 #include "signal_information.h"
31 #include "tel_ril_types.h"
32 
33 namespace OHOS {
34 namespace Telephony {
35 class INetworkSearch {
36 public:
37     using HANDLE = const std::shared_ptr<AppExecFwk::EventHandler>;
38     using NSCALLBACK = const sptr<INetworkSearchCallback>;
39     virtual bool OnInit() = 0;
40     virtual int32_t InitTelExtraModule(int32_t slotId) = 0;
41     virtual int32_t GetPsRadioTech(int32_t slotId, int32_t &psRadioTech) = 0;
42     virtual int32_t GetCsRadioTech(int32_t slotId, int32_t &csRadioTech) = 0;
43     virtual std::u16string GetOperatorNumeric(int32_t slotId) = 0;
44     virtual std::string GetResidentNetworkNumeric(int32_t slotId) = 0;
45     virtual int32_t GetOperatorName(int32_t slotId, std::u16string &operatorName) = 0;
46     /**
47      * @brief Get network state
48      *
49      * @param slotId[in], sim slot id
50      * @param networkState[out], the network state of the SIM card
51      * @return int32_t TELEPHONY_SUCCESS on success, others on failure.
52      */
53     virtual int32_t GetNetworkStatus(int32_t slotId, sptr<NetworkState> &networkState) = 0;
54     virtual int32_t GetRadioState(int32_t slotId) = 0;
55     virtual int32_t GetRadioState(int32_t slotId, NSCALLBACK &callback) = 0;
56     /**
57      * Set radio state
58      * 27007-410_2001 8.2 Set phone functionality +CFUN
59      * 3GPP TS 27.007 V4.1.0 (2001-03)
60      */
61     virtual void SetRadioState(int32_t slotId, bool isOn, int32_t rst) = 0;
62     virtual int32_t SetRadioState(int32_t slotId, bool isOn, int32_t rst, NSCALLBACK &callback) = 0;
63     virtual int32_t GetSignalInfoList(int32_t slotId, std::vector<sptr<SignalInformation>> &signals) = 0;
64     virtual void RegisterCoreNotify(int32_t slotId, HANDLE &handler, int32_t what) = 0;
65     virtual void UnRegisterCoreNotify(int32_t slotId, HANDLE &handler, int32_t what) = 0;
66     virtual void RegisterCellularDataObject(const sptr<NetworkSearchCallBackBase> &callback) = 0;
67     virtual void UnRegisterCellularDataObject(const sptr<NetworkSearchCallBackBase> &callback) = 0;
68     virtual void RegisterCellularCallObject(const sptr<NetworkSearchCallBackBase> &callback) = 0;
69     virtual void UnRegisterCellularCallObject(const sptr<NetworkSearchCallBackBase> &callback) = 0;
70     virtual int32_t GetNetworkSearchInformation(int32_t slotId, NSCALLBACK &callback) = 0;
71     virtual int32_t GetNetworkSelectionMode(int32_t slotId, NSCALLBACK &callback) = 0;
72     virtual int32_t SetNetworkSelectionMode(int32_t slotId, int32_t selectMode,
73         const sptr<NetworkInformation> &networkInformation, bool resumeSelection, NSCALLBACK &callback) = 0;
74     virtual int32_t GetIsoCountryCodeForNetwork(int32_t slotId, std::u16string &countryCode) = 0;
75     virtual int32_t GetPreferredNetwork(int32_t slotId, NSCALLBACK &callback) = 0;
76     virtual int32_t SetPreferredNetwork(int32_t slotId, int32_t networkMode, NSCALLBACK &callback) = 0;
77     /**
78      * @brief Obtains the registration status of the packet switched (PS) domain.
79      *
80      * @param slotId[in], sim slot id
81      * @return Returns the registration status.
82      */
83     virtual int32_t GetPsRegState(int32_t slotId) = 0;
84     /**
85      * @brief Obtains the registration status of the circuit switched (CS) domain.
86      *
87      * @param slotId[in], sim slot id
88      * @return Returns the registration status.
89      */
90     virtual int32_t GetCsRegState(int32_t slotId) = 0;
91     /**
92      * @brief Obtains the roaming status of the packet switched (PS) domain.
93      *
94      * @param slotId[in], sim slot id
95      * @return Returns the roaming status.
96      */
97     virtual int32_t GetPsRoamingState(int32_t slotId) = 0;
98     virtual int32_t GetImei(int32_t slotId, std::u16string &imei) = 0;
99     virtual int32_t GetImeiSv(int32_t slotId, std::u16string &imeiSv) = 0;
100     virtual int32_t GetImsRegStatus(int32_t slotId, ImsServiceType imsSrvType, ImsRegInfo &info) = 0;
101     virtual int32_t GetCellInfoList(int32_t slotId, std::vector<sptr<CellInformation>> &cellInfo) = 0;
102     virtual int32_t SendUpdateCellLocationRequest(int32_t slotId) = 0;
103     /**
104      * @brief Obtains the location of the device.
105      *
106      * @param slotId[in], sim slot id
107      * @return Returns the current location of the device.
108      */
109     virtual sptr<CellLocation> GetCellLocation(int32_t slotId) = 0;
110     virtual int32_t GetMeid(int32_t slotId, std::u16string &meid) = 0;
111     virtual int32_t GetUniqueDeviceId(int32_t slotId, std::u16string &deviceId) = 0;
112     /**
113      * @brief Obtains the network status of the phone.
114      *
115      * @param slotId[in], sim slot id
116      * @return Returns the network status of the phone.
117      */
118     virtual PhoneType GetPhoneType(int32_t slotId) = 0;
119     virtual int32_t SetNrOptionMode(int32_t slotId, int32_t mode, NSCALLBACK &callback) = 0;
120     virtual int32_t GetNrOptionMode(int32_t slotId, NrMode &mode) = 0;
121     virtual int32_t GetNrOptionMode(int32_t slotId, NSCALLBACK &callback) = 0;
122 
123     /**
124      * @brief Obtains the frequency type.
125      *
126      * @param slotId[in], sim slot id
127      * @return Returns the frequency type.
128      */
129     virtual FrequencyType GetFrequencyType(int32_t slotId) = 0;
130     /**
131      * @brief Obtains the 5G New Radio (NR) status.
132      *
133      * @param slotId[in], sim slot id
134      * @return Returns the 5G New Radio (NR) status.
135      */
136     virtual NrState GetNrState(int32_t slotId) = 0;
137     virtual int32_t RegisterImsRegInfoCallback(int32_t slotId, ImsServiceType imsSrvType, const int32_t tokenId,
138         const sptr<ImsRegInfoCallback> &callback) = 0;
139     virtual int32_t UnregisterImsRegInfoCallback(
140         int32_t slotId, ImsServiceType imsSrvType, const int32_t tokenId) = 0;
141     virtual int32_t GetBasebandVersion(int32_t slotId, std::string &version) = 0;
142     /**
143      * @brief Init airplane mode.
144      *
145      * @param slotId[in], sim slot id
146      */
147     virtual void InitAirplaneMode(int32_t slotId) = 0;
148     /**
149      * @brief Get the airplane mode.
150      *
151      * @param airplaneMode[out], true if airplane is on, false if airplane is off
152      * @return int32_t TELEPHONY_SUCCESS on success, others on failure.
153      */
154     virtual int32_t GetAirplaneMode(bool &airplaneMode) = 0;
155     /**
156      * @brief Get the network capability.
157      *
158      * @param slotId[in], sim slot id
159      * @param networkCapabilityType[in], the device capability type
160      * @param networkCapabilityState[in], the device capability state
161      * @return int32_t TELEPHONY_SUCCESS on success, others on failure.
162      */
163     virtual int32_t GetNetworkCapability(
164         int32_t slotId, int32_t networkCapabilityType, int32_t &networkCapabilityState) = 0;
165     /**
166      * @brief Set the network capability.
167      *
168      * @param slotId[in], sim slot id
169      * @param networkCapabilityType[in], the device capability type
170      * @param networkCapabilityState[in], the device capability state
171      * @return int32_t TELEPHONY_SUCCESS on success, others on failure.
172      */
173     virtual int32_t SetNetworkCapability(
174         int32_t slotId, int32_t networkCapabilityType, int32_t networkCapabilityState) = 0;
175     /**
176      * @brief Update radio on, set airplane mode Off and radio state on
177      *
178      * @param slotId[in], sim slot id
179      * @return int32_t TELEPHONY_SUCCESS on success, others on failure.
180      */
181     virtual int32_t UpdateRadioOn(int32_t slotId) = 0;
182     virtual int32_t GetRrcConnectionState(int32_t slotId, int32_t &status) = 0;
183     virtual int32_t FactoryReset(int32_t slotId) = 0;
184     virtual int32_t GetNrSsbId(int32_t slotId, const std::shared_ptr<NrSsbInformation> &nrSsbInformation) = 0;
185 
186     /**
187      * @brief support Nr network or not
188      *
189      * @return true support
190      * @return false not support
191      */
192     virtual bool IsNrSupported(int32_t slotId) = 0;
193 
194     /**
195      * @brief support Satellite network or not
196      *
197      * @return true support
198      * @return false not support
199      */
200     virtual bool IsSatelliteEnabled() = 0;
201 
202     /**
203      * @brief Update physical link active status
204      *
205      * @param slotId[in], sim slot id
206      * @param isActive[in], physical link active or not
207      */
208     virtual void DcPhysicalLinkActiveUpdate(int32_t slotId, bool isActive) = 0;
209     virtual int32_t NotifyCallStatusToNetworkSearch(int32_t slotId, int32_t callStatus) = 0;
210     virtual int32_t HandleNotifyStateChangeWithDelay(int32_t slotId, bool isNeedDelay) = 0;
211     virtual int32_t IsGsm(int32_t slotId, bool &isGsm) = 0;
212     virtual int32_t IsCdma(int32_t slotId, bool &isCdma) = 0;
213     virtual int32_t StartRadioOnState(int32_t slotId) = 0;
214     virtual int32_t StartGetRilSignalIntensity(int32_t slotId) = 0;
215     virtual int32_t ProcessSignalIntensity(int32_t slotId, const struct Rssi &signalIntensity) = 0;
216 };
217 } // namespace Telephony
218 } // namespace OHOS
219 #endif // I_NETWORK_SEARCH_H
220