1 /*
2 * Copyright (c) 2022-2024 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 "callback_death_recipients.h"
17
18 #include "access_token.h"
19 #include "callback_manager.h"
20 #ifdef TOKEN_SYNC_ENABLE
21 #include "token_modify_notifier.h"
22 #endif // TOKEN_SYNC_ENABLE
23
24 namespace OHOS {
25 namespace Security {
26 namespace AccessToken {
27
OnRemoteDied(const wptr<IRemoteObject> & remote)28 void PermStateCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
29 {
30 LOGI(ATM_DOMAIN, ATM_TAG, "Enter");
31 if (remote == nullptr) {
32 LOGE(ATM_DOMAIN, ATM_TAG, "Remote object is nullptr");
33 return;
34 }
35
36 sptr<IRemoteObject> object = remote.promote();
37 if (object == nullptr) {
38 LOGE(ATM_DOMAIN, ATM_TAG, "Object is nullptr");
39 return;
40 }
41 CallbackManager::GetInstance().RemoveCallback(object);
42 LOGI(ATM_DOMAIN, ATM_TAG, "End");
43 }
44
45 #ifdef TOKEN_SYNC_ENABLE
OnRemoteDied(const wptr<IRemoteObject> & remote)46 void TokenSyncCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
47 {
48 LOGI(ATM_DOMAIN, ATM_TAG, "Call OnRemoteDied.");
49 if (remote == nullptr) {
50 LOGE(ATM_DOMAIN, ATM_TAG, "Remote object is nullptr.");
51 return;
52 }
53 TokenModifyNotifier::GetInstance().UnRegisterTokenSyncCallback();
54 LOGI(ATM_DOMAIN, ATM_TAG, "Call UnRegisterTokenSyncCallback end.");
55 }
56 #endif // TOKEN_SYNC_ENABLE
57 } // namespace AccessToken
58 } // namespace Security
59 } // namespace OHOS
60