1 /* 2 * Copyright (C) 2022 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 "nfc_controller_death_recipient.h" 17 #include "loghelper.h" 18 #include "nfc_sdk_common.h" 19 20 namespace OHOS { 21 namespace NFC { NfcControllerDeathRecipient(sptr<NfcControllerStub> nfcConctrolService,Security::AccessToken::AccessTokenID callerToken)22NfcControllerDeathRecipient::NfcControllerDeathRecipient( 23 sptr<NfcControllerStub> nfcConctrolService, Security::AccessToken::AccessTokenID callerToken) 24 { 25 nfcConctrolService_ = nfcConctrolService; 26 callerToken_ = callerToken; 27 } 28 OnRemoteDied(const wptr<IRemoteObject> & remote)29void NfcControllerDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote) 30 { 31 if (nfcConctrolService_ == nullptr) { 32 ErrorLog("NfcControllerDeathRecipient nfcConctrolService_ is nullptr!"); 33 return; 34 } 35 std::lock_guard<std::mutex> lock(mutex_); 36 KITS::ErrorCode ret = nfcConctrolService_->UnRegisterAllCallBack(callerToken_); 37 InfoLog("OnRemoteDied, UnRegisterAllCallBack##ret=%{public}d\n", ret); 38 nfcConctrolService_->RemoveNfcDeathRecipient(remote); 39 } 40 } // namespace NFC 41 } // namespace OHOS