• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "bundle_event_callback_death_recipient.h"
17 
18 #include "app_log_wrapper.h"
19 #include "bundle_mgr_service.h"
20 #include "bundle_event_callback_interface.h"
21 #include "singleton.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
BundleEventCallbackDeathRecipient()25 BundleEventCallbackDeathRecipient::BundleEventCallbackDeathRecipient()
26 {
27     APP_LOGD("create BundleEventCallbackDeathRecipient");
28 }
29 
~BundleEventCallbackDeathRecipient()30 BundleEventCallbackDeathRecipient::~BundleEventCallbackDeathRecipient()
31 {
32     APP_LOGD("destroy BundleEventCallbackDeathRecipient");
33 }
34 
OnRemoteDied(const wptr<IRemoteObject> & remote)35 void BundleEventCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
36 {
37     APP_LOGD("bundle event service died, remove the proxy object");
38     sptr<IBundleEventCallback> callback = iface_cast<IBundleEventCallback>(remote.promote());
39     if (callback == nullptr) {
40         APP_LOGE("callback is nullptr");
41         return;
42     }
43     auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
44     if (dataMgr == nullptr) {
45         APP_LOGE("DataMgr is nullptr");
46         return;
47     }
48     dataMgr->UnregisterBundleEventCallback(callback);
49 }
50 }  // namespace AppExecFwk
51 }  // namespace OHOS
52