1 /*
2  * Copyright (c) 2021-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 "ability_death_recipient.h"
17 
18 #include "iremote_proxy.h"
19 #include "sam_log.h"
20 #include "system_ability_manager.h"
21 
22 namespace OHOS {
OnRemoteDied(const wptr<IRemoteObject> & remote)23 void AbilityDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
24 {
25     HILOGD("AbilityDeathRecipient OnRemoteDied called");
26     SystemAbilityManager::GetInstance()->RemoveSystemAbility(remote.promote());
27     HILOGD("AbilityDeathRecipients death notice success");
28 }
29 
OnRemoteDied(const wptr<IRemoteObject> & remote)30 void SystemProcessDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
31 {
32     HILOGD("SystemProcessDeathRecipient called!");
33     SystemAbilityManager::GetInstance()->RemoveSystemProcess(remote.promote());
34     HILOGD("SystemProcessDeathRecipient death notice success");
35 }
36 
OnRemoteDied(const wptr<IRemoteObject> & remote)37 void AbilityStatusDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
38 {
39     HILOGD("AbilityStatusDeathRecipient called!");
40     SystemAbilityManager::GetInstance()->UnSubscribeSystemAbility(remote.promote());
41     HILOGD("AbilityStatusDeathRecipient death notice success");
42 }
43 
OnRemoteDied(const wptr<IRemoteObject> & remote)44 void AbilityCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
45 {
46     HILOGD("AbilityCallbackDeathRecipient called!");
47     SystemAbilityManager::GetInstance()->OnAbilityCallbackDied(remote.promote());
48     HILOGD("AbilityCallbackDeathRecipient death notice success");
49 }
50 
OnRemoteDied(const wptr<IRemoteObject> & remote)51 void RemoteCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
52 {
53     HILOGD("RemoteCallbackDeathRecipient called!");
54     SystemAbilityManager::GetInstance()->OnRemoteCallbackDied(remote.promote());
55     HILOGD("RemoteCallbackDeathRecipient death notice success");
56 }
57 
OnRemoteDied(const wptr<IRemoteObject> & remote)58 void SystemProcessListenerDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
59 {
60     HILOGD("SystemProcessListenerDeathRecipient called!");
61     sptr<ISystemProcessStatusChange> listener = iface_cast<ISystemProcessStatusChange>(remote.promote());
62     SystemAbilityManager::GetInstance()->UnSubscribeSystemProcess(listener);
63     HILOGD("SystemProcessListenerDeathRecipient death notice success");
64 }
65 } // namespace OHOS
66