rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* Copyright Statement: |
| 2 | * |
| 3 | * This software/firmware and related documentation ("MediaTek Software") are |
| 4 | * protected under relevant copyright laws. The information contained herein |
| 5 | * is confidential and proprietary to MediaTek Inc. and/or its licensors. |
| 6 | * Without the prior written permission of MediaTek inc. and/or its licensors, |
| 7 | * any reproduction, modification, use or disclosure of MediaTek Software, |
| 8 | * and information contained herein, in whole or in part, shall be strictly prohibited. |
| 9 | * |
| 10 | * MediaTek Inc. (C) 2016. All rights reserved. |
| 11 | * |
| 12 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 13 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 14 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON |
| 15 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 18 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 19 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 20 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH |
| 21 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES |
| 22 | * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES |
| 23 | * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK |
| 24 | * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| 25 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND |
| 26 | * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 27 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 28 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO |
| 29 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 30 | * |
| 31 | * The following software/firmware and/or related documentation ("MediaTek Software") |
| 32 | * have been modified by MediaTek Inc. All revisions are subject to any receiver's |
| 33 | * applicable license agreements with MediaTek Inc. |
| 34 | */ |
| 35 | |
| 36 | #include "rfdesense/RfDesenseTxTest.h" |
| 37 | |
| 38 | #include <memory> |
| 39 | #include <list> |
| 40 | #include <regex> |
| 41 | #include <cmath> |
| 42 | #include <string> |
| 43 | #include <cstdarg> |
| 44 | #include <cstring> |
| 45 | |
| 46 | #include <vendor-ril/telephony/ril.h> |
| 47 | |
| 48 | #include "common.h" |
| 49 | #include "em.h" |
| 50 | #include "rfdesense/RfDesenseTxTestCdma.h" |
| 51 | #include "rfdesense/RfDesenseTxTestGsm.h" |
| 52 | #include "rfdesense/RfDesenseTxTestLte.h" |
| 53 | #include "rfdesense/RfDesenseTxTestTd.h" |
| 54 | #include "util/log_extra.h" |
| 55 | #include "util/utils.h" |
| 56 | |
| 57 | #undef LOG_TAG |
| 58 | #define LOG_TAG "EM_RfDesenseTxTest" |
| 59 | |
| 60 | RfDesenseTxTest* RfDesenseTxTest::m_instance = NULL; |
| 61 | std::mutex RfDesenseTxTest::mMutex; |
| 62 | |
| 63 | const int RfDesenseTxTest::STATE_NONE = 0; |
| 64 | const int RfDesenseTxTest::STATE_STARTED = 1; |
| 65 | const int RfDesenseTxTest::STATE_STOPPED = 2; |
| 66 | |
| 67 | const int RfDesenseTxTest::MSG_START_TX = 1; |
| 68 | const int RfDesenseTxTest::MSG_NEXT_RAT = 4; |
| 69 | const int RfDesenseTxTest::MSG_READ_POWER = 10; |
| 70 | const int RfDesenseTxTest::MSG_EWMPOLICY_TDSCDMA = 12; |
| 71 | const int RfDesenseTxTest::MSG_EWMPOLICY_WCDMA = 13; |
| 72 | const int RfDesenseTxTest::MSG_ECSRA = 14; |
| 73 | const int RfDesenseTxTest::MSG_SWITCH_RAT_DONE = 15; |
| 74 | |
| 75 | int RfDesenseTxTest::mState = STATE_NONE; |
| 76 | |
| 77 | long RfDesenseTxTest::mTestDuration = 10; |
| 78 | long RfDesenseTxTest::mTestCount = 1; |
| 79 | long RfDesenseTxTest::mTestDurationSended = 0; |
| 80 | long RfDesenseTxTest::mTestCountSended = 0; |
| 81 | long RfDesenseTxTest::mCheckLimit = 2; |
| 82 | long RfDesenseTxTest::mReadbackInterval = 5; |
| 83 | |
| 84 | const std::string RfDesenseTxTest::KEY_GSM_ATCMD = "gsm_at_cmd"; |
| 85 | const std::string RfDesenseTxTest::KEY_TDSCDMA_ATCMD = "tdscdma_at_cmd"; |
| 86 | const std::string RfDesenseTxTest::KEY_WCDMA_ATCMD = "wcdma_at_cmd"; |
| 87 | const std::string RfDesenseTxTest::KEY_LTE_FDD_ATCMD = "lte_fdd_at_cmd"; |
| 88 | const std::string RfDesenseTxTest::KEY_LTE_TDD_ATCMD = "lte_tdd_at_cmd"; |
| 89 | const std::string RfDesenseTxTest::KEY_CDMA_1X_ATCMD = "cdma_at_cmd"; |
| 90 | const std::string RfDesenseTxTest::KEY_CDMA_EVDO_ATCMD = "cdma_evdo_at_cmd"; |
| 91 | const std::string RfDesenseTxTest::KEY_TEST_DURATION = "test_duration"; |
| 92 | const std::string RfDesenseTxTest::KEY_TEST_COUNT = "test_count"; |
| 93 | const std::string RfDesenseTxTest::KEY_CHECK_LIMIT = "check_limit"; |
| 94 | const std::string RfDesenseTxTest::KEY_READBACK_INTREVAL = "readback_interval"; |
| 95 | |
| 96 | const std::string RfDesenseTxTest::DEFAULT_GSM_ATCMD = |
| 97 | "AT+ERFTX=2,1,190,4100,128,0,5,0"; |
| 98 | const std::string RfDesenseTxTest::DEFAULT_TDSCDMA_ATCMD = "AT+ERFTX=0,0,1,10087,24"; |
| 99 | const std::string RfDesenseTxTest::DEFAULT_WCDMA_ATCMD = "AT+ERFTX=0,0,1,9750,23"; |
| 100 | const std::string RfDesenseTxTest::DEFAULT_LTE_FDD_ATCMD = |
| 101 | "AT+ERFTX=6,0,1,3,3,17475,1,0,0,0,1,0,23"; |
| 102 | const std::string RfDesenseTxTest::DEFAULT_LTE_TDD_ATCMD = |
| 103 | "AT+ERFTX=6,0,1,38,3,25950,0,0,0,0,1,0,23"; |
| 104 | const std::string RfDesenseTxTest::DEFAULT_CDMA_EVDO_ATCMD = "AT+ERFTX=13,4,384,0,83"; |
| 105 | const std::string RfDesenseTxTest::DEFAULT_CDMA_1X_ATCMD = "AT+ECRFTX=1,384,0,83,0"; |
| 106 | |
| 107 | const std::string RfDesenseTxTest::DEFAULT_CDMA_EVDO_ATCMD_93before = |
| 108 | "AT+ERFTX=1,384,0,83,1"; |
| 109 | |
| 110 | const std::vector<std::string> RfDesenseTxTest::mRatName = { "GSM", "TDSCDMA", "WCDMA", |
| 111 | "LTE(FDD)", "LTE(TDD)", "CDMA(EVDO)", "CDMA(1X)" }; |
| 112 | std::vector<std::string> RfDesenseTxTest::mRatCmdStart = { DEFAULT_GSM_ATCMD, |
| 113 | DEFAULT_TDSCDMA_ATCMD, DEFAULT_WCDMA_ATCMD, DEFAULT_LTE_FDD_ATCMD, |
| 114 | DEFAULT_LTE_TDD_ATCMD, DEFAULT_CDMA_EVDO_ATCMD, |
| 115 | DEFAULT_CDMA_1X_ATCMD }; |
| 116 | |
| 117 | std::vector<std::string> RfDesenseTxTest::mRatCmdStop = { "AT+ERFTX=2,0", |
| 118 | "AT+ERFTX=0,1", "AT+ERFTX=0,1", "AT+ERFTX=6,0,0", "AT+ERFTX=6,0,0", |
| 119 | "AT+ERFTX=13,5", "AT+ECRFTX=0" }; |
| 120 | |
| 121 | std::vector<std::string> RfDesenseTxTest::mRatCmdSwitch = { "AT+ERAT=0", "AT+ERAT=1", |
| 122 | "AT+ERAT=1", "AT+ERAT=6,4", "AT+ERAT=6,4", "AT+ERAT=7,64", |
| 123 | "AT+ERAT=7,32" }; |
| 124 | |
| 125 | std::vector<std::string> RfDesenseTxTest::mRatCmdPowerRead = { "", "AT+ERFTX=0,3", |
| 126 | "AT+ERFTX=0,3", "AT+ERFTX=6,1", "AT+ERFTX=6,1", "AT+ERFTX=13,3", |
| 127 | "AT+ERFTX=13,3" }; |
| 128 | std::vector<std::string> RfDesenseTxTest::mRatBand = { "19", "1", "1", "3", "38", "0", "0" }; |
| 129 | std::vector<std::string> RfDesenseTxTest::mRatPowerSet = { "19", "10", "24", "23", "23", "23", "23" }; |
| 130 | std::vector<bool> RfDesenseTxTest::mRatCheck = {false, false,false,false,false,false,false}; |
| 131 | std::vector<bool> RfDesenseTxTest::mSendState = {false, false,false,false,false,false,false}; |
| 132 | std::string RfDesenseTxTest::str_msg = ""; |
| 133 | bool RfDesenseTxTest::trm_flag = false; |
| 134 | int RfDesenseTxTest::phone_id = 0; |
| 135 | |
| 136 | void RfDesenseTxTest::rf_send_at_cmd(std::string cmd, int flag){ |
| 137 | mCurrentFlag = flag; |
| 138 | emSendATCommand(cmd.c_str(),phone_id); |
| 139 | } |
| 140 | |
| 141 | //create thread to send command |
| 142 | void RfDesenseTxTest::emRfDesenseThread(int id) { |
| 143 | mState = STATE_STARTED; |
| 144 | int operatorid = id; |
| 145 | LOG_D(LOG_TAG, "emRfDesenseThread: operatorid(%d)", operatorid); |
| 146 | switch (operatorid) { |
| 147 | case 0:{ |
| 148 | if (trm_flag) { |
| 149 | LOG_D(LOG_TAG, "wait modem reset done"); |
| 150 | std::this_thread::sleep_for(std::chrono::milliseconds(1000*5)); |
| 151 | trm_flag = false; |
| 152 | } |
| 153 | if(isRadioOn((RIL_SOCKET_ID)phone_id)) { |
| 154 | LOG_D(LOG_TAG, "radio already on"); |
| 155 | mIsModemEnabled = false; |
| 156 | emRadioStateOn(); |
| 157 | } else { |
| 158 | while(!isRadioOn((RIL_SOCKET_ID)phone_id)) { |
| 159 | LOG_D(LOG_TAG, "radio isn't on"); |
| 160 | std::this_thread::sleep_for(std::chrono::milliseconds(200)); |
| 161 | } |
| 162 | //turnOnRf(); |
| 163 | LOG_D(LOG_TAG, "radio on again"); |
| 164 | registerRadioOn(m_instance); |
| 165 | mIsModemEnabled = false; |
| 166 | } |
| 167 | break; |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | void RfDesenseTxTest::emRadioStateOn(){ |
| 173 | if (mIsModemEnabled == true) { |
| 174 | LOG_D(LOG_TAG, "mIsModemEnabled is true, just return"); |
| 175 | return; |
| 176 | } |
| 177 | mIsModemEnabled = true; |
| 178 | LOG_D(LOG_TAG, "turn on rf succeed"); |
| 179 | if (mState == STATE_STARTED) { |
| 180 | mCurrectRatInfo = getCurrectRatInfo(); |
| 181 | if (mCurrectRatInfo |
| 182 | && !mCurrectRatInfo->getRatCmdSwitch().empty()) { |
| 183 | LOG_D(LOG_TAG, "switch rat(%s)",mCurrectRatInfo->getRatCmdSwitch().c_str()); |
| 184 | //unregisterRadioOn(); |
| 185 | rf_send_at_cmd(mCurrectRatInfo->getRatCmdSwitch(), MSG_SWITCH_RAT_DONE); |
| 186 | } else { |
| 187 | LOG_D(LOG_TAG, "mCurrectRatInfo == null"); |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | void RfDesenseTxTest::emRadioStateOfforNotAvailable() { |
| 193 | //unregisterRadioOffOrNotAvailable(); |
| 194 | if (mIsModemNotEnabled == true) { |
| 195 | LOG_D(LOG_TAG, "mIsModemNotEnabled is true, just return"); |
| 196 | return; |
| 197 | } |
| 198 | mIsModemNotEnabled = true; |
| 199 | LOG_D(LOG_TAG, "turn off rf succeed..."); |
| 200 | if (mCurrectRatInfo) { |
| 201 | mCurrectRatInfo->setRatSendState(true); |
| 202 | rf_send_at_cmd(mCurrectRatInfo->getRatCmdStart(), MSG_START_TX); |
| 203 | LOG_D(LOG_TAG, "send: %s %s",mCurrectRatInfo->getRatName().c_str() ,mCurrectRatInfo->getRatCmdStart().c_str()); |
| 204 | } else { |
| 205 | LOG_D(LOG_TAG, "mCurrectRatInfo == null"); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | void RfDesenseTxTest::emOemHookRaw(int value, int slot_id){ |
| 210 | if(slot_id != phone_id) { |
| 211 | LOG_W(LOG_TAG, "slot_id = %d, main_slot: %d", slot_id, phone_id); |
| 212 | //return; |
| 213 | } |
| 214 | LOG_D(LOG_TAG, "Readback tx power = %d", value); |
| 215 | std::string result = ""; |
| 216 | std::string rat = ""; |
| 217 | std::lock_guard<std::mutex> guard(mMutex); |
| 218 | m_rawUrc = true; |
| 219 | m_condVar.notify_one(); |
| 220 | float getPower = value / 8.0f; |
| 221 | if (std::abs(std::stoi(mCurrectRatInfo->getRatPowerSet()) - |
| 222 | getPower) > mCheckLimit) { |
| 223 | result = "failed\n"; |
| 224 | } else { |
| 225 | result = "succeed\n"; |
| 226 | } |
| 227 | |
| 228 | std::string s = std::string("Start TX:\n") |
| 229 | + std::string("Rat(band) ") + std::string("Power_Set ") |
| 230 | + std::string("Power_Get ") + std::string("Result\n"); |
| 231 | rat = utils::format("%-20s %-15s %-10s", |
| 232 | (mCurrectRatInfo->getRatName()+ "(b" + mCurrectRatInfo->getRatband() + ")").c_str(), |
| 233 | mCurrectRatInfo->getRatPowerSet().c_str(), |
| 234 | std::to_string(getPower).c_str() |
| 235 | ); |
| 236 | std::string ret; |
| 237 | if (!result.compare("failed\n")) { |
| 238 | ret = utils::format("%10s", result.c_str()); |
| 239 | } else { |
| 240 | ret = utils::format("%10s", result.c_str()); |
| 241 | } |
| 242 | str_msg += s + rat + ret; |
| 243 | |
| 244 | } |
| 245 | |
| 246 | void RfDesenseTxTest::tx_stop() { |
| 247 | LOG_D(LOG_TAG,"tx_stop"); |
| 248 | std::unique_lock<std::mutex> mlock(mMutex); |
| 249 | m_condVar.wait(mlock,[this]{return m_rawUrc;}); |
| 250 | txTestStop(MSG_NEXT_RAT); |
| 251 | } |
| 252 | |
| 253 | void RfDesenseTxTest::init() { |
| 254 | mRequestHandleThread = new RequestHandleThread(this); |
| 255 | mRequestHandleThread->run(); |
| 256 | } |
| 257 | |
| 258 | RfDesenseTxTest::RfDesenseTxTest() { |
| 259 | initRatList(); |
| 260 | } |
| 261 | |
| 262 | RfDesenseTxTest::~RfDesenseTxTest() { |
| 263 | LOG_D(LOG_TAG, "RfDesenseTxTest destroyed"); |
| 264 | } |
| 265 | |
| 266 | void RfDesenseTxTest::txTestStop(int what) { |
| 267 | if (mCurrectRatInfo) { |
| 268 | rf_send_at_cmd(mCurrectRatInfo->getRatCmdStop(), what); |
| 269 | LOG_D(LOG_TAG, "stop: %s %s", mCurrectRatInfo->getRatName().c_str(), mCurrectRatInfo->getRatCmdStop().c_str()); |
| 270 | } else { |
| 271 | LOG_D(LOG_TAG, "mCurrectRatInfo is null"); |
| 272 | mState = STATE_STOPPED; |
| 273 | for (int i = 0; i < mRatList.size(); i++) { |
| 274 | mRatList[i]->setRatSendState(false); |
| 275 | mRatList[i]->setRatCheckState(false); |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | void RfDesenseTxTest::deInit() { |
| 281 | |
| 282 | } |
| 283 | |
| 284 | RfDesenseTxTest* RfDesenseTxTest::getInstance() { |
| 285 | if(!m_instance) { |
| 286 | mMutex.lock(); |
| 287 | if(!m_instance) { |
| 288 | m_instance = new RfDesenseTxTest(); |
| 289 | m_instance->init(); |
| 290 | } |
| 291 | mMutex.unlock(); |
| 292 | } |
| 293 | return m_instance; |
| 294 | } |
| 295 | |
| 296 | // Method implements of RequestHandleThread |
| 297 | RfDesenseTxTest::RequestHandleThread::RequestHandleThread(RfDesenseTxTest* tx) : m_looper(NULL) { |
| 298 | mTx = tx; |
| 299 | LOG_D(LOG_TAG, "RequestHandleThread created"); |
| 300 | } |
| 301 | |
| 302 | RfDesenseTxTest::RequestHandleThread::~RequestHandleThread() { |
| 303 | mTx = NULL; |
| 304 | LOG_D(LOG_TAG, "RequestHandleThread destroyed"); |
| 305 | } |
| 306 | |
| 307 | bool RfDesenseTxTest::RequestHandleThread::threadLoop() { |
| 308 | LOG_D(LOG_TAG, "RequestHandleThread threadLoop"); |
| 309 | // start message loop |
| 310 | m_looper = Looper::prepare(0); |
| 311 | int result; |
| 312 | do { |
| 313 | result = m_looper->pollAll(-1); |
| 314 | LOG_D(LOG_TAG, "RequestHandleThread threadLoop, pull message result = %d", result); |
| 315 | } while (result == Looper::POLL_WAKE || result == Looper::POLL_CALLBACK); |
| 316 | return true; |
| 317 | } |
| 318 | |
| 319 | sp<Looper> RfDesenseTxTest::RequestHandleThread::getLooper() { |
| 320 | return m_looper; |
| 321 | } |
| 322 | |
| 323 | RfDesenseTxTest::RfRequestMessage::RfRequestMessage(RfDesenseTxTest* tx) : mTx(tx),mMsgType(0), |
| 324 | response(""),responselen(0), slot(0), e(RIL_E_SUCCESS) { |
| 325 | } |
| 326 | |
| 327 | RfDesenseTxTest::RfRequestMessage::~RfRequestMessage() { |
| 328 | LOG_D(LOG_TAG, "RequestHandleThread destroyed"); |
| 329 | } |
| 330 | |
| 331 | void RfDesenseTxTest::RfRequestMessage::sendMessage(int delayms) { |
| 332 | LOG_D(LOG_TAG, "RfDesenseTxTest::RfRequestMessage, sendMessage delayms=%d", delayms); |
| 333 | if(mTx != NULL) { |
| 334 | mTx->sendMessage(this, delayms); |
| 335 | } else { |
| 336 | LOG_D(LOG_TAG, "RfDesenseTxTest::RfRequestHandler mTx is null"); |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | void RfDesenseTxTest::RfRequestHandler::sendMessage(sp<RfRequestMessage> msg, int delayms) { |
| 341 | LOG_D(LOG_TAG, "RfDesenseTxTest::RfRequestHandler, sendMessage msg what=%d delayms=%d", msg->mMsgType, delayms); |
| 342 | this->mMsg = msg; |
| 343 | if(mTx != NULL) { |
| 344 | mTx->sendMessage(mMsg, delayms); |
| 345 | } else { |
| 346 | LOG_D(LOG_TAG, "RfDesenseTxTest::RfRequestHandler mTx is null"); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | RfDesenseTxTest::RfRequestHandler:: ~RfRequestHandler() { |
| 351 | mTx = NULL; |
| 352 | LOG_D(LOG_TAG, "RfRequestHandler destroyed"); |
| 353 | } |
| 354 | |
| 355 | void RfDesenseTxTest::handle_request(string response,int responselen,int slot, RIL_Errno e) { |
| 356 | sp<RfRequestMessage> msg = new RfRequestMessage(this); |
| 357 | msg->mMsgType = mCurrentFlag; |
| 358 | msg->response = response; |
| 359 | msg->responselen = responselen; |
| 360 | msg->slot = slot; |
| 361 | msg->e = e; |
| 362 | if(mCurrentFlag == MSG_READ_POWER) { |
| 363 | sendMessage(msg, 2*1000); |
| 364 | } else { |
| 365 | sendMessage(msg, 1000); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | sp<RfDesenseTxTest::RfRequestHandler> RfDesenseTxTest::sendMessage(sp<RfRequestMessage> msg, int delayms) { |
| 370 | LOG_D(LOG_TAG, "sendMessage msg token=%d delayms=%d", msg->mMsgType, delayms); |
| 371 | sp<RfRequestHandler> handler = new RfRequestHandler(this); |
| 372 | handler->mMsg = msg; |
| 373 | if(mRequestHandleThread.get()) { |
| 374 | sp<Looper> looper = mRequestHandleThread->getLooper(); |
| 375 | if(looper.get()) { |
| 376 | if (delayms > 0) { |
| 377 | looper->sendMessageDelayed(ms2ns(delayms),handler, handler->m_dummyMsg); |
| 378 | } else { |
| 379 | looper->sendMessage(handler, handler->m_dummyMsg); |
| 380 | } |
| 381 | } else { |
| 382 | LOG_D(LOG_TAG, "looper fail"); |
| 383 | } |
| 384 | } else { |
| 385 | LOG_D(LOG_TAG, "mRequestHandleThread fail"); |
| 386 | } |
| 387 | |
| 388 | return handler; |
| 389 | } |
| 390 | |
| 391 | void RfDesenseTxTest::emRfDesenseAtCmdHandle(sp<RfRequestMessage> msg){ |
| 392 | LOG_D(LOG_TAG, "emRfDesenseAtCmdHandle, type: %d", msg->mMsgType); |
| 393 | int responselen = msg->responselen; |
| 394 | std::string response = msg->response; |
| 395 | switch (msg->mMsgType) { |
| 396 | case MSG_SWITCH_RAT_DONE: { |
| 397 | if (msg->e == RIL_E_SUCCESS) { |
| 398 | LOG_D(LOG_TAG, "switch rat succeed"); |
| 399 | if (mCurrectRatInfo->getRatName() == mRatName[1]) { // tdscdma |
| 400 | LOG_D(LOG_TAG, "end AT+EWMPOLICY=0"); |
| 401 | rf_send_at_cmd("AT+EWMPOLICY=0", MSG_EWMPOLICY_TDSCDMA); |
| 402 | } else if (mCurrectRatInfo->getRatName() == mRatName[2]) { // wcdma |
| 403 | LOG_D(LOG_TAG, "send AT+EWMPOLICY=0"); |
| 404 | rf_send_at_cmd("AT+EWMPOLICY=0", MSG_EWMPOLICY_WCDMA); |
| 405 | } else { // other rat |
| 406 | registerRadioOffOrNotAvailable(m_instance); |
| 407 | turnOffRf(); |
| 408 | } |
| 409 | } else { |
| 410 | LOG_D(LOG_TAG, "switch rat failed"); |
| 411 | emResultNotifyWithDone(mCurrectRatInfo->getRatName() + " switch rat failed\n"); |
| 412 | } |
| 413 | break; |
| 414 | } |
| 415 | case MSG_EWMPOLICY_TDSCDMA: { |
| 416 | LOG_D(LOG_TAG, "AT+EWMPOLICY=0 send succeed"); |
| 417 | LOG_D(LOG_TAG, "send AT+ECSRA=2,0,1,0,1,0 ..."); |
| 418 | rf_send_at_cmd("AT+ECSRA=2,0,1,0,1,0", MSG_ECSRA); |
| 419 | break; |
| 420 | } |
| 421 | case MSG_EWMPOLICY_WCDMA: { |
| 422 | LOG_D(LOG_TAG, "AT+EWMPOLICY=0 send succeed"); |
| 423 | LOG_D(LOG_TAG, "send AT+ECSRA=2,1,0,1,1,0 ..."); |
| 424 | rf_send_at_cmd("AT+ECSRA=2,1,0,1,1,0", MSG_ECSRA); |
| 425 | break; |
| 426 | } |
| 427 | case MSG_ECSRA: { |
| 428 | LOG_D(LOG_TAG, "AT+ECSRA send succeed"); |
| 429 | turnOffRf(); |
| 430 | break; |
| 431 | } |
| 432 | case MSG_START_TX:{ |
| 433 | if (msg->e == RIL_E_SUCCESS) { |
| 434 | LOG_D(LOG_TAG, "start cmd ok"); |
| 435 | if (utils::is93Modem() && mCurrectRatInfo && !mCurrectRatInfo->getRatCmdPowerRead().empty()) { |
| 436 | LOG_D(LOG_TAG,"start read cmd: %s", mCurrectRatInfo->getRatCmdPowerRead().c_str()); |
| 437 | rf_send_at_cmd(mCurrectRatInfo->getRatCmdPowerRead(), MSG_READ_POWER); |
| 438 | } else { |
| 439 | LOG_D(LOG_TAG, "don't read"); |
| 440 | txTestStop(MSG_NEXT_RAT); |
| 441 | } |
| 442 | } else { |
| 443 | LOG_D(LOG_TAG, "start cmd failed"); |
| 444 | emResultNotifyWithDone(mCurrectRatInfo->getRatName() + " start cmd failed\n"); |
| 445 | } |
| 446 | break; |
| 447 | } |
| 448 | case MSG_READ_POWER:{ |
| 449 | mTestDurationSended += mReadbackInterval; |
| 450 | if (mTestDurationSended >= mTestDuration) { |
| 451 | if (msg->e == RIL_E_SUCCESS) { |
| 452 | LOG_D(LOG_TAG, "read tx power succeed"); |
| 453 | if(m_rawUrc){ |
| 454 | txTestStop(MSG_NEXT_RAT); |
| 455 | m_rawUrc = false; |
| 456 | } else { |
| 457 | std::thread thread_stop(&RfDesenseTxTest::tx_stop, m_instance); |
| 458 | thread_stop.detach(); |
| 459 | } |
| 460 | } else { |
| 461 | LOG_D(LOG_TAG, "read tx power failed"); |
| 462 | emResultNotifyWithDone(mCurrectRatInfo->getRatName() + " read tx power failed\n"); |
| 463 | } |
| 464 | mTestDurationSended = 0; |
| 465 | } else { |
| 466 | if (utils::is93Modem() && mCurrectRatInfo && !mCurrectRatInfo->getRatCmdPowerRead().empty()) { |
| 467 | LOG_D(LOG_TAG,"(sencond)start read cmd: %s", mCurrectRatInfo->getRatCmdPowerRead().c_str()); |
| 468 | rf_send_at_cmd(mCurrectRatInfo->getRatCmdPowerRead(), MSG_READ_POWER); |
| 469 | } else { |
| 470 | LOG_D(LOG_TAG,"(sencond)start read cmd fail"); |
| 471 | } |
| 472 | } |
| 473 | break; |
| 474 | } |
| 475 | case MSG_NEXT_RAT: { |
| 476 | if (msg->e == RIL_E_SUCCESS) { |
| 477 | std::string rat = mCurrectRatInfo->getRatName(); |
| 478 | LOG_D(LOG_TAG, "stop(%s) cmd ok", rat.c_str()); |
| 479 | mCurrectRatInfo = getCurrectRatInfo(); |
| 480 | if (mCurrectRatInfo) { |
| 481 | LOG_D(LOG_TAG, "error, mCurrectRatInfo should null "); |
| 482 | } |
| 483 | emResultNotifyWithDone(str_msg + "send all rat done\n"); |
| 484 | str_msg = ""; |
| 485 | mState = STATE_STOPPED; |
| 486 | for (int i = 0; i < mRatList.size(); i++) { |
| 487 | mRatList[i]->setRatSendState(false); |
| 488 | mRatList[i]->setRatCheckState(false); |
| 489 | } |
| 490 | // if(rat == mRatName[1] || rat == mRatName[2]) { |
| 491 | // if(utils::is93Modem()){ |
| 492 | // utils::mtk_property_set("vendor.ril.mux.report.case", "2"); |
| 493 | // utils::mtk_property_set("vendor.ril.muxreport", "1"); |
| 494 | // }else { |
| 495 | // emSendATCommand("AT+CFUN=1,1"); |
| 496 | // } |
| 497 | // trm_flag = true; |
| 498 | // } else { |
| 499 | // turnOnRf(); |
| 500 | // } |
| 501 | turnOnRf(); |
| 502 | trm_flag = true; |
| 503 | unregister_response_oem_hook_raw(); |
| 504 | unregisterOnUnsolOemHookRaw(); |
| 505 | } else { |
| 506 | LOG_D(LOG_TAG, "stop cmd failed"); |
| 507 | emResultNotifyWithDone(mCurrectRatInfo->getRatName() + " stop cmd failed \n"); |
| 508 | } |
| 509 | break; |
| 510 | } |
| 511 | default: |
| 512 | break; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | void RfDesenseTxTest::RfRequestHandler::handleMessage(const Message& message) { |
| 517 | LOG_D(LOG_TAG, "handleMessage msg->mMsgType: %d", mMsg->mMsgType); |
| 518 | if(mTx != NULL) { |
| 519 | mTx->emRfDesenseAtCmdHandle(mMsg); |
| 520 | } else { |
| 521 | LOG_D(LOG_TAG, "handleMessage mTx is null"); |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | void RfDesenseTxTest::handle_gsm_para(const std::string& name, int last_pos, |
| 526 | const std::string& sub_name) { |
| 527 | bool flag = false; |
| 528 | std::shared_ptr<RfDesenseTxTestGsm> gsm = |
| 529 | RfDesenseTxTestGsm::get_instance(); |
| 530 | if (name == rfdesense_gsm_sub[INDEX_GSM_SUB_BAND].name) { |
| 531 | flag = gsm->set_band(last_pos); |
| 532 | } else if (name == rfdesense_gsm_sub[INDEX_GSM_SUB_CHANNEL].name) { |
| 533 | if (sub_name == set_get[0].name) { |
| 534 | //get |
| 535 | gsm->show_channel(); |
| 536 | } else if (sub_name == set_get[1].name) { |
| 537 | // set |
| 538 | if (mCurrentSettingsValues.size() > 0) { |
| 539 | flag = gsm->set_channel(mCurrentSettingsValues[0]); |
| 540 | } else { |
| 541 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 542 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 543 | } |
| 544 | } else { |
| 545 | LOG_D(LOG_TAG, "error"); |
| 546 | } |
| 547 | } else if (name == rfdesense_gsm_sub[INDEX_GSM_SUB_POWER].name) { |
| 548 | if (sub_name == set_get[0].name) { |
| 549 | //get |
| 550 | gsm->show_power(); |
| 551 | } else if (sub_name == set_get[1].name) { |
| 552 | // set |
| 553 | if (mCurrentSettingsValues.size() > 0) { |
| 554 | flag = gsm->set_power(mCurrentSettingsValues[0]); |
| 555 | } else { |
| 556 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 557 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 558 | } |
| 559 | } else { |
| 560 | LOG_D(LOG_TAG, "error"); |
| 561 | } |
| 562 | } else if (name == rfdesense_gsm_sub[INDEX_GSM_SUB_AFC].name) { |
| 563 | if (sub_name == set_get[0].name) { |
| 564 | //get |
| 565 | gsm->show_afc(); |
| 566 | } else if (sub_name == set_get[1].name) { |
| 567 | // set |
| 568 | if (mCurrentSettingsValues.size() > 0) { |
| 569 | flag = gsm->set_afc(mCurrentSettingsValues[0]); |
| 570 | } else { |
| 571 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 572 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 573 | } |
| 574 | } else { |
| 575 | LOG_D(LOG_TAG, "error"); |
| 576 | } |
| 577 | } else if (name == rfdesense_gsm_sub[INDEX_GSM_SUB_TSC].name) { |
| 578 | if (sub_name == set_get[0].name) { |
| 579 | //get |
| 580 | gsm->show_tsc(); |
| 581 | } else if (sub_name == set_get[1].name) { |
| 582 | // set |
| 583 | if (mCurrentSettingsValues.size() > 0) { |
| 584 | flag = gsm->set_tsc(mCurrentSettingsValues[0]); |
| 585 | } else { |
| 586 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 587 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 588 | } |
| 589 | } else { |
| 590 | LOG_D(LOG_TAG, "error"); |
| 591 | } |
| 592 | } else if (name == rfdesense_gsm_sub[INDEX_GSM_SUB_PATTERN].name) { |
| 593 | flag = gsm->set_pattern(last_pos); |
| 594 | } |
| 595 | |
| 596 | if (flag) { |
| 597 | mRatList[INDEX_GSM]->setRatCmdStart(gsm->get_command()); |
| 598 | mRatList[INDEX_GSM]->setRatband(gsm->get_band()); |
| 599 | mRatList[INDEX_GSM]->setRatPowerSet(gsm->get_power()); |
| 600 | save(INDEX_GSM); |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | void RfDesenseTxTest::handle_tdscdma_para(const std::string& name, int last_pos, |
| 605 | const std::string& sub_name) { |
| 606 | //"TDSCDMA" |
| 607 | bool flag = false; |
| 608 | std::shared_ptr<RfDesenseTxTestTd> tdscdma = std::make_shared< |
| 609 | RfDesenseTxTestTd>(utils::MODEM_TDSCDMA); |
| 610 | if (name == rfdesense_tdscdma_sub[INDEX_3G_SUB_BAND].name) { |
| 611 | flag = tdscdma->set_band(last_pos); |
| 612 | } else if (name == rfdesense_tdscdma_sub[INDEX_3G_SUB_CHANNEL].name) { |
| 613 | if (sub_name == set_get[0].name) { |
| 614 | //get |
| 615 | tdscdma->show_channel(); |
| 616 | } else if (sub_name == set_get[1].name) { |
| 617 | // set |
| 618 | if (mCurrentSettingsValues.size() > 0) { |
| 619 | flag = tdscdma->set_channel(mCurrentSettingsValues[0]); |
| 620 | } else { |
| 621 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 622 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 623 | } |
| 624 | } else { |
| 625 | LOG_D(LOG_TAG, "error"); |
| 626 | } |
| 627 | } else if (name == rfdesense_tdscdma_sub[INDEX_3G_SUB_POWER].name) { |
| 628 | if (sub_name == set_get[0].name) { |
| 629 | //get |
| 630 | tdscdma->show_power(); |
| 631 | } else if (sub_name == set_get[1].name) { |
| 632 | // set |
| 633 | if (mCurrentSettingsValues.size() > 0) { |
| 634 | flag = tdscdma->set_power(mCurrentSettingsValues[0]); |
| 635 | } else { |
| 636 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 637 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 638 | } |
| 639 | } else { |
| 640 | LOG_D(LOG_TAG, "error"); |
| 641 | } |
| 642 | } else { |
| 643 | LOG_D(LOG_TAG, "logic error"); |
| 644 | } |
| 645 | |
| 646 | if (flag) { |
| 647 | mRatList[INDEX_TDSCDMA]->setRatCmdStart(tdscdma->get_command()); |
| 648 | mRatList[INDEX_TDSCDMA]->setRatband(tdscdma->get_band()); |
| 649 | mRatList[INDEX_TDSCDMA]->setRatPowerSet(tdscdma->get_power()); |
| 650 | save(INDEX_TDSCDMA); |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | void RfDesenseTxTest::handle_wcdma_para(const std::string& name, int last_pos, |
| 655 | const std::string& sub_name) { |
| 656 | //"WCDMA" |
| 657 | bool flag = false; |
| 658 | std::shared_ptr<RfDesenseTxTestTd> wcdma = std::make_shared< |
| 659 | RfDesenseTxTestTd>(utils::MODEM_WCDMA); |
| 660 | if (name == rfdesense_wcdma_sub[INDEX_3G_SUB_BAND].name) { |
| 661 | flag = wcdma->set_band(last_pos); |
| 662 | } else if (name == rfdesense_wcdma_sub[INDEX_3G_SUB_CHANNEL].name) { |
| 663 | if (sub_name == set_get[0].name) { |
| 664 | //get |
| 665 | wcdma->show_channel(); |
| 666 | } else if (sub_name == set_get[1].name) { |
| 667 | // set |
| 668 | if (mCurrentSettingsValues.size() > 0) { |
| 669 | flag = wcdma->set_channel(mCurrentSettingsValues[0]); |
| 670 | } else { |
| 671 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 672 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 673 | } |
| 674 | } else { |
| 675 | LOG_D(LOG_TAG, "error"); |
| 676 | } |
| 677 | } else if (name == rfdesense_wcdma_sub[INDEX_3G_SUB_POWER].name) { |
| 678 | if (sub_name == set_get[0].name) { |
| 679 | //get |
| 680 | wcdma->show_power(); |
| 681 | } else if (sub_name == set_get[1].name) { |
| 682 | // set |
| 683 | if (mCurrentSettingsValues.size() > 0) { |
| 684 | flag = wcdma->set_power(mCurrentSettingsValues[0]); |
| 685 | } else { |
| 686 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 687 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 688 | } |
| 689 | } else { |
| 690 | LOG_D(LOG_TAG, "error"); |
| 691 | } |
| 692 | } else { |
| 693 | LOG_D(LOG_TAG, "logic error"); |
| 694 | } |
| 695 | |
| 696 | if (flag) { |
| 697 | mRatList[INDEX_WCDMA]->setRatCmdStart(wcdma->get_command()); |
| 698 | mRatList[INDEX_WCDMA]->setRatband(wcdma->get_band()); |
| 699 | mRatList[INDEX_WCDMA]->setRatPowerSet(wcdma->get_power()); |
| 700 | save(INDEX_WCDMA); |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | void RfDesenseTxTest::handle_lte_fdd_para(const std::string& name, int last_pos, |
| 705 | const std::string& sub_name) { |
| 706 | //LTE(FDD) |
| 707 | bool flag = false; |
| 708 | std::shared_ptr<RfDesenseTxTestLte> fdd = std::make_shared< |
| 709 | RfDesenseTxTestLte>(utils::MODEM_LTE_FDD); |
| 710 | if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_MODE].name) { |
| 711 | flag = fdd->set_mode(last_pos); |
| 712 | } else if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_BAND].name) { |
| 713 | flag = fdd->set_band(last_pos); |
| 714 | } else if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_BANDWITH].name) { |
| 715 | flag = fdd->set_bandwith(last_pos); |
| 716 | } else if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_FREQ].name) { |
| 717 | if (sub_name == set_get[0].name) { |
| 718 | //get |
| 719 | fdd->show_freq(); |
| 720 | } else if (sub_name == set_get[1].name) { |
| 721 | // set |
| 722 | if (mCurrentSettingsValues.size() > 0) { |
| 723 | flag = fdd->set_freq(mCurrentSettingsValues[0]); |
| 724 | } else { |
| 725 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 726 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 727 | } |
| 728 | } else { |
| 729 | LOG_D(LOG_TAG, "error"); |
| 730 | } |
| 731 | } else if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_START].name) { |
| 732 | if (sub_name == set_get[0].name) { |
| 733 | //get |
| 734 | fdd->show_start(); |
| 735 | } else if (sub_name == set_get[1].name) { |
| 736 | // set |
| 737 | if (mCurrentSettingsValues.size() > 0) { |
| 738 | flag = fdd->set_start(mCurrentSettingsValues[0]); |
| 739 | } else { |
| 740 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 741 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 742 | } |
| 743 | } else { |
| 744 | LOG_D(LOG_TAG, "error"); |
| 745 | } |
| 746 | } else if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_LENGTH].name) { |
| 747 | if (sub_name == set_get[0].name) { |
| 748 | //get |
| 749 | fdd->show_length(); |
| 750 | } else if (sub_name == set_get[1].name) { |
| 751 | // set |
| 752 | if (mCurrentSettingsValues.size() > 0) { |
| 753 | flag = fdd->set_length(mCurrentSettingsValues[0]); |
| 754 | } else { |
| 755 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 756 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 757 | } |
| 758 | } else { |
| 759 | LOG_D(LOG_TAG, "error"); |
| 760 | } |
| 761 | } else if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_MCS].name) { |
| 762 | flag = fdd->set_mcs(last_pos); |
| 763 | } else if (name == rfdesense_fdd_sub[INDEX_FDD_SUB_POWER].name) { |
| 764 | if (sub_name == set_get[0].name) { |
| 765 | //get |
| 766 | fdd->show_power(); |
| 767 | } else if (sub_name == set_get[1].name) { |
| 768 | // set |
| 769 | if (mCurrentSettingsValues.size() > 0) { |
| 770 | flag = fdd->set_power(mCurrentSettingsValues[0]); |
| 771 | } else { |
| 772 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 773 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 774 | } |
| 775 | } else { |
| 776 | LOG_D(LOG_TAG, "error"); |
| 777 | } |
| 778 | } else { |
| 779 | LOG_D(LOG_TAG, "error"); |
| 780 | } |
| 781 | |
| 782 | if (flag) { |
| 783 | mRatList[INDEX_LTE_FDD]->setRatCmdStart(fdd->get_command()); |
| 784 | mRatList[INDEX_LTE_FDD]->setRatband(fdd->get_band()); |
| 785 | mRatList[INDEX_LTE_FDD]->setRatPowerSet(fdd->get_power()); |
| 786 | save(INDEX_LTE_FDD); |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | void RfDesenseTxTest::handle_lte_tdd_para(const std::string& name, int last_pos, |
| 791 | const std::string& sub_name) { |
| 792 | //LTE(TDD) |
| 793 | bool flag = false; |
| 794 | std::shared_ptr<RfDesenseTxTestLte> tdd = std::make_shared< |
| 795 | RfDesenseTxTestLte>(utils::MODEM_LTE_TDD); |
| 796 | if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_MODE].name) { |
| 797 | flag = tdd->set_mode(last_pos); |
| 798 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_BAND].name) { |
| 799 | flag = tdd->set_band(last_pos); |
| 800 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_BANDWIDTH].name) { |
| 801 | flag = tdd->set_bandwith(last_pos); |
| 802 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_FREQ].name) { |
| 803 | if (sub_name == set_get[0].name) { |
| 804 | //get |
| 805 | tdd->show_freq(); |
| 806 | } else if (sub_name == set_get[1].name) { |
| 807 | // set |
| 808 | if (mCurrentSettingsValues.size() > 0) { |
| 809 | flag = tdd->set_freq(mCurrentSettingsValues[0]); |
| 810 | } else { |
| 811 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 812 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 813 | } |
| 814 | } else { |
| 815 | LOG_D(LOG_TAG, "error"); |
| 816 | } |
| 817 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_CONFIG].name) { |
| 818 | flag = tdd->set_tdd_config(last_pos); |
| 819 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_SPECIAL].name) { |
| 820 | flag = tdd->set_tdd_special(last_pos); |
| 821 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_START].name) { |
| 822 | if (sub_name == set_get[0].name) { |
| 823 | //get |
| 824 | tdd->show_start(); |
| 825 | } else if (sub_name == set_get[1].name) { |
| 826 | // set |
| 827 | if (mCurrentSettingsValues.size() > 0) { |
| 828 | flag = tdd->set_start(mCurrentSettingsValues[0]); |
| 829 | } else { |
| 830 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 831 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 832 | } |
| 833 | } else { |
| 834 | LOG_D(LOG_TAG, "error"); |
| 835 | } |
| 836 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_LENGTH].name) { |
| 837 | if (sub_name == set_get[0].name) { |
| 838 | //get |
| 839 | tdd->show_length(); |
| 840 | } else if (sub_name == set_get[1].name) { |
| 841 | // set |
| 842 | if (mCurrentSettingsValues.size() > 0) { |
| 843 | flag = tdd->set_length(mCurrentSettingsValues[0]); |
| 844 | } else { |
| 845 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 846 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 847 | } |
| 848 | } else { |
| 849 | LOG_D(LOG_TAG, "error"); |
| 850 | } |
| 851 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_MCS].name) { |
| 852 | flag = tdd->set_mcs(last_pos); |
| 853 | } else if (name == rfdesense_tdd_sub[INDEX_TDD_SUB_POWER].name) { |
| 854 | if (sub_name == set_get[0].name) { |
| 855 | //get |
| 856 | tdd->show_power(); |
| 857 | } else if (sub_name == set_get[1].name) { |
| 858 | // set |
| 859 | if (mCurrentSettingsValues.size() > 0) { |
| 860 | flag = tdd->set_power(mCurrentSettingsValues[0]); |
| 861 | } else { |
| 862 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 863 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 864 | } |
| 865 | } else { |
| 866 | LOG_D(LOG_TAG, "error"); |
| 867 | } |
| 868 | } else { |
| 869 | LOG_D(LOG_TAG, "error"); |
| 870 | } |
| 871 | |
| 872 | if (flag) { |
| 873 | mRatList[INDEX_LTE_TDD]->setRatCmdStart(tdd->get_command()); |
| 874 | mRatList[INDEX_LTE_TDD]->setRatband(tdd->get_band()); |
| 875 | mRatList[INDEX_LTE_TDD]->setRatPowerSet(tdd->get_power()); |
| 876 | save(INDEX_LTE_TDD); |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | void RfDesenseTxTest::handle_cdma_evdo_para(const std::string& name, |
| 881 | int last_pos, const std::string& sub_name) { |
| 882 | //CDMA(EVDO) |
| 883 | bool flag = false; |
| 884 | std::shared_ptr<RfDesenseTxTestCdma> evdo = std::make_shared< |
| 885 | RfDesenseTxTestCdma>(utils::MODEM_CDMA_EVDO); |
| 886 | if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_BAND].name) { |
| 887 | flag = evdo->set_band(last_pos); |
| 888 | } else if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_CHANNEL].name) { |
| 889 | if (sub_name == set_get[0].name) { |
| 890 | //get |
| 891 | evdo->show_channel(); |
| 892 | } else if (sub_name == set_get[1].name) { |
| 893 | // set |
| 894 | if (mCurrentSettingsValues.size() > 0) { |
| 895 | flag = evdo->set_channel(mCurrentSettingsValues[0]); |
| 896 | } else { |
| 897 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 898 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 899 | } |
| 900 | } else { |
| 901 | LOG_D(LOG_TAG, "error"); |
| 902 | } |
| 903 | } else if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_MODULATION].name) { |
| 904 | flag = evdo->set_modulation(last_pos); |
| 905 | } else if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_POWER].name) { |
| 906 | if (sub_name == set_get[0].name) { |
| 907 | //get |
| 908 | evdo->show_power(); |
| 909 | } else if (sub_name == set_get[1].name) { |
| 910 | // set |
| 911 | if (mCurrentSettingsValues.size() > 0) { |
| 912 | flag = evdo->set_power(mCurrentSettingsValues[0]); |
| 913 | } else { |
| 914 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 915 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 916 | } |
| 917 | } else { |
| 918 | LOG_D(LOG_TAG, "error"); |
| 919 | } |
| 920 | } |
| 921 | |
| 922 | if (flag) { |
| 923 | mRatList[INDEX_CDMA_EVDO]->setRatCmdStart(evdo->get_command()); |
| 924 | mRatList[INDEX_CDMA_EVDO]->setRatband(evdo->get_band()); |
| 925 | mRatList[INDEX_CDMA_EVDO]->setRatPowerSet(evdo->get_power()); |
| 926 | save(INDEX_CDMA_EVDO); |
| 927 | } |
| 928 | } |
| 929 | |
| 930 | void RfDesenseTxTest::handle_cdma_1X_para(const std::string& name, int last_pos, |
| 931 | const std::string& sub_name) { |
| 932 | //CDMA(1X) |
| 933 | bool flag = false; |
| 934 | std::shared_ptr<RfDesenseTxTestCdma> cdma_1x = std::make_shared< |
| 935 | RfDesenseTxTestCdma>(utils::MODEM_CDMA_1X); |
| 936 | if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_BAND].name) { |
| 937 | flag = cdma_1x->set_band(last_pos); |
| 938 | } else if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_CHANNEL].name) { |
| 939 | if (sub_name == set_get[0].name) { |
| 940 | //get |
| 941 | cdma_1x->show_channel(); |
| 942 | } else if (sub_name == set_get[1].name) { |
| 943 | // set |
| 944 | if (mCurrentSettingsValues.size() > 0) { |
| 945 | flag = cdma_1x->set_channel(mCurrentSettingsValues[0]); |
| 946 | } else { |
| 947 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 948 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 949 | } |
| 950 | } else { |
| 951 | LOG_D(LOG_TAG, "error"); |
| 952 | } |
| 953 | } else if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_MODULATION].name) { |
| 954 | flag = cdma_1x->set_modulation(last_pos); |
| 955 | } else if (name == rfdesense_cdma_sub[INDEX_CDMA_SUB_POWER].name) { |
| 956 | if (sub_name == set_get[0].name) { |
| 957 | //get |
| 958 | cdma_1x->show_power(); |
| 959 | } else if (sub_name == set_get[1].name) { |
| 960 | // set |
| 961 | if (mCurrentSettingsValues.size() > 0) { |
| 962 | flag = cdma_1x->set_power(mCurrentSettingsValues[0]); |
| 963 | } else { |
| 964 | LOG_D(LOG_TAG, "mCurrentSettingsValues size is 0"); |
| 965 | em_result_notify_error("please input set values, now, only select the set item. value is empty"); |
| 966 | } |
| 967 | } else { |
| 968 | LOG_D(LOG_TAG, "error"); |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | if (flag) { |
| 973 | mRatList[INDEX_CDMA_1X]->setRatCmdStart(cdma_1x->get_command()); |
| 974 | mRatList[INDEX_CDMA_1X]->setRatband(cdma_1x->get_band()); |
| 975 | mRatList[INDEX_CDMA_1X]->setRatPowerSet(cdma_1x->get_power()); |
| 976 | save(INDEX_CDMA_1X); |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | bool RfDesenseTxTest::handle_show_default(const std::string& standard) { |
| 981 | //show default |
| 982 | if (standard == sub_tx_test[INDEX_GSM].name) { |
| 983 | //"GSM" |
| 984 | std::shared_ptr<RfDesenseTxTestGsm> gsm = |
| 985 | RfDesenseTxTestGsm::get_instance(); |
| 986 | gsm->show_default(); |
| 987 | } else if (standard == sub_tx_test[INDEX_TDSCDMA].name) { |
| 988 | //"TDSCDMA" |
| 989 | std::shared_ptr<RfDesenseTxTestTd> tdscdma = std::make_shared< |
| 990 | RfDesenseTxTestTd>(utils::MODEM_TDSCDMA); |
| 991 | tdscdma->show_default(); |
| 992 | } else if (standard == sub_tx_test[INDEX_WCDMA].name) { |
| 993 | //"WCDMA" |
| 994 | std::shared_ptr<RfDesenseTxTestTd> wcdma = std::make_shared< |
| 995 | RfDesenseTxTestTd>(utils::MODEM_WCDMA); |
| 996 | wcdma->show_default(); |
| 997 | } else if (standard == sub_tx_test[INDEX_LTE_FDD].name) { |
| 998 | //LTE(FDD) |
| 999 | std::shared_ptr<RfDesenseTxTestLte> fdd = std::make_shared< |
| 1000 | RfDesenseTxTestLte>(utils::MODEM_LTE_FDD); |
| 1001 | fdd->show_default(); |
| 1002 | } else if (standard == sub_tx_test[INDEX_LTE_TDD].name) { |
| 1003 | //LTE(TDD) |
| 1004 | std::shared_ptr<RfDesenseTxTestLte> tdd = std::make_shared< |
| 1005 | RfDesenseTxTestLte>(utils::MODEM_LTE_TDD); |
| 1006 | tdd->show_default(); |
| 1007 | } else if ((standard == sub_tx_test[INDEX_CDMA_EVDO].name) |
| 1008 | && utils::isC2KSupport()) { |
| 1009 | //CDMA(EVDO) |
| 1010 | std::shared_ptr<RfDesenseTxTestCdma> evdo = std::make_shared< |
| 1011 | RfDesenseTxTestCdma>(utils::MODEM_CDMA_EVDO); |
| 1012 | evdo->show_default(); |
| 1013 | } else if ((standard == sub_tx_test[INDEX_CDMA_1X].name) |
| 1014 | && utils::isC2KSupport()) { |
| 1015 | //CDMA(1X) |
| 1016 | std::shared_ptr<RfDesenseTxTestCdma> cdma_1x = std::make_shared< |
| 1017 | RfDesenseTxTestCdma>(utils::MODEM_CDMA_1X); |
| 1018 | cdma_1x->show_default(); |
| 1019 | } else { |
| 1020 | LOG_D(LOG_TAG, "invaild INPUT"); |
| 1021 | return false; |
| 1022 | } |
| 1023 | return true; |
| 1024 | } |
| 1025 | |
| 1026 | bool RfDesenseTxTest::handle_para(int len, int classid, int propertyid,int operatorid, const std::string& standard, int* item) { |
| 1027 | if (len < 5) { |
| 1028 | LOG_D(LOG_TAG, "logic error"); |
| 1029 | return false; |
| 1030 | } |
| 1031 | LOG_D(LOG_TAG, "len: %d, classid: %d, propertyid: %d, operatorid: %d, standard: %s", len, classid,propertyid, operatorid, standard.c_str()); |
| 1032 | int name_pos = item[3]; |
| 1033 | int last_pos = item[4]; |
| 1034 | std::string name = |
| 1035 | desense_test[classid].subarray[propertyid].subarray[operatorid].subarray[name_pos].name; |
| 1036 | std::string sub_name = |
| 1037 | desense_test[classid].subarray[propertyid].subarray[operatorid].subarray[name_pos].subarray[last_pos].name; |
| 1038 | LOG_D(LOG_TAG, "name_pos: %d, last_pos: %d, name: %s, sub_name: %s", name_pos, last_pos,name.c_str(), sub_name.c_str()); |
| 1039 | if (standard == sub_tx_test[INDEX_GSM].name) { |
| 1040 | //"GSM" |
| 1041 | handle_gsm_para(name, last_pos, sub_name); |
| 1042 | } else if (standard == sub_tx_test[INDEX_TDSCDMA].name) { |
| 1043 | //"TDSCDMA" |
| 1044 | handle_tdscdma_para(name, last_pos, sub_name); |
| 1045 | } else if (standard == sub_tx_test[INDEX_WCDMA].name) { |
| 1046 | //"WCDMA" |
| 1047 | handle_wcdma_para(name, last_pos, sub_name); |
| 1048 | } else if (standard == sub_tx_test[INDEX_LTE_FDD].name) { |
| 1049 | //LTE(FDD) |
| 1050 | handle_lte_fdd_para(name, last_pos, sub_name); |
| 1051 | } else if (standard == sub_tx_test[INDEX_LTE_TDD].name) { |
| 1052 | //LTE(TDD) |
| 1053 | handle_lte_tdd_para(name, last_pos, sub_name); |
| 1054 | } else if ((standard == sub_tx_test[INDEX_CDMA_EVDO].name) |
| 1055 | && utils::isC2KSupport()) { |
| 1056 | //CDMA(EVDO) |
| 1057 | handle_cdma_evdo_para(name, last_pos, sub_name); |
| 1058 | } else if ((standard == sub_tx_test[INDEX_CDMA_1X].name) |
| 1059 | && utils::isC2KSupport()) { |
| 1060 | //CDMA(1X) |
| 1061 | handle_cdma_1X_para(name, last_pos, sub_name); |
| 1062 | } else { |
| 1063 | LOG_D(LOG_TAG, "invaild INPUT"); |
| 1064 | return false; |
| 1065 | } |
| 1066 | return true; |
| 1067 | } |
| 1068 | |
| 1069 | bool RfDesenseTxTest::handle_start(const std::string& standard) { |
| 1070 | //start |
| 1071 | mState = STATE_STARTED; |
| 1072 | if (standard == sub_tx_test[INDEX_GSM].name) { |
| 1073 | //"GSM" |
| 1074 | mRatList[INDEX_GSM]->setRatCheckState(true); |
| 1075 | } else if (standard == sub_tx_test[INDEX_TDSCDMA].name) { |
| 1076 | //"TDSCDMA" |
| 1077 | mRatList[INDEX_TDSCDMA]->setRatCheckState(true); |
| 1078 | } else if (standard == sub_tx_test[INDEX_WCDMA].name) { |
| 1079 | //"WCDMA" |
| 1080 | mRatList[INDEX_WCDMA]->setRatCheckState(true); |
| 1081 | } else if (standard == sub_tx_test[INDEX_LTE_FDD].name) { |
| 1082 | //LTE(FDD) |
| 1083 | mRatList[INDEX_LTE_FDD]->setRatCheckState(true); |
| 1084 | } else if (standard == sub_tx_test[INDEX_LTE_TDD].name) { |
| 1085 | //LTE(TDD) |
| 1086 | mRatList[INDEX_LTE_TDD]->setRatCheckState(true); |
| 1087 | } else if ((standard == sub_tx_test[INDEX_CDMA_EVDO].name) |
| 1088 | && utils::isC2KSupport()) { |
| 1089 | //CDMA(EVDO) |
| 1090 | mRatList[INDEX_CDMA_EVDO]->setRatCheckState(true); |
| 1091 | } else if ((standard == sub_tx_test[INDEX_CDMA_1X].name) |
| 1092 | && utils::isC2KSupport()) { |
| 1093 | //CDMA(1X) |
| 1094 | mRatList[INDEX_CDMA_1X]->setRatCheckState(true); |
| 1095 | } else { |
| 1096 | LOG_D(LOG_TAG, "invaild INPUT"); |
| 1097 | return false; |
| 1098 | } |
| 1099 | return true; |
| 1100 | } |
| 1101 | |
| 1102 | int RfDesenseTxTest::emRfDesenseStart(int len,int *item,int multilen,char *value[]) { |
| 1103 | LOG_D(LOG_TAG,"emRfDesenseStart called"); |
| 1104 | update_rat(); |
| 1105 | if (len < 3) { |
| 1106 | LOG_D(LOG_TAG, "please select redesense get or set"); |
| 1107 | return -1; |
| 1108 | } |
| 1109 | int classid = item[0]; |
| 1110 | int propertyid = item[1]; |
| 1111 | int operatorid = item[2]; |
| 1112 | mCurrentSettingsValues.clear(); |
| 1113 | for(int i = 0; i < multilen; i++ ) { |
| 1114 | mCurrentSettingsValues.push_back(value[i]); |
| 1115 | LOG_D(LOG_TAG, "value[%d]: %s", i, value[i]); |
| 1116 | } |
| 1117 | LOG_D(LOG_TAG, "mCurrentSettingsValues size: " + mCurrentSettingsValues.size()); |
| 1118 | em_arry_t *subarry = &(desense_test[classid].subarray[propertyid]); |
| 1119 | std::string standard = subarry->name; |
| 1120 | LOG_D(LOG_TAG,"rfdesense property name: %s, operatorid: %d",subarry->name, operatorid); |
| 1121 | switch (operatorid) { |
| 1122 | case 0: { //start |
| 1123 | str_msg = ""; |
| 1124 | if(!handle_start(standard)) return -1; |
| 1125 | //emEnableRadio(false); |
| 1126 | registerOnUnsolOemHookRaw(m_instance); |
| 1127 | register_response_oem_hook_raw(m_instance); |
| 1128 | std::thread thread_start(&RfDesenseTxTest::emRfDesenseThread, m_instance, operatorid); |
| 1129 | thread_start.detach(); |
| 1130 | break; |
| 1131 | } |
| 1132 | case 1: { |
| 1133 | if(!handle_para(len, classid, propertyid, operatorid, standard, item)) return -1; |
| 1134 | break; |
| 1135 | } |
| 1136 | case 2: { //show default |
| 1137 | if(!handle_show_default(standard)) return -1; |
| 1138 | break; |
| 1139 | } |
| 1140 | default: |
| 1141 | LOG_D(LOG_TAG, "logic eror "); |
| 1142 | return -1; |
| 1143 | } |
| 1144 | return (0); |
| 1145 | } |
| 1146 | |
| 1147 | std::shared_ptr<RfDesenseRatInfo> RfDesenseTxTest::getCurrectRatInfo() { |
| 1148 | int index; |
| 1149 | for (index = 0; index < mRatList.size(); index++) { |
| 1150 | if (mRatList[index]->getRatCheckState()) { |
| 1151 | if (mRatList[index]->getRatSendState()) { |
| 1152 | continue; |
| 1153 | } |
| 1154 | mCurrectRatInfo = mRatList[index]; |
| 1155 | break; |
| 1156 | } |
| 1157 | } |
| 1158 | return mCurrectRatInfo; |
| 1159 | } |
| 1160 | |
| 1161 | void RfDesenseTxTest::turnOffRf(){ |
| 1162 | LOG_D(LOG_TAG, "turn off rf...."); |
| 1163 | mIsModemNotEnabled = false; |
| 1164 | emEnableRadio(false, phone_id); |
| 1165 | if(utils::is_support_dsds()){ |
| 1166 | emEnableRadio(false, phone_id == 0? 1:0); |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | void RfDesenseTxTest::turnOnRf() { |
| 1171 | LOG_D(LOG_TAG, "turn on rf...."); |
| 1172 | mIsModemEnabled = false; |
| 1173 | emEnableRadio(true, phone_id); |
| 1174 | if(utils::is_support_dsds()){ |
| 1175 | emEnableRadio(true, phone_id == 0? 1:0); |
| 1176 | } |
| 1177 | } |
| 1178 | |
| 1179 | void RfDesenseTxTest::initRatList() { |
| 1180 | phone_id = Radio_capability_switch_util::get_main_capability_phone_id(); |
| 1181 | mState = STATE_NONE; |
| 1182 | if(!utils::is93Modem()){ |
| 1183 | mRatCmdStart[5] = DEFAULT_CDMA_EVDO_ATCMD_93before; |
| 1184 | mRatCmdStop[5] = "AT+ECRFTX=0"; |
| 1185 | } |
| 1186 | |
| 1187 | if(utils::is90Modem()) { |
| 1188 | mRatCmdSwitch[5] = "AT^PREFMODE=4"; |
| 1189 | mRatCmdSwitch[6] = "AT^EIRATMODE=2"; |
| 1190 | } |
| 1191 | for (int i = 0; i < mRatName.size(); i++) { |
| 1192 | std::shared_ptr<RfDesenseRatInfo> Info = std::make_shared<RfDesenseRatInfo>(); |
| 1193 | Info->setRatName(mRatName[i]); |
| 1194 | Info->setRatCmdStart(mRatCmdStart[i]); |
| 1195 | Info->setRatCmdStop(mRatCmdStop[i]); |
| 1196 | Info->setRatCmdSwitch(mRatCmdSwitch[i]); |
| 1197 | Info->setRatPowerRead(mRatCmdPowerRead[i]); |
| 1198 | Info->setRatband(mRatBand[i]); |
| 1199 | Info->setRatPowerSet(mRatPowerSet[i]); |
| 1200 | Info->setRatCheckState(false); |
| 1201 | Info->setRatSendState(false); |
| 1202 | mRatList.push_back(Info); |
| 1203 | if(!(utils::isC2KSupport())){ |
| 1204 | if (i == 4) { |
| 1205 | break; |
| 1206 | } |
| 1207 | } |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | void RfDesenseTxTest::update_rat() { |
| 1212 | for(int i=0; i < mRatList.size(); i++){ |
| 1213 | mRatList[i]->setRatName(mRatName[i]); |
| 1214 | mRatList[i]->setRatCmdStart(mRatCmdStart[i]); |
| 1215 | mRatList[i]->setRatCmdStop(mRatCmdStop[i]); |
| 1216 | mRatList[i]->setRatCmdSwitch(mRatCmdSwitch[i]); |
| 1217 | mRatList[i]->setRatPowerRead(mRatCmdPowerRead[i]); |
| 1218 | mRatList[i]->setRatband(mRatBand[i]); |
| 1219 | mRatList[i]->setRatPowerSet(mRatPowerSet[i]); |
| 1220 | mRatList[i]->setRatCheckState(false); |
| 1221 | mRatList[i]->setRatSendState(false); |
| 1222 | if(!(utils::isC2KSupport())){ |
| 1223 | if (i == 4) { |
| 1224 | break; |
| 1225 | } |
| 1226 | } |
| 1227 | } |
| 1228 | } |
| 1229 | void RfDesenseTxTest::save(int index) { |
| 1230 | mRatCmdStart[index] = mRatList[index]->getRatCmdStart(); |
| 1231 | mRatBand[index] = mRatList[index]->getRatband(); |
| 1232 | mRatPowerSet[index] = mRatList[index]->getRatPowerSet(); |
| 1233 | } |