1d95e75fdSopenharmony_ci/* 2d95e75fdSopenharmony_ci * Copyright (C) 2021-2023 Huawei Device Co., Ltd. 3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License. 5d95e75fdSopenharmony_ci * You may obtain a copy of the License at 6d95e75fdSopenharmony_ci * 7d95e75fdSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8d95e75fdSopenharmony_ci * 9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and 13d95e75fdSopenharmony_ci * limitations under the License. 14d95e75fdSopenharmony_ci */ 15d95e75fdSopenharmony_ci 16d95e75fdSopenharmony_ci#include "ims_test.h" 17d95e75fdSopenharmony_ci 18d95e75fdSopenharmony_ci#define private public 19d95e75fdSopenharmony_ci#define protected public 20d95e75fdSopenharmony_ci#include "cellular_call_config.h" 21d95e75fdSopenharmony_ci#include "cellular_call_handler.h" 22d95e75fdSopenharmony_ci#include "cellular_call_proxy.h" 23d95e75fdSopenharmony_ci#include "cellular_call_register.h" 24d95e75fdSopenharmony_ci#include "cellular_call_service.h" 25d95e75fdSopenharmony_ci#include "tel_ril_call_parcel.h" 26d95e75fdSopenharmony_ci#include "ims_call_callback_proxy.h" 27d95e75fdSopenharmony_ci#include "ims_call_callback_stub.h" 28d95e75fdSopenharmony_ci#include "ims_call_client.h" 29d95e75fdSopenharmony_ci#include "ims_control.h" 30d95e75fdSopenharmony_ci#include "ims_error.h" 31d95e75fdSopenharmony_ci#include "securec.h" 32d95e75fdSopenharmony_ci 33d95e75fdSopenharmony_cinamespace OHOS { 34d95e75fdSopenharmony_cinamespace Telephony { 35d95e75fdSopenharmony_ciusing namespace testing::ext; 36d95e75fdSopenharmony_ciconst int32_t SIM1_SLOTID = 0; 37d95e75fdSopenharmony_ciconst std::string PHONE_NUMBER = "0000000"; 38d95e75fdSopenharmony_ciconst std::string PHONE_NUMBER_SECOND = "1111111"; 39d95e75fdSopenharmony_ciconst std::string PHONE_NUMBER_THIRD = "2222222"; 40d95e75fdSopenharmony_ciconst std::string PHONE_NUMBER_FOUR = "3333333"; 41d95e75fdSopenharmony_ciconst int32_t CELLULAR_CALL_SUCCESS = 0; 42d95e75fdSopenharmony_ciconst int32_t DEFAULT_INDEX = 1; 43d95e75fdSopenharmony_ci 44d95e75fdSopenharmony_civoid ImsTest::SetUpTestCase(void) 45d95e75fdSopenharmony_ci{ 46d95e75fdSopenharmony_ci // step 3: Set Up Test Case 47d95e75fdSopenharmony_ci std::cout << "---------- ImsCoreServiceClient start ------------" << std::endl; 48d95e75fdSopenharmony_ci DelayedSingleton<ImsCoreServiceClient>::GetInstance()->Init(); 49d95e75fdSopenharmony_ci} 50d95e75fdSopenharmony_ci 51d95e75fdSopenharmony_civoid ImsTest::TearDownTestCase(void) 52d95e75fdSopenharmony_ci{ 53d95e75fdSopenharmony_ci // step 3: Tear Down Test Case 54d95e75fdSopenharmony_ci} 55d95e75fdSopenharmony_ci 56d95e75fdSopenharmony_civoid ImsTest::SetUp(void) 57d95e75fdSopenharmony_ci{ 58d95e75fdSopenharmony_ci // step 3: input testcase setup step 59d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_DOMAIN_PREFERENCE_MODE)] = 60d95e75fdSopenharmony_ci &ImsTest::SetDomainPreferenceMode; 61d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_DOMAIN_PREFERENCE_MODE)] = 62d95e75fdSopenharmony_ci &ImsTest::GetDomainPreferenceMode; 63d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_SWITCH_STATUS)] = 64d95e75fdSopenharmony_ci &ImsTest::SetImsSwitchStatus; 65d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_IMS_SWITCH_STATUS)] = 66d95e75fdSopenharmony_ci &ImsTest::GetImsSwitchStatus; 67d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_STRING)] = 68d95e75fdSopenharmony_ci &ImsTest::SetImsConfigString; 69d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_INT)] = &ImsTest::SetImsConfigInt; 70d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_IMS_CONFIG)] = &ImsTest::GetImsConfig; 71d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_IMS_FEATURE)] = &ImsTest::SetImsFeatureValue; 72d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_IMS_FEATURE)] = &ImsTest::GetImsFeatureValue; 73d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::CTRL_CAMERA)] = &ImsTest::ControlCamera; 74d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_PREVIEW_WINDOW)] = &ImsTest::SetPreviewWindow; 75d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_DISPLAY_WINDOW)] = &ImsTest::SetDisplayWindow; 76d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_CAMERA_ZOOM)] = &ImsTest::SetCameraZoom; 77d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_PAUSE_IMAGE)] = &ImsTest::SetPausePicture; 78d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_DEVICE_DIRECTION)] = 79d95e75fdSopenharmony_ci &ImsTest::SetDeviceDirection; 80d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_REQUEST)] = 81d95e75fdSopenharmony_ci &ImsTest::SendUpdateCallMediaModeRequest; 82d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_RESPONSE)] = 83d95e75fdSopenharmony_ci &ImsTest::SendUpdateCallMediaModeResponse; 84d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::CANCEL_CALL_UPGRADE)] = 85d95e75fdSopenharmony_ci &ImsTest::CancelCallUpgrade; 86d95e75fdSopenharmony_ci requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::REQUEST_CAMERA_CAPABILITY)] = 87d95e75fdSopenharmony_ci &ImsTest::RequestCameraCapabilities; 88d95e75fdSopenharmony_ci} 89d95e75fdSopenharmony_ci 90d95e75fdSopenharmony_civoid ImsTest::TearDown(void) 91d95e75fdSopenharmony_ci{ 92d95e75fdSopenharmony_ci // step 3: input testcase teardown step 93d95e75fdSopenharmony_ci} 94d95e75fdSopenharmony_ci 95d95e75fdSopenharmony_ciint32_t ImsTest::SetDomainPreferenceMode(const sptr<CellularCallInterface> &telephonyService) const 96d95e75fdSopenharmony_ci{ 97d95e75fdSopenharmony_ci std::cout << "test SetDomainPreferenceMode entry." << std::endl; 98d95e75fdSopenharmony_ci std::cout << "please enter the need mode:(1 - 4)"; 99d95e75fdSopenharmony_ci int32_t mode; 100d95e75fdSopenharmony_ci std::cin >> mode; 101d95e75fdSopenharmony_ci int32_t slotId = 0; 102d95e75fdSopenharmony_ci std::cout << "please enter the slotId:(0 1)"; 103d95e75fdSopenharmony_ci std::cin >> slotId; 104d95e75fdSopenharmony_ci return telephonyService->SetDomainPreferenceMode(slotId, mode); 105d95e75fdSopenharmony_ci} 106d95e75fdSopenharmony_ci 107d95e75fdSopenharmony_ciint32_t ImsTest::GetDomainPreferenceMode(const sptr<CellularCallInterface> &telephonyService) const 108d95e75fdSopenharmony_ci{ 109d95e75fdSopenharmony_ci std::cout << "test GetDomainPreferenceMode entry." << std::endl; 110d95e75fdSopenharmony_ci int32_t slotId = 0; 111d95e75fdSopenharmony_ci std::cout << "please enter the slotId:(0 1)"; 112d95e75fdSopenharmony_ci std::cin >> slotId; 113d95e75fdSopenharmony_ci return telephonyService->GetDomainPreferenceMode(slotId); 114d95e75fdSopenharmony_ci} 115d95e75fdSopenharmony_ci 116d95e75fdSopenharmony_ciint32_t ImsTest::SetImsSwitchStatus(const sptr<CellularCallInterface> &telephonyService) const 117d95e75fdSopenharmony_ci{ 118d95e75fdSopenharmony_ci std::cout << "test SetImsSwitchStatus entry." << std::endl; 119d95e75fdSopenharmony_ci std::cout << "please enter the switch state:"; 120d95e75fdSopenharmony_ci bool active; 121d95e75fdSopenharmony_ci std::cin >> active; 122d95e75fdSopenharmony_ci int32_t slotId = 0; 123d95e75fdSopenharmony_ci std::cout << "please enter the slotId:(0 1)"; 124d95e75fdSopenharmony_ci std::cin >> slotId; 125d95e75fdSopenharmony_ci return telephonyService->SetImsSwitchStatus(slotId, active); 126d95e75fdSopenharmony_ci} 127d95e75fdSopenharmony_ci 128d95e75fdSopenharmony_ciint32_t ImsTest::GetImsSwitchStatus(const sptr<CellularCallInterface> &telephonyService) const 129d95e75fdSopenharmony_ci{ 130d95e75fdSopenharmony_ci std::cout << "test GetImsSwitchStatus entry." << std::endl; 131d95e75fdSopenharmony_ci int32_t slotId = 0; 132d95e75fdSopenharmony_ci std::cout << "please enter the slotId:(0 1)"; 133d95e75fdSopenharmony_ci std::cin >> slotId; 134d95e75fdSopenharmony_ci bool enabled; 135d95e75fdSopenharmony_ci return telephonyService->GetImsSwitchStatus(slotId, enabled); 136d95e75fdSopenharmony_ci} 137d95e75fdSopenharmony_ci 138d95e75fdSopenharmony_ciint32_t ImsTest::SetImsConfigString(const sptr<CellularCallInterface> &telephonyService) const 139d95e75fdSopenharmony_ci{ 140d95e75fdSopenharmony_ci std::cout << "test SetImsConfigString entry." << std::endl; 141d95e75fdSopenharmony_ci std::cout << "please enter the item id:"; 142d95e75fdSopenharmony_ci int32_t item = 0; 143d95e75fdSopenharmony_ci std::cin >> item; 144d95e75fdSopenharmony_ci std::cout << "please enter the item value:"; 145d95e75fdSopenharmony_ci std::string value; 146d95e75fdSopenharmony_ci std::cin >> value; 147d95e75fdSopenharmony_ci int32_t slotId = 0; 148d95e75fdSopenharmony_ci return telephonyService->SetImsConfig(slotId, static_cast<ImsConfigItem>(item), value); 149d95e75fdSopenharmony_ci} 150d95e75fdSopenharmony_ci 151d95e75fdSopenharmony_ciint32_t ImsTest::SetImsConfigInt(const sptr<CellularCallInterface> &telephonyService) const 152d95e75fdSopenharmony_ci{ 153d95e75fdSopenharmony_ci std::cout << "test SetImsConfigInt entry." << std::endl; 154d95e75fdSopenharmony_ci std::cout << "please enter the item id:"; 155d95e75fdSopenharmony_ci int32_t item = 0; 156d95e75fdSopenharmony_ci std::cin >> item; 157d95e75fdSopenharmony_ci std::cout << "please enter the item value:"; 158d95e75fdSopenharmony_ci int32_t value = 0; 159d95e75fdSopenharmony_ci std::cin >> value; 160d95e75fdSopenharmony_ci int32_t slotId = 0; 161d95e75fdSopenharmony_ci return telephonyService->SetImsConfig(slotId, static_cast<ImsConfigItem>(item), value); 162d95e75fdSopenharmony_ci} 163d95e75fdSopenharmony_ci 164d95e75fdSopenharmony_ciint32_t ImsTest::GetImsConfig(const sptr<CellularCallInterface> &telephonyService) const 165d95e75fdSopenharmony_ci{ 166d95e75fdSopenharmony_ci std::cout << "test GetImsConfig entry." << std::endl; 167d95e75fdSopenharmony_ci std::cout << "please enter the item id:"; 168d95e75fdSopenharmony_ci int32_t item = 0; 169d95e75fdSopenharmony_ci std::cin >> item; 170d95e75fdSopenharmony_ci int32_t slotId = 0; 171d95e75fdSopenharmony_ci return telephonyService->GetImsConfig(slotId, static_cast<ImsConfigItem>(item)); 172d95e75fdSopenharmony_ci} 173d95e75fdSopenharmony_ci 174d95e75fdSopenharmony_ciint32_t ImsTest::SetImsFeatureValue(const sptr<CellularCallInterface> &telephonyService) const 175d95e75fdSopenharmony_ci{ 176d95e75fdSopenharmony_ci std::cout << "test SetImsFeatureValue entry." << std::endl; 177d95e75fdSopenharmony_ci std::cout << "please enter the feature type:"; 178d95e75fdSopenharmony_ci int32_t type = 0; 179d95e75fdSopenharmony_ci std::cin >> type; 180d95e75fdSopenharmony_ci std::cout << "please enter the feature value:"; 181d95e75fdSopenharmony_ci int32_t value = 0; 182d95e75fdSopenharmony_ci std::cin >> value; 183d95e75fdSopenharmony_ci int32_t slotId = 0; 184d95e75fdSopenharmony_ci return telephonyService->SetImsFeatureValue(slotId, static_cast<FeatureType>(type), value); 185d95e75fdSopenharmony_ci} 186d95e75fdSopenharmony_ci 187d95e75fdSopenharmony_ciint32_t ImsTest::GetImsFeatureValue(const sptr<CellularCallInterface> &telephonyService) const 188d95e75fdSopenharmony_ci{ 189d95e75fdSopenharmony_ci std::cout << "test GetImsFeatureValue entry." << std::endl; 190d95e75fdSopenharmony_ci std::cout << "please enter the feature type:"; 191d95e75fdSopenharmony_ci int32_t type = 0; 192d95e75fdSopenharmony_ci std::cin >> type; 193d95e75fdSopenharmony_ci int32_t slotId = 0; 194d95e75fdSopenharmony_ci return telephonyService->GetImsFeatureValue(slotId, static_cast<FeatureType>(type)); 195d95e75fdSopenharmony_ci} 196d95e75fdSopenharmony_ci 197d95e75fdSopenharmony_ciint32_t ImsTest::ControlCamera(const sptr<CellularCallInterface> &telephonyService) const 198d95e75fdSopenharmony_ci{ 199d95e75fdSopenharmony_ci std::cout << "test ControlCamera entry." << std::endl; 200d95e75fdSopenharmony_ci int32_t slotId = SIM1_SLOTID; 201d95e75fdSopenharmony_ci int32_t callIndex = DEFAULT_INDEX; 202d95e75fdSopenharmony_ci std::string cameraId = "cameraId"; 203d95e75fdSopenharmony_ci return telephonyService->ControlCamera(slotId, callIndex, cameraId); 204d95e75fdSopenharmony_ci} 205d95e75fdSopenharmony_ci 206d95e75fdSopenharmony_ciint32_t ImsTest::SetPreviewWindow(const sptr<CellularCallInterface> &telephonyService) const 207d95e75fdSopenharmony_ci{ 208d95e75fdSopenharmony_ci std::cout << "test SetPreviewWindow entry." << std::endl; 209d95e75fdSopenharmony_ci int32_t slotId = SIM1_SLOTID; 210d95e75fdSopenharmony_ci int32_t callIndex = DEFAULT_INDEX; 211d95e75fdSopenharmony_ci std::string surfaceId = "123"; 212d95e75fdSopenharmony_ci std::string subSurfaceId = surfaceId.substr(0, 1); 213d95e75fdSopenharmony_ci uint64_t tmpSurfaceId = std::stoull(subSurfaceId); 214d95e75fdSopenharmony_ci auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId); 215d95e75fdSopenharmony_ci if (surface == nullptr) { 216d95e75fdSopenharmony_ci surfaceId = ""; 217d95e75fdSopenharmony_ci } 218d95e75fdSopenharmony_ci return telephonyService->SetPreviewWindow(slotId, callIndex, subSurfaceId, surface); 219d95e75fdSopenharmony_ci} 220d95e75fdSopenharmony_ci 221d95e75fdSopenharmony_ciint32_t ImsTest::SetDisplayWindow(const sptr<CellularCallInterface> &telephonyService) const 222d95e75fdSopenharmony_ci{ 223d95e75fdSopenharmony_ci std::cout << "test SetDisplayWindow entry." << std::endl; 224d95e75fdSopenharmony_ci int32_t slotId = SIM1_SLOTID; 225d95e75fdSopenharmony_ci int32_t callIndex = DEFAULT_INDEX; 226d95e75fdSopenharmony_ci std::string surfaceId = "123"; 227d95e75fdSopenharmony_ci std::string subSurfaceId = surfaceId.substr(0, 1); 228d95e75fdSopenharmony_ci uint64_t tmpSurfaceId = std::stoull(subSurfaceId); 229d95e75fdSopenharmony_ci auto surface = SurfaceUtils::GetInstance()->GetSurface(tmpSurfaceId); 230d95e75fdSopenharmony_ci if (surface == nullptr) { 231d95e75fdSopenharmony_ci surfaceId = ""; 232d95e75fdSopenharmony_ci } 233d95e75fdSopenharmony_ci return telephonyService->SetDisplayWindow(slotId, callIndex, subSurfaceId, surface); 234d95e75fdSopenharmony_ci} 235d95e75fdSopenharmony_ci 236d95e75fdSopenharmony_ciint32_t ImsTest::SetCameraZoom(const sptr<CellularCallInterface> &telephonyService) const 237d95e75fdSopenharmony_ci{ 238d95e75fdSopenharmony_ci std::cout << "test SetCameraZoom entry." << std::endl; 239d95e75fdSopenharmony_ci float zoomRatio = 1.0; 240d95e75fdSopenharmony_ci return telephonyService->SetCameraZoom(zoomRatio); 241d95e75fdSopenharmony_ci} 242d95e75fdSopenharmony_ci 243d95e75fdSopenharmony_ciint32_t ImsTest::SetPausePicture(const sptr<CellularCallInterface> &telephonyService) const 244d95e75fdSopenharmony_ci{ 245d95e75fdSopenharmony_ci std::cout << "test SetPausePicture entry." << std::endl; 246d95e75fdSopenharmony_ci int32_t slotId = SIM1_SLOTID; 247d95e75fdSopenharmony_ci int32_t callIndex = DEFAULT_INDEX; 248d95e75fdSopenharmony_ci std::string path = "path"; 249d95e75fdSopenharmony_ci return telephonyService->SetPausePicture(slotId, callIndex, path); 250d95e75fdSopenharmony_ci} 251d95e75fdSopenharmony_ci 252d95e75fdSopenharmony_ciint32_t ImsTest::SetDeviceDirection(const sptr<CellularCallInterface> &telephonyService) const 253d95e75fdSopenharmony_ci{ 254d95e75fdSopenharmony_ci std::cout << "test SetDeviceDirection entry." << std::endl; 255d95e75fdSopenharmony_ci int32_t slotId = SIM1_SLOTID; 256d95e75fdSopenharmony_ci int32_t callIndex = DEFAULT_INDEX; 257d95e75fdSopenharmony_ci int32_t rotation = 0; 258d95e75fdSopenharmony_ci return telephonyService->SetDeviceDirection(slotId, callIndex, rotation); 259d95e75fdSopenharmony_ci} 260d95e75fdSopenharmony_ci 261d95e75fdSopenharmony_ciint32_t ImsTest::SendUpdateCallMediaModeRequest(const sptr<CellularCallInterface> &telephonyService) const 262d95e75fdSopenharmony_ci{ 263d95e75fdSopenharmony_ci std::cout << "test SendUpdateCallMediaModeRequest entry." << std::endl; 264d95e75fdSopenharmony_ci CellularCallInfo callInfo; 265d95e75fdSopenharmony_ci callInfo.accountId = SIM1_SLOTID; 266d95e75fdSopenharmony_ci callInfo.slotId = SIM1_SLOTID; 267d95e75fdSopenharmony_ci callInfo.index = DEFAULT_INDEX; 268d95e75fdSopenharmony_ci callInfo.callType = CallType::TYPE_IMS; 269d95e75fdSopenharmony_ci callInfo.videoState = 0; // 0 means audio 270d95e75fdSopenharmony_ci if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) { 271d95e75fdSopenharmony_ci return TELEPHONY_ERR_MEMSET_FAIL; 272d95e75fdSopenharmony_ci } 273d95e75fdSopenharmony_ci if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, PHONE_NUMBER.c_str(), PHONE_NUMBER.length()) != EOK) { 274d95e75fdSopenharmony_ci return TELEPHONY_ERR_MEMCPY_FAIL; 275d95e75fdSopenharmony_ci } 276d95e75fdSopenharmony_ci std::cout << "please enter the ims call mode:"; 277d95e75fdSopenharmony_ci std::cout << "0:audio_only, 1:send_only, 2:receive_only, 3:send_receive, 4:video_paused"; 278d95e75fdSopenharmony_ci ImsCallMode callMode = ImsCallMode::CALL_MODE_AUDIO_ONLY; 279d95e75fdSopenharmony_ci int32_t input = 0; 280d95e75fdSopenharmony_ci std::cin >> input; 281d95e75fdSopenharmony_ci callMode = static_cast<ImsCallMode>(input); 282d95e75fdSopenharmony_ci return telephonyService->SendUpdateCallMediaModeRequest(callInfo, callMode); 283d95e75fdSopenharmony_ci} 284d95e75fdSopenharmony_ci 285d95e75fdSopenharmony_ciint32_t ImsTest::SendUpdateCallMediaModeResponse(const sptr<CellularCallInterface> &telephonyService) const 286d95e75fdSopenharmony_ci{ 287d95e75fdSopenharmony_ci std::cout << "test SendUpdateCallMediaModeResponse entry." << std::endl; 288d95e75fdSopenharmony_ci CellularCallInfo callInfo; 289d95e75fdSopenharmony_ci callInfo.accountId = SIM1_SLOTID; 290d95e75fdSopenharmony_ci callInfo.slotId = SIM1_SLOTID; 291d95e75fdSopenharmony_ci callInfo.index = DEFAULT_INDEX; 292d95e75fdSopenharmony_ci callInfo.callType = CallType::TYPE_IMS; 293d95e75fdSopenharmony_ci callInfo.videoState = 0; // 0 means audio 294d95e75fdSopenharmony_ci if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) { 295d95e75fdSopenharmony_ci return TELEPHONY_ERR_MEMSET_FAIL; 296d95e75fdSopenharmony_ci } 297d95e75fdSopenharmony_ci if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, PHONE_NUMBER.c_str(), PHONE_NUMBER.length()) != EOK) { 298d95e75fdSopenharmony_ci return TELEPHONY_ERR_MEMCPY_FAIL; 299d95e75fdSopenharmony_ci } 300d95e75fdSopenharmony_ci std::cout << "please enter the ims call mode:"; 301d95e75fdSopenharmony_ci std::cout << "0:audio_only, 1:send_only, 2:receive_only, 3:send_receive, 4:video_paused"; 302d95e75fdSopenharmony_ci ImsCallMode callMode = ImsCallMode::CALL_MODE_AUDIO_ONLY; 303d95e75fdSopenharmony_ci int32_t input = 0; 304d95e75fdSopenharmony_ci std::cin >> input; 305d95e75fdSopenharmony_ci callMode = static_cast<ImsCallMode>(input); 306d95e75fdSopenharmony_ci return telephonyService->SendUpdateCallMediaModeResponse(callInfo, callMode); 307d95e75fdSopenharmony_ci} 308d95e75fdSopenharmony_ci 309d95e75fdSopenharmony_ciint32_t ImsTest::CancelCallUpgrade(const sptr<CellularCallInterface> &telephonyService) const 310d95e75fdSopenharmony_ci{ 311d95e75fdSopenharmony_ci std::cout << "test CancelCallUpgrade entry." << std::endl; 312d95e75fdSopenharmony_ci int32_t slotId = SIM1_SLOTID; 313d95e75fdSopenharmony_ci int32_t callIndex = DEFAULT_INDEX; 314d95e75fdSopenharmony_ci return telephonyService->CancelCallUpgrade(slotId, callIndex); 315d95e75fdSopenharmony_ci} 316d95e75fdSopenharmony_ci 317d95e75fdSopenharmony_ciint32_t ImsTest::RequestCameraCapabilities(const sptr<CellularCallInterface> &telephonyService) const 318d95e75fdSopenharmony_ci{ 319d95e75fdSopenharmony_ci std::cout << "test RequestCameraCapabilities entry." << std::endl; 320d95e75fdSopenharmony_ci int32_t slotId = SIM1_SLOTID; 321d95e75fdSopenharmony_ci int32_t callIndex = DEFAULT_INDEX; 322d95e75fdSopenharmony_ci return telephonyService->RequestCameraCapabilities(slotId, callIndex); 323d95e75fdSopenharmony_ci} 324d95e75fdSopenharmony_ci 325d95e75fdSopenharmony_ciint32_t ImsTest::InputNumForInterface(const sptr<CellularCallInterface> &telephonyService) const 326d95e75fdSopenharmony_ci{ 327d95e75fdSopenharmony_ci int32_t ret = -1; 328d95e75fdSopenharmony_ci bool loopFlag = true; 329d95e75fdSopenharmony_ci int32_t inputNumber = 0; 330d95e75fdSopenharmony_ci int32_t returnNum = 1000; // end loop variable value 331d95e75fdSopenharmony_ci while (loopFlag) { 332d95e75fdSopenharmony_ci std::cout << "\n**********Unit Test Start**********\n" 333d95e75fdSopenharmony_ci "Usage: please input a cmd num:\n" 334d95e75fdSopenharmony_ci "300:SetCallPreferenceMode\n" 335d95e75fdSopenharmony_ci "301:GetCallPreferenceMode\n" 336d95e75fdSopenharmony_ci "302:SetImsSwitchStatus\n" 337d95e75fdSopenharmony_ci "303:GetImsSwitchStatus\n" 338d95e75fdSopenharmony_ci "304:SetImsConfigString\n" 339d95e75fdSopenharmony_ci "305:SetImsConfigInt\n" 340d95e75fdSopenharmony_ci "306:GetImsConfig\n" 341d95e75fdSopenharmony_ci "307:SetImsFeatureValue\n" 342d95e75fdSopenharmony_ci "308:GetImsFeatureValue\n" 343d95e75fdSopenharmony_ci "400:ControlCamera\n" 344d95e75fdSopenharmony_ci "401:SetPreviewWindow\n" 345d95e75fdSopenharmony_ci "402:SetDisplayWindow\n" 346d95e75fdSopenharmony_ci "403:SetCameraZoom\n" 347d95e75fdSopenharmony_ci "404:SetPausePicture\n" 348d95e75fdSopenharmony_ci "405:SetDeviceDirection\n" 349d95e75fdSopenharmony_ci "406:SendUpdateCallMediaModeRequest\n" 350d95e75fdSopenharmony_ci "407:SendUpdateCallMediaModeResponse\n" 351d95e75fdSopenharmony_ci "408:CancelCallUpgrade\n" 352d95e75fdSopenharmony_ci "409:RequestCameraCapabilities\n" 353d95e75fdSopenharmony_ci "1000:Exit\n" 354d95e75fdSopenharmony_ci "***********************************\n" 355d95e75fdSopenharmony_ci "Your choice: "; 356d95e75fdSopenharmony_ci std::cin >> inputNumber; 357d95e75fdSopenharmony_ci if (inputNumber == returnNum) { 358d95e75fdSopenharmony_ci std::cout << "exiting...\n"; 359d95e75fdSopenharmony_ci break; 360d95e75fdSopenharmony_ci } 361d95e75fdSopenharmony_ci auto itFunction = requestFuncMap_.find(inputNumber); 362d95e75fdSopenharmony_ci if (itFunction != requestFuncMap_.end()) { 363d95e75fdSopenharmony_ci auto requestFunction = itFunction->second; 364d95e75fdSopenharmony_ci if (requestFunction != nullptr) { 365d95e75fdSopenharmony_ci ret = (this->*requestFunction)(telephonyService); 366d95e75fdSopenharmony_ci } 367d95e75fdSopenharmony_ci } 368d95e75fdSopenharmony_ci if (ret != CELLULAR_CALL_SUCCESS) { 369d95e75fdSopenharmony_ci std::cout << "this execution did not return a successful value, please check.\n"; 370d95e75fdSopenharmony_ci return ret; 371d95e75fdSopenharmony_ci } 372d95e75fdSopenharmony_ci } 373d95e75fdSopenharmony_ci return CELLULAR_CALL_SUCCESS; 374d95e75fdSopenharmony_ci} 375d95e75fdSopenharmony_ci} // namespace Telephony 376d95e75fdSopenharmony_ci} // namespace OHOS 377