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 #include "cellular_call_config.h"
17
18 #include "telephony_types.h"
19
20 #include "cellular_call_data_struct.h"
21
22 namespace OHOS {
23 namespace Telephony {
24 std::map<int32_t, int32_t> CellularCallConfig::modeMap_;
25 std::map<int32_t, int32_t> CellularCallConfig::activeMap_;
26 std::map<int32_t, int32_t> CellularCallConfig::modeTempMap_;
27 std::map<int32_t, std::vector<EmergencyInfo>> CellularCallConfig::eccListMap_;
28
SetDomainPreferenceMode(int32_t slotId,int32_t mode)29 int32_t CellularCallConfig::SetDomainPreferenceMode(int32_t slotId, int32_t mode)
30 {
31 if (mode < DomainPreferenceMode::CS_VOICE_ONLY || mode > DomainPreferenceMode::IMS_PS_VOICE_ONLY) {
32 TELEPHONY_LOGE("SetDomainPreferenceMode return, mode out of range!");
33 return CALL_ERR_PARAMETER_OUT_OF_RANGE;
34 }
35 modeTempMap_[slotId] = mode;
36 return configRequest_.SetDomainPreferenceModeRequest(slotId, mode);
37 }
38
GetDomainPreferenceMode(int32_t slotId)39 int32_t CellularCallConfig::GetDomainPreferenceMode(int32_t slotId)
40 {
41 return configRequest_.GetDomainPreferenceModeRequest(slotId);
42 }
43
SetLteImsSwitchStatus(int32_t slotId,bool active)44 int32_t CellularCallConfig::SetLteImsSwitchStatus(int32_t slotId, bool active)
45 {
46 /*
47 * The Mobility_Management_IMS_Voice_Termination leaf indicates whether the UE mobility management performs
48 * additional procedures as specified in 3GPP TS 24.008 [17] and 3GPP TS 24.301 [15] to support
49 * terminating access domain selection by the network.
50 * - Format: bool
51 * - Access Types: Get, Replace
52 * - Values: 0, 1
53 * 0 – Mobility Management for IMS Voice Termination disabled.
54 * 1 – Mobility Management for IMS Voice Termination enabled.
55 */
56 return configRequest_.SetLteImsSwitchStatusRequest(slotId, active);
57 }
58
GetLteImsSwitchStatus(int32_t slotId)59 int32_t CellularCallConfig::GetLteImsSwitchStatus(int32_t slotId)
60 {
61 /*
62 * The Mobility_Management_IMS_Voice_Termination leaf indicates whether the UE mobility management performs
63 * additional procedures as specified in 3GPP TS 24.008 [17] and 3GPP TS 24.301 [15] to support
64 * terminating access domain selection by the network.
65 * - Format: bool
66 * - Access Types: Get, Replace
67 * - Values: 0, 1
68 * 0 – Mobility Management for IMS Voice Termination disabled.
69 * 1 – Mobility Management for IMS Voice Termination enabled.
70 */
71 return configRequest_.GetLteImsSwitchStatusRequest(slotId);
72 }
73
GetDomainPreferenceModeResponse(int32_t slotId,int32_t mode)74 void CellularCallConfig::GetDomainPreferenceModeResponse(int32_t slotId, int32_t mode)
75 {
76 modeMap_[slotId] = mode;
77 }
78
GetLteImsSwitchStatusResponse(int32_t slotId,int32_t active)79 void CellularCallConfig::GetLteImsSwitchStatusResponse(int32_t slotId, int32_t active)
80 {
81 activeMap_[slotId] = active;
82 }
83
GetPreferenceMode(int32_t slotId) const84 int32_t CellularCallConfig::GetPreferenceMode(int32_t slotId) const
85 {
86 return modeMap_[slotId];
87 }
88
GetSwitchStatus(int32_t slotId) const89 int32_t CellularCallConfig::GetSwitchStatus(int32_t slotId) const
90 {
91 return activeMap_[slotId];
92 }
93
SetImsConfig(ImsConfigItem item,const std::string & value)94 int32_t CellularCallConfig::SetImsConfig(ImsConfigItem item, const std::string &value)
95 {
96 return configRequest_.SetImsConfigRequest(item, value);
97 }
98
SetImsConfig(ImsConfigItem item,int32_t value)99 int32_t CellularCallConfig::SetImsConfig(ImsConfigItem item, int32_t value)
100 {
101 return configRequest_.SetImsConfigRequest(item, value);
102 }
103
GetImsConfig(ImsConfigItem item)104 int32_t CellularCallConfig::GetImsConfig(ImsConfigItem item)
105 {
106 return configRequest_.GetImsConfigRequest(item);
107 }
108
SetImsFeatureValue(FeatureType type,int32_t value)109 int32_t CellularCallConfig::SetImsFeatureValue(FeatureType type, int32_t value)
110 {
111 return configRequest_.SetImsFeatureValueRequest(type, value);
112 }
113
GetImsFeatureValue(FeatureType type)114 int32_t CellularCallConfig::GetImsFeatureValue(FeatureType type)
115 {
116 return configRequest_.GetImsFeatureValueRequest(type);
117 }
118
SetImsSwitchEnhanceMode(bool value)119 int32_t CellularCallConfig::SetImsSwitchEnhanceMode(bool value)
120 {
121 return configRequest_.SetImsSwitchEnhanceModeRequest(value);
122 }
123
GetImsSwitchEnhanceMode()124 int32_t CellularCallConfig::GetImsSwitchEnhanceMode()
125 {
126 return configRequest_.GetImsSwitchEnhanceModeRequest();
127 }
128
CtrlCamera(const std::u16string & cameraId,int32_t callingUid,int32_t callingPid)129 int32_t CellularCallConfig::CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid)
130 {
131 return configRequest_.CtrlCameraRequest(cameraId, callingUid, callingPid);
132 }
133
SetPreviewWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)134 int32_t CellularCallConfig::SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
135 {
136 return configRequest_.SetPreviewWindowRequest(x, y, z, width, height);
137 }
138
SetDisplayWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)139 int32_t CellularCallConfig::SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
140 {
141 return configRequest_.SetDisplayWindowRequest(x, y, z, width, height);
142 }
143
SetCameraZoom(float zoomRatio)144 int32_t CellularCallConfig::SetCameraZoom(float zoomRatio)
145 {
146 return configRequest_.SetCameraZoomRequest(zoomRatio);
147 }
148
SetPauseImage(const std::u16string & path)149 int32_t CellularCallConfig::SetPauseImage(const std::u16string &path)
150 {
151 return configRequest_.SetPauseImageRequest(path);
152 }
153
SetDeviceDirection(int32_t rotation)154 int32_t CellularCallConfig::SetDeviceDirection(int32_t rotation)
155 {
156 return configRequest_.SetDeviceDirectionRequest(rotation);
157 }
158
SetTempMode(int32_t slotId)159 void CellularCallConfig::SetTempMode(int32_t slotId)
160 {
161 modeMap_[slotId] = modeTempMap_[slotId];
162 }
163
InitModeActive()164 void CellularCallConfig::InitModeActive()
165 {
166 int32_t slotId = DEFAULT_SIM_SLOT_ID;
167 modeMap_[slotId] = DomainPreferenceMode::IMS_PS_VOICE_PREFERRED;
168 activeMap_[slotId] = true;
169 eccListMap_.clear();
170 }
171
SetMute(int32_t slotId,int32_t mute)172 int32_t CellularCallConfig::SetMute(int32_t slotId, int32_t mute)
173 {
174 return configRequest_.SetMuteRequest(slotId, mute);
175 }
176
GetMute(int32_t slotId)177 int32_t CellularCallConfig::GetMute(int32_t slotId)
178 {
179 return configRequest_.GetMuteRequest(slotId);
180 }
181
GetEmergencyCallList(int32_t slotId)182 int32_t CellularCallConfig::GetEmergencyCallList(int32_t slotId)
183 {
184 return configRequest_.GetEmergencyCallListRequest(slotId);
185 }
186
GetEmergencyCallListResponse(int32_t slotId,const EmergencyInfoList & eccList)187 void CellularCallConfig::GetEmergencyCallListResponse(int32_t slotId, const EmergencyInfoList &eccList)
188 {
189 eccListMap_[slotId] = eccList.calls;
190 }
191
GetEccCallList(int32_t slotId)192 std::vector<EmergencyInfo> CellularCallConfig::GetEccCallList(int32_t slotId)
193 {
194 return eccListMap_[slotId];
195 }
196 } // namespace Telephony
197 } // namespace OHOS
198