diff --git a/interfaces/inner_api/app_manager/include/appmgr/process_bind_data.h b/interfaces/inner_api/app_manager/include/appmgr/process_bind_data.h index c75d9c61da..45015abdb0 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/process_bind_data.h +++ b/interfaces/inner_api/app_manager/include/appmgr/process_bind_data.h @@ -29,7 +29,7 @@ struct UIExtensionProcessBindInfo { int32_t pid = 0; int32_t uid = 0; bool isKeepAlive = false; - ProcessType processType = ProcessType::NORMAL; + ProcessType processType = ProcessType::EXTENSION; ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED; int32_t callerPid = -1; int32_t callerUid = -1; @@ -66,7 +66,7 @@ struct ProcessBindData : public Parcelable { int32_t pid = 0; int32_t uid = 0; bool isKeepAlive = false; - ProcessType processType = ProcessType::NORMAL; + ProcessType processType = ProcessType::EXTENSION; ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED; int32_t callerPid = -1; int32_t callerUid = -1; diff --git a/interfaces/inner_api/app_manager/src/appmgr/application_state_observer_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/application_state_observer_proxy.cpp index 4ea43e3bfb..33731b0d52 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/application_state_observer_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/application_state_observer_proxy.cpp @@ -401,10 +401,11 @@ void ApplicationStateObserverProxy::OnProcessBindingRelationChanged(const Proces MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); return; } if (!data.WriteParcelable(&processBindData)) { - TAG_LOGE(AAFwkTag::APPMGR, "write processData failed"); + TAG_LOGE(AAFwkTag::APPMGR, "Write processData failed"); return; } int32_t ret = SendTransactCmd( diff --git a/interfaces/inner_api/app_manager/src/appmgr/process_bind_data.cpp b/interfaces/inner_api/app_manager/src/appmgr/process_bind_data.cpp index cdbad45a5f..b4036d8ccf 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/process_bind_data.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/process_bind_data.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2025 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,13 +23,10 @@ namespace OHOS { namespace AppExecFwk { bool ProcessBindData::Marshalling(Parcel &parcel) const { - return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) && - parcel.WriteInt32(uid) && parcel.WriteBool(isKeepAlive) && - parcel.WriteInt32(static_cast(processType)) && - parcel.WriteInt32(static_cast(extensionType)) && - parcel.WriteInt32(callerPid) && parcel.WriteInt32(callerUid) && - parcel.WriteString(callerBundleName) && - parcel.WriteInt32(bindingRelation)); + return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) && parcel.WriteInt32(uid) && + parcel.WriteBool(isKeepAlive) && parcel.WriteInt32(static_cast(processType)) && + parcel.WriteInt32(static_cast(extensionType)) && parcel.WriteInt32(callerPid) && + parcel.WriteInt32(callerUid) && parcel.WriteString(callerBundleName) && parcel.WriteInt32(bindingRelation)); } bool ProcessBindData::ReadFromParcel(Parcel &parcel) @@ -51,8 +48,7 @@ ProcessBindData *ProcessBindData::Unmarshalling(Parcel &parcel) { ProcessBindData *processBindData = new (std::nothrow) ProcessBindData(); if (processBindData && !processBindData->ReadFromParcel(parcel)) { - TAG_LOGW(AAFwkTag::APPMGR, - "processBindData failed, because ReadFromParcel failed"); + TAG_LOGW(AAFwkTag::APPMGR, "processBindData failed, because ReadFromParcel failed"); delete processBindData; processBindData = nullptr; } diff --git a/services/abilitymgr/include/ability_connect_manager.h b/services/abilitymgr/include/ability_connect_manager.h index bb7b93c35d..4108f5ebe0 100644 --- a/services/abilitymgr/include/ability_connect_manager.h +++ b/services/abilitymgr/include/ability_connect_manager.h @@ -670,8 +670,8 @@ private: bool NeedExtensionControl(std::shared_ptr abilityRecord); bool GetTimeoutMsgContent(uint32_t msgId, std::string &msgContent, int &typeId); - void UpdateUIExtensionBindInfo(const std::shared_ptr &abilityRecord, - std::string callerBundleName, int32_t notifyProcessBind); + void UpdateUIExtensionBindInfo( + const std::shared_ptr &abilityRecord, std::string callerBundleName, int32_t notifyProcessBind); private: const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask"; const std::string TASK_ON_ABILITY_DIED = "OnAbilityDiedTask"; diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 7e27ca64d8..878585db67 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -232,8 +232,7 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque } }; UpdateUIExtensionBindInfo( - targetService, hostBundleName, - abilityRequest.want.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1)); + targetService, hostBundleName, abilityRequest.want.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1)); LoadAbility(targetService, updateRecordCallback); } else if (targetService->IsAbilityState(AbilityState::ACTIVE) && !IsUIExtensionAbility(targetService)) { // It may have been started through connect @@ -577,8 +576,7 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest & } }; UpdateUIExtensionBindInfo( - targetService, hostBundleName, - abilityRequest.want.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1)); + targetService, hostBundleName, abilityRequest.want.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1)); LoadAbility(targetService, updateRecordCallback); return ERR_OK; } @@ -3604,22 +3602,17 @@ void AbilityConnectManager::UpdateUIExtensionBindInfo( if (abilityRecord == nullptr || !UIExtensionUtils::IsUIExtension( abilityRecord->GetAbilityInfo().extensionAbilityType)) { - TAG_LOGE(AAFwkTag::UI_EXT, "record null or type error"); + TAG_LOGE(AAFwkTag::UI_EXT, "record null or abilityType not match"); return; } WantParams wantParams; auto uiExtensionBindAbilityId = abilityRecord->GetUIExtensionAbilityId(); - wantParams.SetParam(UIEXTENSION_BIND_ABILITY_ID, - AAFwk::Integer::Box(uiExtensionBindAbilityId)); - wantParams.SetParam(UIEXTENSION_NOTIFY_BIND, - AAFwk::Integer::Box(notifyProcessBind)); - wantParams.SetParam(UIEXTENSION_HOST_PID, - AAFwk::Integer::Box(IPCSkeleton::GetCallingPid())); - wantParams.SetParam(UIEXTENSION_HOST_UID, - AAFwk::Integer::Box(IPCSkeleton::GetCallingUid())); - wantParams.SetParam(UIEXTENSION_HOST_BUNDLENAME, - String ::Box(callerBundleName)); + wantParams.SetParam(UIEXTENSION_BIND_ABILITY_ID, AAFwk::Integer::Box(uiExtensionBindAbilityId)); + wantParams.SetParam(UIEXTENSION_NOTIFY_BIND, AAFwk::Integer::Box(notifyProcessBind)); + wantParams.SetParam(UIEXTENSION_HOST_PID, AAFwk::Integer::Box(IPCSkeleton::GetCallingPid())); + wantParams.SetParam(UIEXTENSION_HOST_UID, AAFwk::Integer::Box(IPCSkeleton::GetCallingUid())); + wantParams.SetParam(UIEXTENSION_HOST_BUNDLENAME, String ::Box(callerBundleName)); abilityRecord->UpdateUIExtensionBindInfo(wantParams); } } // namespace AAFwk diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index c6a5d713a3..bd39f025d6 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -3859,6 +3859,7 @@ void AbilityRecord::NotifyAbilityRequestSuccess(const std::string &requestId, co void AbilityRecord::UpdateUIExtensionBindInfo(const WantParams &wantParams) { if (!UIExtensionUtils::IsUIExtension(GetAbilityInfo().extensionAbilityType)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityType not match"); return; } @@ -3866,30 +3867,27 @@ void AbilityRecord::UpdateUIExtensionBindInfo(const WantParams &wantParams) if (want_.HasParameter(UIEXTENSION_BIND_ABILITY_ID)) { want_.RemoveParam(UIEXTENSION_BIND_ABILITY_ID); } - want_.SetParam(UIEXTENSION_BIND_ABILITY_ID, - wantParams.GetIntParam(UIEXTENSION_BIND_ABILITY_ID, -1)); + want_.SetParam(UIEXTENSION_BIND_ABILITY_ID, wantParams.GetIntParam(UIEXTENSION_BIND_ABILITY_ID, -1)); if (want_.HasParameter(UIEXTENSION_NOTIFY_BIND)) { want_.RemoveParam(UIEXTENSION_NOTIFY_BIND); } - want_.SetParam(UIEXTENSION_NOTIFY_BIND, - wantParams.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1)); + want_.SetParam(UIEXTENSION_NOTIFY_BIND, wantParams.GetIntParam(UIEXTENSION_NOTIFY_BIND, -1)); + if (want_.HasParameter(UIEXTENSION_HOST_PID)) { want_.RemoveParam(UIEXTENSION_HOST_PID); } - want_.SetParam(UIEXTENSION_HOST_PID, - wantParams.GetIntParam(UIEXTENSION_HOST_PID, -1)); + want_.SetParam(UIEXTENSION_HOST_PID, wantParams.GetIntParam(UIEXTENSION_HOST_PID, -1)); if (want_.HasParameter(UIEXTENSION_HOST_UID)) { want_.RemoveParam(UIEXTENSION_HOST_UID); } - want_.SetParam(UIEXTENSION_HOST_UID, - wantParams.GetIntParam(UIEXTENSION_HOST_UID, -1)); + want_.SetParam(UIEXTENSION_HOST_UID, wantParams.GetIntParam(UIEXTENSION_HOST_UID, -1)); + if (want_.HasParameter(UIEXTENSION_HOST_BUNDLENAME)) { want_.RemoveParam(UIEXTENSION_HOST_BUNDLENAME); } - want_.SetParam(UIEXTENSION_HOST_BUNDLENAME, - wantParams.GetStringParam(UIEXTENSION_HOST_BUNDLENAME)); + want_.SetParam(UIEXTENSION_HOST_BUNDLENAME, wantParams.GetStringParam(UIEXTENSION_HOST_BUNDLENAME)); } } // namespace AAFwk } // namespace OHOS diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 165e393675..e671be3d11 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1978,14 +1978,14 @@ private: void SendAppSpawnUninstallDebugHapMsg(int32_t userId); std::shared_ptr CreateAppRunningRecord(std::shared_ptr appInfo, const std::string &processName, const BundleInfo &bundleInfo); - void AddUIExtensionBindItem(std::shared_ptr want, std::shared_ptr appRecord, - sptr token); + void AddUIExtensionBindItem( + std::shared_ptr want, std::shared_ptr appRecord, sptr token); void RemoveUIExtensionBindItem(std::shared_ptr appRecord, sptr token); - void BindUIExtensionProcess(const std::shared_ptr &appRecord, - const UIExtensionProcessBindInfo &bindInfo); - void UnBindUIExtensionProcess(const std::shared_ptr &appRecord, - const UIExtensionProcessBindInfo &bindInfo); - + void BindUIExtensionProcess( + const std::shared_ptr &appRecord, const UIExtensionProcessBindInfo &bindInfo); + void UnBindUIExtensionProcess(const std::shared_ptr &appRecord, const UIExtensionProcessBindInfo &bindInfo); + bool WrapBindInfo(std::shared_ptr &want, std::shared_ptr &appRecord, + UIExtensionProcessBindInfo &bindInfo); bool isInitAppWaitingDebugListExecuted_ = false; std::atomic sceneBoardAttachFlag_ = true; std::atomic willKillPidsNum_ = 0; diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index 5b488ae019..159e730593 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -375,8 +375,6 @@ public: void UpdateInstanceKeyBySpecifiedId(int32_t specifiedId, std::string &instanceKey); std::shared_ptr QueryAppRecordPlus(int32_t pid, int32_t uid); - UIExtensionProcessBindInfo WarpBindInfo(int32_t pid, int32_t uid, int32_t callerPid, int32_t callerUid, - std::string callerBundleName, int32_t notifyProcessBind); int32_t AddUIExtensionBindItem(int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo); int32_t QueryUIExtensionBindItemById(int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo); int32_t RemoveUIExtensionBindItemById(int32_t uiExtensionBindAbilityId); diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index e6cd7960ee..b01e9d14d0 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -9404,48 +9404,25 @@ int32_t AppMgrServiceInner::LaunchAbility(sptr token) } void AppMgrServiceInner::AddUIExtensionBindItem( - std::shared_ptr want, - std::shared_ptr appRecord, sptr token) + std::shared_ptr want, std::shared_ptr appRecord, sptr token) { + if (want == nullptr || appRecord == nullptr || token == nullptr || appRunningManager_ == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "invalid input params"); + return; + } + auto notifyProcessBind = want->GetIntParam(UIEXTENSION_NOTIFY_BIND, -1); if (notifyProcessBind != 1) { TAG_LOGE(AAFwkTag::APPMGR, "no bind permission"); return; } - if (want == nullptr || appRecord == nullptr || token == nullptr || - appRunningManager_ == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "invalid input params"); - return; - } - auto uiExtensionBindAbilityId = - want->GetIntParam(UIEXTENSION_BIND_ABILITY_ID, -1); - auto callerPid = want->GetIntParam(UIEXTENSION_HOST_PID, -1); - auto callerUid = want->GetIntParam(UIEXTENSION_HOST_UID, -1); - auto callerBundleName = want->GetStringParam(UIEXTENSION_HOST_BUNDLENAME); - pid_t providerPid = -1; - pid_t providerUid = -1; - if (appRecord->GetPriorityObject() != nullptr) { - providerPid = appRecord->GetPid(); - providerUid = appRecord->GetUid(); - } - if (uiExtensionBindAbilityId == -1 || providerPid == -1 || - providerUid == -1 || callerPid == -1 || callerUid == -1 || - callerBundleName.empty()) { - TAG_LOGE(AAFwkTag::APPMGR, "invalid want params"); - return; - } - TAG_LOGI(AAFwkTag::APPMGR, - "uiExtensionBindAbilityId: %{public}d, providerUid: " - "%{public}d,providerPid: %{public}d,callerUid: %{public}d, " - "callerPid: %{public}d,callerBundleName: %{public}s", - uiExtensionBindAbilityId, providerUid, providerPid, callerUid, - callerPid, callerBundleName.c_str()); - UIExtensionProcessBindInfo bindInfo = appRunningManager_->WarpBindInfo( - providerPid, providerUid, callerPid, callerUid, callerBundleName, - notifyProcessBind); - appRunningManager_->AddUIExtensionBindItem(uiExtensionBindAbilityId, - bindInfo); + UIExtensionProcessBindInfo bindInfo; + if(!WarpBindInfo(want, appRecord, bindInfo)){ + TAG_LOGE(AAFwkTag::APPMGR, "warp bindInfo fail"); + return; + } + appRunningManager_->AddUIExtensionBindItem(uiExtensionBindAbilityId, bindInfo); BindUIExtensionProcess(appRecord, bindInfo); want->RemoveParam(UIEXTENSION_HOST_PID); want->RemoveParam(UIEXTENSION_HOST_UID); @@ -9456,8 +9433,7 @@ void AppMgrServiceInner::AddUIExtensionBindItem( void AppMgrServiceInner::RemoveUIExtensionBindItem( std::shared_ptr appRecord, sptr token) { - if (appRecord == nullptr || token == nullptr || - appRunningManager_ == nullptr) { + if (appRecord == nullptr || token == nullptr || appRunningManager_ == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "invalid input params"); return; } @@ -9476,19 +9452,19 @@ void AppMgrServiceInner::RemoveUIExtensionBindItem( if (!AAFwk::UIExtensionUtils::IsUIExtension( abilityInfo->extensionAbilityType)) { + TAG_LOGE(AAFwkTag::APPMGR, "abilityType not match"); return; } - auto uiExtensionBindAbilityId = - abilityRunningRecord->GetUIExtensionBindAbilityId(); + auto uiExtensionBindAbilityId = abilityRunningRecord->GetUIExtensionBindAbilityId(); UIExtensionProcessBindInfo bindInfo; - auto result = appRunningManager_->QueryUIExtensionBindItemById( - uiExtensionBindAbilityId, bindInfo); + auto result = appRunningManager_->QueryUIExtensionBindItemById(uiExtensionBindAbilityId, bindInfo); if (result != ERR_OK) { + TAG_LOGE(AAFwkTag::APPMGR, "bindInfo not exist"); return; } if (bindInfo.notifyProcessBind != 1) { - TAG_LOGE(AAFwkTag::APPMGR, "no bind permission"); + TAG_LOGE(AAFwkTag::APPMGR, "no unbind permission"); return; } UnBindUIExtensionProcess(appRecord, bindInfo); @@ -9496,27 +9472,24 @@ void AppMgrServiceInner::RemoveUIExtensionBindItem( } void AppMgrServiceInner::BindUIExtensionProcess( - const std::shared_ptr &appRecord, - const UIExtensionProcessBindInfo &bindInfo) + const std::shared_ptr &appRecord, const UIExtensionProcessBindInfo &bindInfo) { std::lock_guard guard(uiExtensionBindReleationsLock_); auto pid = bindInfo.pid; auto callerPid = bindInfo.callerPid; auto it = uiExtensionBindReleations_.find(pid); - if (it == uiExtensionBindReleations_.end() || - it->second.find(callerPid) == it->second.end()) { + if (it == uiExtensionBindReleations_.end() || it->second.find(callerPid) == it->second.end()) { uiExtensionBindReleations_[pid][callerPid] = 1; - DelayedSingleton::GetInstance() - ->OnProcessBindingRelationChanged(appRecord, bindInfo, 1); + DelayedSingleton::GetInstance()->OnProcessBindingRelationChanged( + appRecord, bindInfo, 1); } else { it->second[callerPid]++; } } void AppMgrServiceInner::UnBindUIExtensionProcess( - const std::shared_ptr &appRecord, - const UIExtensionProcessBindInfo &bindInfo) + const std::shared_ptr &appRecord, const UIExtensionProcessBindInfo &bindInfo) { std::lock_guard guard(uiExtensionBindReleationsLock_); auto pid = bindInfo.pid; @@ -9529,8 +9502,8 @@ void AppMgrServiceInner::UnBindUIExtensionProcess( if (innerIt != innerMap.end()) { innerIt->second--; if (innerIt->second == 0) { - DelayedSingleton::GetInstance() - ->OnProcessBindingRelationChanged(appRecord, bindInfo, 0); + DelayedSingleton::GetInstance()->OnProcessBindingRelationChanged( + appRecord, bindInfo, 0); innerMap.erase(innerIt); } } @@ -9539,5 +9512,48 @@ void AppMgrServiceInner::UnBindUIExtensionProcess( } } } + +bool WrapBindInfo(std::shared_ptr &want, std::shared_ptr &appRecord, + UIExtensionProcessBindInfo &bindInfo) +{ + auto notifyProcessBind = want->GetIntParam(UIEXTENSION_NOTIFY_BIND, -1); + auto uiExtensionBindAbilityId = want->GetIntParam(UIEXTENSION_BIND_ABILITY_ID, -1); + auto callerPid = want->GetIntParam(UIEXTENSION_HOST_PID, -1); + auto callerUid = want->GetIntParam(UIEXTENSION_HOST_UID, -1); + auto callerBundleName = want->GetStringParam(UIEXTENSION_HOST_BUNDLENAME); + pid_t providerPid = -1; + pid_t providerUid = -1; + if (appRecord->GetPriorityObject() != nullptr) { + providerPid = appRecord->GetPid(); + providerUid = appRecord->GetUid(); + } + TAG_LOGI(AAFwkTag::APPMGR, + "uiExtensionBindAbilityId: %{public}d, providerUid: " + "%{public}d,providerPid: %{public}d,callerUid: %{public}d, " + "callerPid: %{public}d,callerBundleName: %{public}s", + uiExtensionBindAbilityId, + providerUid, + providerPid, + callerUid, + callerPid, + callerBundleName.c_str()); + if (uiExtensionBindAbilityId == -1 || providerPid == -1 || providerUid == -1 || callerPid == -1 || + callerUid == -1 || callerBundleName.empty()) { + TAG_LOGE(AAFwkTag::APPMGR, "invalid want params"); + return false; + } + bindInfo.pid = providerPid; + bindInfo.uid = providerUid; + bindInfo.callerPid = callerPid; + bindInfo.callerUid = callerUid; + bindInfo.callerBundleName = callerBundleName; + bindInfo.notifyProcessBind = notifyProcessBind; + bindInfo.isKeepAlive = notifyProcessBind; + bindInfo.isKeepAlive = appRecord->IsKeepAliveApp(); + bindInfo.extensionType = appRecord->GetExtensionType(); + bindInfo.processType = appRecord->GetProcessType(); + return true; +} +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 5f9d21f882..0d8cf5ac9a 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -1957,20 +1957,6 @@ void AppRunningManager::RemoveTimeoutDeadAppRecord() } } -UIExtensionProcessBindInfo AppRunningManager::WarpBindInfo(int32_t pid, int32_t uid, int32_t callerPid, - int32_t callerUid, std::string callerBundleName, - int32_t notifyProcessBind) -{ - UIExtensionProcessBindInfo uiExtensionProcessBindInfo; - uiExtensionProcessBindInfo.pid = pid; - uiExtensionProcessBindInfo.uid = uid; - uiExtensionProcessBindInfo.callerPid = callerPid; - uiExtensionProcessBindInfo.callerUid = callerUid; - uiExtensionProcessBindInfo.callerBundleName = callerBundleName; - uiExtensionProcessBindInfo.notifyProcessBind = notifyProcessBind; - return uiExtensionProcessBindInfo; -} - int32_t AppRunningManager::AddUIExtensionBindItem( int32_t uiExtensionBindAbilityId, UIExtensionProcessBindInfo &bindInfo) { diff --git a/services/appmgr/src/app_state_observer_manager.cpp b/services/appmgr/src/app_state_observer_manager.cpp index a40b5cb7b1..45861b3ebe 100644 --- a/services/appmgr/src/app_state_observer_manager.cpp +++ b/services/appmgr/src/app_state_observer_manager.cpp @@ -1251,16 +1251,15 @@ void AppStateObserverManager::HandleOnAppCacheStateChanged(const std::shared_ptr } ProcessBindData AppStateObserverManager::WrapProcessBindData( - const std::shared_ptr &appRecord, const UIExtensionProcessBindInfo &bindInfo, int32_t bindingRelation) { ProcessBindData processBindData; - processBindData.bundleName = appRecord->GetBundleName(); - processBindData.pid = appRecord->GetPid(); - processBindData.uid = appRecord->GetUid(); - processBindData.isKeepAlive = appRecord->IsKeepAliveApp(); - processBindData.extensionType = appRecord->GetExtensionType(); - processBindData.processType = appRecord->GetProcessType(); + processBindData.bundleName = bindInfo.bundleName; + processBindData.pid = bindInfo.pid; + processBindData.uid = bindInfo.uid; + processBindData.isKeepAlive = bindInfo.isKeepAlive; + processBindData.extensionType = bindInfo.extensionType; + processBindData.processType = bindInfo.processType; processBindData.callerPid = bindInfo.callerPid; processBindData.callerUid = bindInfo.callerUid; processBindData.callerBundleName = bindInfo.callerBundleName; @@ -1277,8 +1276,7 @@ void AppStateObserverManager::OnProcessBindingRelationChanged( return; } - auto task = - [weak = weak_from_this(), appRecord, bindInfo, bindingRelation]() { + auto task = [weak = weak_from_this(), appRecord, bindInfo, bindingRelation]() { auto self = weak.lock(); if (self == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "null self"); @@ -1300,16 +1298,22 @@ void AppStateObserverManager::HandleOnProcessBindingRelationChanged( return; } - ProcessBindData data = - WrapProcessBindData(appRecord, bindInfo, bindingRelation); + ProcessBindData data = WrapProcessBindData(bindInfo, bindingRelation); + TAG_LOGD(AAFwkTag::APPMGR, + "HandleOnProcessBindingRelationChanged, pid:%{public}d, uid:%{public}d, bundleName:%{public}s, " + "callerPid:%{public}d, callerUid:%{public}d, callerBundleName:%{public}s, bindingRelation:%{public}d", + data.pid, + data.uid, + data.bundleName.c_str(), + data.callerPid, + data.callerUid, + data.callerBundleName.c_str(), + data.bindingRelation); auto appStateObserverMapCopy = GetAppStateObserverMapCopy(); - for (auto it = appStateObserverMapCopy.begin(); - it != appStateObserverMapCopy.end(); ++it) { + for (auto it = appStateObserverMapCopy.begin(); it != appStateObserverMapCopy.end(); ++it) { const auto &bundleNames = it->second.bundleNames; - auto iter = - std::find(bundleNames.begin(), bundleNames.end(), data.bundleName); - if ((bundleNames.empty() || iter != bundleNames.end()) && - it->first != nullptr) { + auto iter = std::find(bundleNames.begin(), bundleNames.end(), data.bundleName); + if ((bundleNames.empty() || iter != bundleNames.end()) && it->first != nullptr) { it->first->OnProcessBindingRelationChanged(data); } }