• 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     int32_t HandleRrcStateChanged(int32_t status);
44     RegServiceState GetRegServiceState() const;
45 
46     enum class RilRegister {
47         REG_STATE_NOT_REG = 0,
48         REG_STATE_HOME_ONLY = 1,
49         REG_STATE_SEARCH = 2,
50         REG_STATE_NO_SERVICE = 3,
51         REG_STATE_INVALID = 4,
52         REG_STATE_ROAMING = 5,
53         REG_STATE_EMERGENCY_ONLY = 6
54     };
55     enum class ConnectServiceCell {
56         /** Connection status is unknown. */
57         CONNECTION_UNKNOWN = 0,
58         /** UE has connection to primary cell cell(3GPP 36.331).*/
59         CONNECTION_PRIMARY_CELL = 1,
60         /** UE has connectionto secondary cell cell(3GPP 36.331).*/
61         CONNECTION_SECONDARY_CELL = 2
62     };
63 
64 private:
65     RegServiceState ConvertRegFromRil(RilRegister code) const;
66     RadioTech ConvertTechFromRil(HRilRadioTech code) const;
67     void UpdateNrState();
68     void NotifyNrFrequencyChanged();
69     int32_t GetRrcConnectionState(int32_t &rrcState);
70     bool IsValidConfig(const std::string &config);
71     RadioTech GetTechnologyByNrConfig(RadioTech tech);
72     int32_t GetSystemPropertiesConfig(std::string &config);
73 
74 private:
75     std::shared_ptr<NetworkSearchState> networkSearchState_ = nullptr;
76     std::weak_ptr<NetworkSearchManager> networkSearchManager_;
77     /**
78      * Indicates that if E-UTRA-NR Dual Connectivity (EN-DC) is supported by the primary serving
79      * cell.
80      *
81      * Reference: 3GPP TS 36.331 V16.6.0 6.3.1 System information blocks.
82      */
83     bool endcSupport_ = false;
84     /**
85      * Indicates if the use of dual connectivity with NR is restricted.
86      * Reference: 3GPP TS 24.301 V17.4.0 section 9.9.3.12A.
87      */
88     bool dcNrRestricted_ = false;
89     /**
90      * Indicates if NR is supported by the selected PLMN.
91      * Reference: 3GPP TS 36.331 V16.6.0 section 6.3.1 PLMN-InfoList-r15.
92      *            3GPP TS 36.331 V16.6.0 section 6.2.2 SystemInformationBlockType1 message.
93      */
94     bool nrSupport_ = false;
95     FrequencyType freqType_ = FrequencyType::FREQ_TYPE_UNKNOWN;
96     bool isNrSecondaryCell_ = false;
97     bool isPhysicalLinkActive_ = false;
98     NrState nrState_ = NrState::NR_STATE_NOT_SUPPORT;
99     std::vector<PhysicalChannelConfig> channelConfigInfos_;
100     std::map<NrState, RadioTech> nrConfigMap_;
101 
102     int32_t slotId_ = 0;
103     bool isCsCapable_ = true;
104     std::string currentNrConfig_ = "";
105     std::string systemPropertiesConfig_ = "ConfigD";
106     RegServiceState regStatusResult_ = RegServiceState::REG_STATE_UNKNOWN;
107 };
108 } // namespace Telephony
109 } // namespace OHOS
110 #endif // NETWORK_SEARCH_INCLUDE_NETWORK_REGISTER_H
111