• 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 #ifndef NETWORK_SEARCH_INCLUDE_NETWORK_REGISTER_H
16 #define NETWORK_SEARCH_INCLUDE_NETWORK_REGISTER_H
17 #include <memory>
18 #include <string>
19 #include <vector>
20 #include <map>
21 #include "event_handler.h"
22 
23 #include "hril_network_parcel.h"
24 #include "network_search_state.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class NetworkRegister {
29 public:
30     NetworkRegister(std::shared_ptr<NetworkSearchState> networkSearchState,
31         std::weak_ptr<NetworkSearchManager> networkSearchManager, int32_t slotId);
32     virtual ~NetworkRegister() = default;
33     void InitNrConversionConfig();
34     void ProcessPsRegister(const AppExecFwk::InnerEvent::Pointer &event);
35     void ProcessCsRegister(const AppExecFwk::InnerEvent::Pointer &event);
36     void ProcessRestrictedState(const AppExecFwk::InnerEvent::Pointer &event) const;
37     void ProcessPsAttachStatus(const AppExecFwk::InnerEvent::Pointer &event) const;
38     void ProcessChannelConfigInfo(const AppExecFwk::InnerEvent::Pointer &event);
39     int32_t RevertLastTechnology();
40     int32_t NotifyStateChange();
41     void DcPhysicalLinkActiveUpdate(bool isActive);
42     void UpdateCfgTech();
43     void UpdateCellularCall(const RegServiceState &regStatus, const int32_t callType);
44     int32_t HandleRrcStateChanged(int32_t status);
45     RegServiceState GetRegServiceState() const;
46 
47     enum class RilRegister {
48         REG_STATE_NOT_REG = 0,
49         REG_STATE_HOME_ONLY = 1,
50         REG_STATE_SEARCH = 2,
51         REG_STATE_NO_SERVICE = 3,
52         REG_STATE_INVALID = 4,
53         REG_STATE_ROAMING = 5,
54         REG_STATE_EMERGENCY_ONLY = 6
55     };
56     enum class ConnectServiceCell {
57         /** Connection status is unknown. */
58         CONNECTION_UNKNOWN = 0,
59         /** UE has connection to primary cell cell(3GPP 36.331).*/
60         CONNECTION_PRIMARY_CELL = 1,
61         /** UE has connectionto secondary cell cell(3GPP 36.331).*/
62         CONNECTION_SECONDARY_CELL = 2
63     };
64 
65 private:
66     RegServiceState ConvertRegFromRil(RilRegister code) const;
67     RadioTech ConvertTechFromRil(HRilRadioTech code) const;
68     void UpdateNrState();
69     void NotifyNrFrequencyChanged();
70     int32_t GetRrcConnectionState(int32_t &rrcState);
71     bool IsValidConfig(const std::string &config);
72     RadioTech GetTechnologyByNrConfig(RadioTech tech);
73     int32_t GetSystemPropertiesConfig(std::string &config);
74     void UpdateNetworkSearchState(RegServiceState regStatus, RadioTech tech, RoamingType roam, DomainType type);
75 
76 private:
77     std::shared_ptr<NetworkSearchState> networkSearchState_ = nullptr;
78     std::weak_ptr<NetworkSearchManager> networkSearchManager_;
79     /**
80      * Indicates that if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving
81      * cell.
82      *
83      * Reference: 3GPP TS 36.331 V16.6.0 6.3.1 System information blocks.
84      */
85     bool endcSupport_ = false;
86     /**
87      * Indicates if the use of dual connectivity with NR is restricted.
88      * Reference: 3GPP TS 24.301 V17.4.0 section 9.9.3.12A.
89      */
90     bool dcNrRestricted_ = false;
91     /**
92      * Indicates if NR is supported by the selected PLMN.
93      * Reference: 3GPP TS 36.331 V16.6.0 section 6.3.1 PLMN-InfoList-r15.
94      *            3GPP TS 36.331 V16.6.0 section 6.2.2 SystemInformationBlockType1 message.
95      */
96     bool nrSupport_ = false;
97     FrequencyType freqType_ = FrequencyType::FREQ_TYPE_UNKNOWN;
98     bool isNrSecondaryCell_ = false;
99     bool isPhysicalLinkActive_ = false;
100     NrState nrState_ = NrState::NR_STATE_NOT_SUPPORT;
101     std::vector<PhysicalChannelConfig> channelConfigInfos_;
102     std::map<NrState, RadioTech> nrConfigMap_;
103 
104     int32_t slotId_ = 0;
105     bool isCsCapable_ = true;
106     std::string currentNrConfig_ = "";
107     std::string systemPropertiesConfig_ = "ConfigD";
108     RegServiceState regStatusResult_ = RegServiceState::REG_STATE_UNKNOWN;
109 };
110 } // namespace Telephony
111 } // namespace OHOS
112 #endif // NETWORK_SEARCH_INCLUDE_NETWORK_REGISTER_H
113