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 "bundle_death_recipient.h" 17 18 #include "appexecfwk_errors.h" 19 #include "app_log_wrapper.h" 20 #include "status_receiver_interface.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 namespace { 25 const std::string STRING_FAIL = "[BUNDLER_MANAGER_SERVICE_UNAVAILABLE]"; 26 } BundleDeathRecipient(const sptr<StatusReceiverHost> & statusReceiver,const sptr<QuickFixStatusCallbackHost> & callback)27BundleDeathRecipient::BundleDeathRecipient(const sptr<StatusReceiverHost> &statusReceiver, 28 const sptr<QuickFixStatusCallbackHost> &callback) : statusReceiver_(statusReceiver), quickFixCallback_(callback) 29 { 30 } 31 ~BundleDeathRecipient()32BundleDeathRecipient::~BundleDeathRecipient() 33 { 34 statusReceiver_ = nullptr; 35 quickFixCallback_ = nullptr; 36 } 37 38 void BundleDeathRecipient::OnRemoteDied([[maybe_unused]] const wptr<IRemoteObject> &remote) 39 { 40 APP_LOGE("BundleManagerService is died"); 41 if (statusReceiver_ != nullptr) { 42 APP_LOGD("call installer callback"); 43 statusReceiver_->OnFinished(IStatusReceiver::ERR_FAILED_SERVICE_DIED, STRING_FAIL); 44 } 45 #ifdef BUNDLE_FRAMEWORK_QUICK_FIX 46 if (quickFixCallback_ != nullptr) { 47 APP_LOGD("call quickFix callback"); 48 std::shared_ptr<QuickFixResult> deployRes = std::make_shared<DeployQuickFixResult>(); 49 deployRes->SetResCode(ERR_APPEXECFWK_FAILED_SERVICE_DIED); 50 quickFixCallback_->OnPatchDeployed(deployRes); 51 } 52 #endif 53 return; 54 } 55 } // namespace AppExecFwk 56 } // namespace OHOS