diff --git a/interfaces/inner_api/app_manager/include/appmgr/process_data.h b/interfaces/inner_api/app_manager/include/appmgr/process_data.h index 2263efd2e0a6160d2cb8e40f9729b8b4671c2ab0..0181f217b008c0d6b678230f8797a73e50693927 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/process_data.h +++ b/interfaces/inner_api/app_manager/include/appmgr/process_data.h @@ -49,7 +49,9 @@ struct ProcessData : public Parcelable { std::string bundleName; int32_t pid = 0; - int32_t uid = 0; + int32_t uid = 0; // host uid + int32_t hostPid = 0; + int32_t gpuPid = 0; int32_t renderUid = -1; AppProcessState state; bool isContinuousTask = false; diff --git a/interfaces/inner_api/app_manager/src/appmgr/process_data.cpp b/interfaces/inner_api/app_manager/src/appmgr/process_data.cpp index 6deaf882af6cfec8fadd605327c7e1513c1b0bc3..3e1759f9eca0c31f3eca2e6d08ddf97de13b37df 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/process_data.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/process_data.cpp @@ -24,7 +24,8 @@ namespace OHOS { namespace AppExecFwk { bool ProcessData::Marshalling(Parcel &parcel) const { - return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) && parcel.WriteInt32(uid) && + return (parcel.WriteString(bundleName) && parcel.WriteInt32(pid) && + parcel.WriteInt32(uid) && parcel.WriteInt32(hostPid) && parcel.WriteInt32(gpuPid) && parcel.WriteInt32(static_cast(state)) && parcel.WriteBool(isContinuousTask) && parcel.WriteBool(isKeepAlive) && parcel.WriteBool(isFocused) && parcel.WriteInt32(requestProcCode) && parcel.WriteInt32(processChangeReason) && parcel.WriteString(processName) && @@ -38,6 +39,8 @@ bool ProcessData::ReadFromParcel(Parcel &parcel) bundleName = parcel.ReadString(); pid = parcel.ReadInt32(); uid = parcel.ReadInt32(); + hostPid = parcel.ReadInt32(); + gpuPid = parcel.ReadInt32(); state = static_cast(parcel.ReadInt32()); isContinuousTask = parcel.ReadBool(); isKeepAlive = parcel.ReadBool(); diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 417044ff0675d3ebd9d48475d5d1df6ae7b9c55e..a470a7bc750970444bc41d145d8243c06df1bee9 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -784,6 +784,8 @@ public: sptr GetBrowserHost(); void SetIsGPU(bool gpu); bool GetIsGPU(); + void SetGPUPid(pid_t gpuPid); + pid_t GetGPUPid(); private: /** * SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data. @@ -941,6 +943,7 @@ private: SupportProcessCacheState procCacheSupportState_ = SupportProcessCacheState::UNSPECIFIED; sptr browserHost_; bool isGPU_ = false; + pid_t gpuPid_ = 0; }; } // namespace AppExecFwk diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 9604ba1b65357fb864db58f229f685952a826f1c..c8aba0018c7d2c75a7fd6a0989310dc30b504723 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -4516,13 +4516,14 @@ void AppMgrServiceInner::AttachRenderProcess(const pid_t pid, const sptrGetBrowserHost() != nullptr) { + if (appRecord->GetBrowserHost() != nullptr && appRecord->GetIsGPU()) { TAG_LOGD(AAFwkTag::APPMGR, "GPU has host remote object"); + scheduler->NotifyBrowserFd(renderRecord->GetIpcFd(), + renderRecord->GetSharedFd(), renderRecord->GetCrashFd(), appRecord->GetBrowserHost()); + } else { + scheduler->NotifyBrowserFd(renderRecord->GetIpcFd(), + renderRecord->GetSharedFd(), renderRecord->GetCrashFd(), nullptr); } - scheduler->NotifyBrowserFd(renderRecord->GetIpcFd(), - renderRecord->GetSharedFd(), - renderRecord->GetCrashFd(), - appRecord->GetBrowserHost()); } void AppMgrServiceInner::SaveBrowserChannel(const pid_t hostPid, sptr browser) @@ -4623,6 +4624,7 @@ int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptrSetUid(renderUid); if (isGPU) { renderRecord->SetProcessType(ProcessType::GPU); + appRecord->SetGPUPid(pid); } appRecord->AddRenderRecord(renderRecord); TAG_LOGI(AAFwkTag::APPMGR, diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index 2af04101b883aab54f9001ac71dd32c1daed2816..8e3cf63c572a928737de29b4a2065ab606a53fa6 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -2252,5 +2252,15 @@ bool AppRunningRecord::GetIsGPU() { return isGPU_; } + +void AppRunningRecord::SetGPUPid(pid_t gpuPid) +{ + gpuPid_ = gpuPid; +} + +pid_t AppRunningRecord::GetGPUPid() +{ + return gpuPid_; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index b37be945c180b99264a1c67fcf73a98999c46046..3aaab43f99c3cdc61635085d346eca02d4480e2c 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -171,16 +171,6 @@ int32_t AppSpawnClient::SetMountPermission(const AppSpawnStartMsg &startMsg, App return ret; } } - - if (!startMsg.processType.empty()) { - ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_PROCESS_TYPE, - reinterpret_cast(startMsg.processType.c_str()), startMsg.processType.size()); - if (ret) { - TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); - return ret; - } - } - return ret; } @@ -314,6 +304,15 @@ int32_t AppSpawnClient::AppspawnSetExtMsgMore(const AppSpawnStartMsg &startMsg, } } + if (!startMsg.processType.empty()) { + ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_PROCESS_TYPE, + reinterpret_cast(startMsg.processType.c_str()), startMsg.processType.size()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); + return ret; + } + } + std::string maxChildProcessStr = std::to_string(startMsg.maxChildProcess); if ((ret = AppSpawnReqMsgAddExtInfo(reqHandle, MAX_CHILD_PROCESS.c_str(), reinterpret_cast(maxChildProcessStr.c_str()), maxChildProcessStr.size()))) { diff --git a/services/appmgr/src/app_state_observer_manager.cpp b/services/appmgr/src/app_state_observer_manager.cpp index 7f4ddcf5facac56ea6857aa0c2fb1fc8d9b4d19a..e742c8eb8ef7eb02eb282a3c5c1153f608414be9 100644 --- a/services/appmgr/src/app_state_observer_manager.cpp +++ b/services/appmgr/src/app_state_observer_manager.cpp @@ -596,8 +596,9 @@ void AppStateObserverManager::HandleOnProcessStateChanged(const std::shared_ptr< } ProcessData data = WrapProcessData(appRecord); TAG_LOGD(AAFwkTag::APPMGR, - "bundle:%{public}s pid:%{public}d uid:%{public}d state:%{public}d isContinuousTask:%{public}d", - data.bundleName.c_str(), data.pid, data.uid, data.state, data.isContinuousTask); + "bundle:%{public}s, pid:%{public}d, uid:%{public}d, state:%{public}d, " + "isContinuousTask:%{public}d, gpuPid:%{public}d", + data.bundleName.c_str(), data.pid, data.uid, data.state, data.isContinuousTask, data.gpuPid); auto appStateObserverMapCopy = GetAppStateObserverMapCopy(); for (auto it = appStateObserverMapCopy.begin(); it != appStateObserverMapCopy.end(); ++it) { std::vector::iterator iter = std::find(it->second.begin(), @@ -670,6 +671,7 @@ ProcessData AppStateObserverManager::WrapProcessData(const std::shared_ptrGetExitReason(); processData.exitMsg = appRecord->GetExitMsg(); + processData.gpuPid = appRecord->GetGPUPid(); return processData; } @@ -682,6 +684,7 @@ ProcessData AppStateObserverManager::WrapRenderProcessData(const std::shared_ptr processData.renderUid = renderRecord->GetUid(); processData.processName = renderRecord->GetProcessName(); processData.processType = renderRecord->GetProcessType(); + processData.hostPid = renderRecord->GetHostPid(); return processData; }