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 "set_radio_state_callback.h" 17 18 #include "telephony_errors.h" 19 #include "telephony_log_wrapper.h" 20 #include "telephony_napi_hril_error_code.h" 21 22 namespace OHOS { 23 namespace Telephony { SetRadioStateCallback(SwitchRadioContext * context)24SetRadioStateCallback::SetRadioStateCallback(SwitchRadioContext *context) : asyncContext_(context) {} 25 OnSetRadioStateCallback(const bool setResult,const int32_t errorCode)26void SetRadioStateCallback::OnSetRadioStateCallback(const bool setResult, const int32_t errorCode) 27 { 28 if (asyncContext_ == nullptr) { 29 TELEPHONY_LOGE("OnSetRadioStateCallback asyncContext null"); 30 return; 31 } 32 std::unique_lock<std::mutex> callbackLock(asyncContext_->callbackMutex); 33 TELEPHONY_LOGI("OnSetRadioStateCallback setResult = %{public}d", setResult); 34 asyncContext_->resolved = (errorCode == HRIL_ERR_REPEAT_STATUS) || 35 ((errorCode == HRIL_ERR_SUCCESS) && setResult); 36 if (!asyncContext_->resolved) { 37 asyncContext_->errorCode = TELEPHONY_ERR_RIL_CMD_FAIL; 38 } 39 asyncContext_->callbackEnd = true; 40 asyncContext_->cv.notify_all(); 41 TELEPHONY_LOGI("OnSetRadioStateCallback end"); 42 } 43 } // namespace Telephony 44 } // namespace OHOS