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 NETWORK_SEARCH_INCLUDE_RADIO_INFO_H
17 #define NETWORK_SEARCH_INCLUDE_RADIO_INFO_H
18 
19 #include <memory>
20 #include "event_handler.h"
21 #include "tel_ril_types.h"
22 #include "tel_ril_modem_parcel.h"
23 #include "message_parcel.h"
24 #include "network_state.h"
25 #include "telephony_types.h"
26 #include "telephony_ext_wrapper.h"
27 
28 namespace OHOS {
29 namespace Telephony {
30 class NetworkSearchManager;
31 class RadioInfo {
32 public:
33     RadioInfo(std::weak_ptr<NetworkSearchManager> networkSearchManager, int32_t slotId);
34     virtual ~RadioInfo() = default;
35     void ProcessGetRadioState(const AppExecFwk::InnerEvent::Pointer &event) const;
36     void ProcessSetRadioState(const AppExecFwk::InnerEvent::Pointer &event) const;
37     void RadioFirstPowerOn(std::shared_ptr<NetworkSearchManager> &nsm, ModemPowerState radioState) const;
38     void ProcessGetImei(const AppExecFwk::InnerEvent::Pointer &event) const;
39     void ProcessGetImeiSv(const AppExecFwk::InnerEvent::Pointer &event) const;
40     void ProcessGetMeid(const AppExecFwk::InnerEvent::Pointer &event) const;
41     void UpdatePhone(RadioTech csRadioTech, const RadioTech &psRadioTech);
42     void SetPhoneType(PhoneType phoneType);
43     PhoneType GetPhoneType() const;
44     void ProcessVoiceTechChange(const AppExecFwk::InnerEvent::Pointer &event);
45     void AirplaneModeChange();
46     int32_t ProcessGetBasebandVersion(const AppExecFwk::InnerEvent::Pointer &event) const;
47     int32_t ProcessSetNrOptionMode(const AppExecFwk::InnerEvent::Pointer &event) const;
48     int32_t ProcessGetNrOptionMode(const AppExecFwk::InnerEvent::Pointer &event) const;
49     int32_t ProcessGetRrcConnectionState(const AppExecFwk::InnerEvent::Pointer &event) const;
50 
51 private:
52     PhoneType RadioTechToPhoneType(RadioTech csRadioTech, const RadioTech &psRadioTech) const;
53     bool WriteRadioStateResponseInfo(
54         int64_t &index, MessageParcel &data, bool result, std::shared_ptr<RadioResponseInfo> &responseInfo) const;
55     bool WriteRadioStateObject(
56         int64_t &index, MessageParcel &data, bool result, std::unique_ptr<RadioStateInfo> &object) const;
57     void UpdateInfoOfSetRadioState(ModemPowerState &radioState, bool result, MessageParcel &data, int64_t index) const;
58     PhoneType phoneType_ = PhoneType::PHONE_TYPE_IS_NONE;
59     std::weak_ptr<NetworkSearchManager> networkSearchManager_;
60     int32_t slotId_ = 0;
61 };
62 } // namespace Telephony
63 } // namespace OHOS
64 #endif // NETWORK_SEARCH_INCLUDE_RADIO_INFO_H
65