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 "dbinder_sa_death_recipient.h"
17 #include "dbinder_service.h"
18 #include "dbinder_log.h"
19 #include "ISessionService.h"
20 #include "log_tags.h"
21
22 namespace OHOS {
23 using Communication::SoftBus::ISessionService;
24
25 static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = { LOG_CORE, LOG_ID_RPC, "DbinderSaDeathRecipient" };
26
DbinderSaDeathRecipient(binder_uintptr_t binderObject)27 DbinderSaDeathRecipient::DbinderSaDeathRecipient(binder_uintptr_t binderObject) : binderObject_(binderObject)
28 {
29 }
30
OnRemoteDied(const wptr<IRemoteObject> & remote)31 void DbinderSaDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
32 {
33 DBINDER_LOGE(LOG_LABEL, "DbinderSaDeathRecipient OnRemoteDied");
34 if (remote == nullptr) {
35 DBINDER_LOGE(LOG_LABEL, "remote object is null");
36 return;
37 }
38
39 sptr<DBinderService> dBinderService = DBinderService::GetInstance();
40 if (dBinderService == nullptr) {
41 DBINDER_LOGE(LOG_LABEL, "dBinderService is null");
42 return;
43 }
44 (void)dBinderService->DetachProxyObject(binderObject_);
45 }
46 } // namespace OHOS
47