mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2025-02-17 11:18:42 +00:00
commit
018f79c6fb
@ -80,6 +80,7 @@ ohos_shared_library("app_manager") {
|
||||
"src/appmgr/profile.cpp",
|
||||
"src/appmgr/quick_fix_callback_proxy.cpp",
|
||||
"src/appmgr/quick_fix_callback_stub.cpp",
|
||||
"src/appmgr/render_process_info.cpp",
|
||||
"src/appmgr/render_scheduler_host.cpp",
|
||||
"src/appmgr/render_scheduler_proxy.cpp",
|
||||
"src/appmgr/running_process_info.cpp",
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "bundle_info.h"
|
||||
#include "iapp_state_callback.h"
|
||||
#include "irender_scheduler.h"
|
||||
#include "render_process_info.h"
|
||||
#include "running_process_info.h"
|
||||
#include "system_memory_attr.h"
|
||||
#include "istart_specified_ability_response.h"
|
||||
@ -201,6 +202,15 @@ public:
|
||||
*/
|
||||
virtual AppMgrResultCode GetProcessRunningInformation(RunningProcessInfo &info);
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
*
|
||||
* @param info, render process info.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode GetAllRenderProcesses(std::vector<RenderProcessInfo> &info);
|
||||
|
||||
/**
|
||||
* NotifyMemoryLevel, call NotifyMemoryLevel() through proxy project.
|
||||
* Notify abilities background the current memory level.
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "bundle_info.h"
|
||||
#include "iapp_state_callback.h"
|
||||
#include "ams_mgr_interface.h"
|
||||
#include "render_process_info.h"
|
||||
#include "running_process_info.h"
|
||||
#include "system_memory_attr.h"
|
||||
#include "iapplication_state_observer.h"
|
||||
@ -117,6 +118,15 @@ public:
|
||||
*/
|
||||
virtual int GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
*
|
||||
* @param info, render process info.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int GetAllRenderProcesses(std::vector<RenderProcessInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* JudgeSandboxByPid, call JudgeSandboxByPid() through proxy project.
|
||||
* Obtains information about application processes that are running on the device.
|
||||
@ -384,6 +394,7 @@ public:
|
||||
DUMP_HEAP_MEMORY_PROCESS,
|
||||
START_NATIVE_PROCESS_FOR_DEBUGGER,
|
||||
JUDGE_SANDBOX_BY_PID,
|
||||
APP_GET_ALL_RENDER_PROCESSES,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
@ -108,6 +108,15 @@ public:
|
||||
*/
|
||||
virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
*
|
||||
* @param info, render process info.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRenderProcesses(std::vector<RenderProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* JudgeSandboxByPid, call JudgeSandboxByPid() through proxy project.
|
||||
* Obtains information about application processes that are running on the device.
|
||||
|
@ -67,6 +67,7 @@ private:
|
||||
int32_t HandleGetAllRunningProcesses(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetProcessRunningInfosByUserId(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetProcessRunningInformation(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetAllRenderProcesses(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleAddAbilityStageDone(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleNotifyMemoryLevel(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleStartupResidentProcess(MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -57,6 +57,7 @@ struct AppProcessData : public Parcelable {
|
||||
pid_t pid = 0;
|
||||
std::vector<AppData> appDatas;
|
||||
bool isFocused = false;
|
||||
std::vector<int32_t> renderPids;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -52,6 +52,7 @@ struct AppStateData : public Parcelable {
|
||||
int32_t state = 0;
|
||||
int32_t accessTokenId = 0;
|
||||
bool isFocused = false;
|
||||
std::vector<int32_t> renderPids;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -50,6 +50,7 @@ struct ProcessData : public Parcelable {
|
||||
std::string bundleName;
|
||||
int32_t pid = 0;
|
||||
int32_t uid = 0;
|
||||
int32_t renderUid = -1;
|
||||
AppProcessState state;
|
||||
bool isContinuousTask = false;
|
||||
bool isKeepAlive = false;
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_RENDER_PROCESS_INFO_H
|
||||
#define OHOS_ABILITY_RUNTIME_RENDER_PROCESS_INFO_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "app_mgr_constants.h"
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
struct RenderProcessInfo : public Parcelable {
|
||||
std::string bundleName_;
|
||||
std::string processName_;
|
||||
std::int32_t pid_;
|
||||
std::int32_t uid_;
|
||||
std::int32_t hostUid_;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static RenderProcessInfo *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_ABILITY_RUNTIME_RENDER_PROCESS_INFO_H
|
@ -349,6 +349,19 @@ AppMgrResultCode AppMgrClient::GetProcessRunningInformation(AppExecFwk::RunningP
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::GetAllRenderProcesses(std::vector<RenderProcessInfo> &info)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
int32_t result = service->GetAllRenderProcesses(info);
|
||||
if (result == ERR_OK) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||
}
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::NotifyMemoryLevel(MemoryLevel level)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
|
@ -241,6 +241,31 @@ int32_t AppMgrProxy::GetAllRunningProcesses(std::vector<RunningProcessInfo> &inf
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetAllRenderProcesses(std::vector<RenderProcessInfo> &info)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote() is NULL");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
if (!SendTransactCmd(IAppMgr::Message::APP_GET_ALL_RENDER_PROCESSES, data, reply)) {
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
auto error = GetParcelableInfos<RenderProcessInfo>(reply, info);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("GetParcelableInfos fail, error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
int result = reply.ReadInt32();
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::JudgeSandboxByPid(pid_t pid, bool &isSandbox)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -116,6 +116,8 @@ AppMgrStub::AppMgrStub()
|
||||
&AppMgrStub::HandleStartNativeProcessForDebugger;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::JUDGE_SANDBOX_BY_PID)] =
|
||||
&AppMgrStub::HandleJudgeSandboxByPid;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::APP_GET_ALL_RENDER_PROCESSES)] =
|
||||
&AppMgrStub::HandleGetAllRenderProcesses;
|
||||
}
|
||||
|
||||
AppMgrStub::~AppMgrStub()
|
||||
@ -252,6 +254,23 @@ int32_t AppMgrStub::HandleGetProcessRunningInfosByUserId(MessageParcel &data, Me
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetAllRenderProcesses(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::vector<RenderProcessInfo> info;
|
||||
auto result = GetAllRenderProcesses(info);
|
||||
reply.WriteInt32(info.size());
|
||||
for (auto &it : info) {
|
||||
if (!reply.WriteParcelable(&it)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleJudgeSandboxByPid(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
|
@ -61,6 +61,7 @@ bool AppProcessData::Marshalling(Parcel &parcel) const
|
||||
}
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isFocused);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32Vector, parcel, renderPids);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -76,6 +77,7 @@ bool AppProcessData::ReadFromParcel(Parcel &parcel)
|
||||
ReadFromParcelAppData(appDatas, parcel);
|
||||
|
||||
isFocused = parcel.ReadBool();
|
||||
parcel.ReadInt32Vector(&renderPids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ namespace AppExecFwk {
|
||||
bool AppStateData::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
return (parcel.WriteString(bundleName) && parcel.WriteInt32(uid) && parcel.WriteInt32(state)
|
||||
&& parcel.WriteInt32(pid) && parcel.WriteInt32(accessTokenId) && parcel.WriteBool(isFocused));
|
||||
&& parcel.WriteInt32(pid) && parcel.WriteInt32(accessTokenId) && parcel.WriteBool(isFocused)
|
||||
&& parcel.WriteInt32Vector(renderPids));
|
||||
}
|
||||
|
||||
bool AppStateData::ReadFromParcel(Parcel &parcel)
|
||||
@ -33,6 +34,7 @@ bool AppStateData::ReadFromParcel(Parcel &parcel)
|
||||
pid = parcel.ReadInt32();
|
||||
accessTokenId = parcel.ReadInt32();
|
||||
isFocused = parcel.ReadBool();
|
||||
parcel.ReadInt32Vector(&renderPids);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ bool ProcessData::Marshalling(Parcel &parcel) const
|
||||
parcel.WriteInt32(static_cast<int32_t>(state)) && parcel.WriteBool(isContinuousTask) &&
|
||||
parcel.WriteBool(isKeepAlive) && parcel.WriteBool(isFocused) && parcel.WriteInt32(requestProcCode) &&
|
||||
parcel.WriteInt32(processChangeReason) && parcel.WriteString(processName) &&
|
||||
parcel.WriteInt32(static_cast<int32_t>(processType)) && parcel.WriteInt32(static_cast<int32_t>(extensionType)));
|
||||
parcel.WriteInt32(static_cast<int32_t>(processType)) && parcel.WriteInt32(static_cast<int32_t>(extensionType))
|
||||
&& parcel.WriteInt32(renderUid));
|
||||
}
|
||||
|
||||
bool ProcessData::ReadFromParcel(Parcel &parcel)
|
||||
@ -43,6 +44,7 @@ bool ProcessData::ReadFromParcel(Parcel &parcel)
|
||||
processName = parcel.ReadString();
|
||||
processType = static_cast<ProcessType>(parcel.ReadInt32());
|
||||
extensionType = static_cast<ExtensionAbilityType>(parcel.ReadInt32());
|
||||
renderUid = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "render_process_info.h"
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "string_ex.h"
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel_macro_base.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
bool RenderProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
bundleName_ = Str16ToStr8(parcel.ReadString16());
|
||||
processName_ = Str16ToStr8(parcel.ReadString16());
|
||||
int32_t pidData;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, pidData);
|
||||
pid_ = static_cast<int32_t>(pidData);
|
||||
int32_t uidData;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uidData);
|
||||
uid_ = static_cast<int32_t>(uidData);
|
||||
int32_t hostUidData;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hostUidData);
|
||||
hostUid_ = static_cast<int32_t>(hostUidData);
|
||||
return true;
|
||||
}
|
||||
|
||||
RenderProcessInfo *RenderProcessInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
RenderProcessInfo *info = new (std::nothrow) RenderProcessInfo();
|
||||
if (info && !info->ReadFromParcel(parcel)) {
|
||||
HILOG_WARN("read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
bool RenderProcessInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(processName_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(pid_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(uid_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(hostUid_));
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -124,6 +124,15 @@ public:
|
||||
*/
|
||||
virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
*
|
||||
* @param info, render process info.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRenderProcesses(std::vector<RenderProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* JudgeSandboxByPid, call JudgeSandboxByPid() through proxy project.
|
||||
* Obtains information about application processes that are running on the device.
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "remote_client_manager.h"
|
||||
#include "app_running_manager.h"
|
||||
#include "record_query_result.h"
|
||||
#include "render_process_info.h"
|
||||
#include "running_process_info.h"
|
||||
#include "bundle_info.h"
|
||||
#include "istart_specified_ability_response.h"
|
||||
@ -276,6 +277,15 @@ public:
|
||||
*/
|
||||
virtual int32_t GetProcessRunningInformation(RunningProcessInfo &info);
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, Obtains information about render processes that are running on the device.
|
||||
*
|
||||
* @param info, render process record.
|
||||
*
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRenderProcesses(std::vector<RenderProcessInfo> &info);
|
||||
|
||||
/**
|
||||
* NotifyMemoryLevel, Notify applications background the current memory level.
|
||||
*
|
||||
@ -803,6 +813,8 @@ private:
|
||||
void GetRunningProcesses(const std::shared_ptr<AppRunningRecord> &appRecord, std::vector<RunningProcessInfo> &info);
|
||||
void GetRunningProcess(const std::shared_ptr<AppRunningRecord> &appRecord, RunningProcessInfo &info);
|
||||
|
||||
void GetRenderProcesses(const std::shared_ptr<AppRunningRecord> &appRecord, std::vector<RenderProcessInfo> &info);
|
||||
|
||||
int StartRenderProcessImpl(const std::shared_ptr<RenderRecord> &renderRecord,
|
||||
const std::shared_ptr<AppRunningRecord> appRecord, pid_t &renderPid);
|
||||
|
||||
|
@ -63,6 +63,8 @@ public:
|
||||
void SetPid(pid_t pid);
|
||||
pid_t GetPid() const ;
|
||||
pid_t GetHostPid() const;
|
||||
void SetUid(int32_t uid);
|
||||
int32_t GetUid() const;
|
||||
int32_t GetHostUid() const;
|
||||
std::string GetHostBundleName() const;
|
||||
std::string GetRenderParam() const;
|
||||
@ -84,6 +86,7 @@ private:
|
||||
|
||||
pid_t pid_ = 0;
|
||||
pid_t hostPid_ = 0;
|
||||
int32_t uid_ = 0;
|
||||
int32_t hostUid_ = 0;
|
||||
std::string hostBundleName_;
|
||||
std::string renderParam_;
|
||||
@ -551,8 +554,10 @@ public:
|
||||
void SetDebugApp(bool isDebugApp);
|
||||
bool IsDebugApp();
|
||||
void SetNativeDebug(bool isNativeDebug);
|
||||
void SetRenderRecord(const std::shared_ptr<RenderRecord> &record);
|
||||
std::shared_ptr<RenderRecord> GetRenderRecord();
|
||||
void AddRenderRecord(const std::shared_ptr<RenderRecord> &record);
|
||||
void RemoveRenderRecord(const std::shared_ptr<RenderRecord> &record);
|
||||
std::shared_ptr<RenderRecord> GetRenderRecordByPid(const pid_t pid);
|
||||
std::map<int32_t, std::shared_ptr<RenderRecord>> GetRenderRecordMap();
|
||||
void SetStartMsg(const AppSpawnStartMsg &msg);
|
||||
AppSpawnStartMsg GetStartMsg();
|
||||
|
||||
@ -716,7 +721,8 @@ private:
|
||||
std::atomic_bool isSpawned_ = false;
|
||||
|
||||
// render record
|
||||
std::shared_ptr<RenderRecord> renderRecord_ = nullptr;
|
||||
std::map<int32_t, std::shared_ptr<RenderRecord>> renderRecordMap_;
|
||||
std::mutex renderRecordMapLock_;
|
||||
AppSpawnStartMsg startMsg_;
|
||||
int32_t appIndex_ = 0;
|
||||
bool securityFlag_ = false;
|
||||
|
@ -320,6 +320,14 @@ int32_t AppMgrService::GetAllRunningProcesses(std::vector<RunningProcessInfo> &i
|
||||
return appMgrServiceInner_->GetAllRunningProcesses(info);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::GetAllRenderProcesses(std::vector<RenderProcessInfo> &info)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
return appMgrServiceInner_->GetAllRenderProcesses(info);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::JudgeSandboxByPid(pid_t pid, bool &isSandbox)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
|
@ -916,6 +916,29 @@ int32_t AppMgrServiceInner::GetProcessRunningInformation(RunningProcessInfo &inf
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::GetAllRenderProcesses(std::vector<RenderProcessInfo> &info)
|
||||
{
|
||||
auto isPerm = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm();
|
||||
// check permission
|
||||
for (const auto &item : appRunningManager_->GetAppRunningRecordMap()) {
|
||||
const auto &appRecord = item.second;
|
||||
if (isPerm) {
|
||||
GetRenderProcesses(appRecord, info);
|
||||
} else {
|
||||
auto applicationInfo = appRecord->GetApplicationInfo();
|
||||
if (!applicationInfo) {
|
||||
continue;
|
||||
}
|
||||
auto callingTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
auto tokenId = applicationInfo->accessTokenId;
|
||||
if (callingTokenId == tokenId) {
|
||||
GetRenderProcesses(appRecord, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::NotifyMemoryLevel(int32_t level)
|
||||
{
|
||||
HILOG_INFO("AppMgrServiceInner start");
|
||||
@ -982,6 +1005,27 @@ void AppMgrServiceInner::GetRunningProcess(const std::shared_ptr<AppRunningRecor
|
||||
info.extensionType_ = appRecord->GetExtensionType();
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::GetRenderProcesses(const std::shared_ptr<AppRunningRecord> &appRecord,
|
||||
std::vector<RenderProcessInfo> &info)
|
||||
{
|
||||
auto renderRecordMap = appRecord->GetRenderRecordMap();
|
||||
if (renderRecordMap.empty()) {
|
||||
return;
|
||||
}
|
||||
for (auto iter : renderRecordMap) {
|
||||
auto renderRecord = iter.second;
|
||||
if (renderRecord != nullptr) {
|
||||
RenderProcessInfo renderProcessInfo;
|
||||
renderProcessInfo.bundleName_ = renderRecord->GetHostBundleName();
|
||||
renderProcessInfo.processName_ = renderRecord->GetProcessName();
|
||||
renderProcessInfo.pid_ = renderRecord->GetPid();
|
||||
renderProcessInfo.uid_ = renderRecord->GetUid();
|
||||
renderProcessInfo.hostUid_ = renderRecord->GetHostUid();
|
||||
info.emplace_back(renderProcessInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::KillProcessByPid(const pid_t pid) const
|
||||
{
|
||||
int32_t ret = -1;
|
||||
@ -1558,6 +1602,15 @@ AppProcessData AppMgrServiceInner::WrapAppProcessData(const std::shared_ptr<AppR
|
||||
processData.pid = appRecord->GetPriorityObject()->GetPid();
|
||||
processData.appState = state;
|
||||
processData.isFocused = appRecord->GetFocusFlag();
|
||||
auto renderRecordMap = appRecord->GetRenderRecordMap();
|
||||
if (!renderRecordMap.empty()) {
|
||||
for (auto iter : renderRecordMap) {
|
||||
auto renderRecord = iter.second;
|
||||
if (renderRecord != nullptr) {
|
||||
processData.renderPids.emplace_back(renderRecord->GetPid());
|
||||
}
|
||||
}
|
||||
}
|
||||
return processData;
|
||||
}
|
||||
|
||||
@ -1906,11 +1959,16 @@ void AppMgrServiceInner::ClearAppRunningData(const std::shared_ptr<AppRunningRec
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnProcessDied(appRecord);
|
||||
|
||||
// kill render if exist.
|
||||
auto renderRecord = appRecord->GetRenderRecord();
|
||||
if (renderRecord && renderRecord->GetPid() > 0) {
|
||||
HILOG_DEBUG("Kill render process when host died.");
|
||||
KillProcessByPid(renderRecord->GetPid());
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnRenderProcessDied(renderRecord);
|
||||
auto renderRecordMap = appRecord->GetRenderRecordMap();
|
||||
if (!renderRecordMap.empty()) {
|
||||
for (auto iter : renderRecordMap) {
|
||||
auto renderRecord = iter.second;
|
||||
if (renderRecord && renderRecord->GetPid() > 0) {
|
||||
HILOG_DEBUG("Kill render process when host died.");
|
||||
KillProcessByPid(renderRecord->GetPid());
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnRenderProcessDied(renderRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (appRecord->GetPriorityObject() != nullptr) {
|
||||
@ -3120,14 +3178,18 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto renderRecord = appRecord->GetRenderRecord();
|
||||
if (renderRecord) {
|
||||
HILOG_WARN("already exist render process,do not request again, renderPid:%{public}d", renderRecord->GetPid());
|
||||
renderPid = renderRecord->GetPid();
|
||||
return ERR_ALREADY_EXIST_RENDER;
|
||||
auto renderRecordMap = appRecord->GetRenderRecordMap();
|
||||
if (!renderRecordMap.empty()) {
|
||||
for (auto iter : renderRecordMap) {
|
||||
if (iter.second != nullptr) {
|
||||
HILOG_WARN("already exist render process, renderPid:%{public}d", iter.second->GetPid());
|
||||
renderPid = iter.second->GetPid();
|
||||
return ERR_ALREADY_EXIST_RENDER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderRecord = RenderRecord::CreateRenderRecord(hostPid, renderParam, ipcFd, sharedFd, crashFd, appRecord);
|
||||
auto renderRecord = RenderRecord::CreateRenderRecord(hostPid, renderParam, ipcFd, sharedFd, crashFd, appRecord);
|
||||
if (!renderRecord) {
|
||||
HILOG_ERROR("create render record failed, hostPid:%{public}d", hostPid);
|
||||
return ERR_INVALID_VALUE;
|
||||
@ -3160,7 +3222,7 @@ void AppMgrServiceInner::AttachRenderProcess(const pid_t pid, const sptr<IRender
|
||||
return;
|
||||
}
|
||||
|
||||
auto renderRecord = appRecord->GetRenderRecord();
|
||||
auto renderRecord = appRecord->GetRenderRecordByPid(pid);
|
||||
if (!renderRecord) {
|
||||
HILOG_ERROR("no such render Record, pid:%{public}d", pid);
|
||||
return;
|
||||
@ -3204,8 +3266,9 @@ int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptr<RenderRecor
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
renderPid = pid;
|
||||
appRecord->SetRenderRecord(renderRecord);
|
||||
renderRecord->SetPid(pid);
|
||||
renderRecord->SetUid(startMsg.uid);
|
||||
appRecord->AddRenderRecord(renderRecord);
|
||||
HILOG_INFO("start render process success, hostPid:%{public}d, pid:%{public}d uid:%{public}d",
|
||||
renderRecord->GetHostPid(), pid, startMsg.uid);
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->OnRenderProcessCreated(renderRecord);
|
||||
|
@ -624,8 +624,17 @@ std::shared_ptr<AppRunningRecord> AppRunningManager::GetAppRunningRecordByRender
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(lock_);
|
||||
auto iter = std::find_if(appRunningRecordMap_.begin(), appRunningRecordMap_.end(), [&pid](const auto &pair) {
|
||||
auto renderRecord = pair.second->GetRenderRecord();
|
||||
return renderRecord && renderRecord->GetPid() == pid;
|
||||
auto renderRecordMap = pair.second->GetRenderRecordMap();
|
||||
if (renderRecordMap.empty()) {
|
||||
return false;
|
||||
}
|
||||
for (auto it : renderRecordMap) {
|
||||
auto renderRecord = it.second;
|
||||
if (renderRecord && renderRecord->GetPid() == pid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return ((iter == appRunningRecordMap_.end()) ? nullptr : iter->second);
|
||||
}
|
||||
@ -643,24 +652,33 @@ std::shared_ptr<RenderRecord> AppRunningManager::OnRemoteRenderDied(const wptr<I
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> guard(lock_);
|
||||
std::shared_ptr<RenderRecord> renderRecord;
|
||||
const auto &it =
|
||||
std::find_if(appRunningRecordMap_.begin(), appRunningRecordMap_.end(), [&object](const auto &pair) {
|
||||
std::find_if(appRunningRecordMap_.begin(), appRunningRecordMap_.end(),
|
||||
[&object, &renderRecord](const auto &pair) {
|
||||
if (!pair.second) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto renderRecord = pair.second->GetRenderRecord();
|
||||
if (!renderRecord) {
|
||||
auto renderRecordMap = pair.second->GetRenderRecordMap();
|
||||
if (renderRecordMap.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto scheduler = renderRecord->GetScheduler();
|
||||
return scheduler && scheduler->AsObject() == object;
|
||||
for (auto iter : renderRecordMap) {
|
||||
if (iter.second == nullptr) {
|
||||
continue;
|
||||
}
|
||||
auto scheduler = iter.second->GetScheduler();
|
||||
if (scheduler && scheduler->AsObject() == object) {
|
||||
renderRecord = iter.second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (it != appRunningRecordMap_.end()) {
|
||||
auto appRecord = it->second;
|
||||
auto renderRecord = appRecord->GetRenderRecord();
|
||||
appRecord->SetRenderRecord(nullptr);
|
||||
appRecord->RemoveRenderRecord(renderRecord);
|
||||
return renderRecord;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -75,6 +75,16 @@ pid_t RenderRecord::GetHostPid() const
|
||||
return hostPid_;
|
||||
}
|
||||
|
||||
void RenderRecord::SetUid(int32_t uid)
|
||||
{
|
||||
uid_ = uid;
|
||||
}
|
||||
|
||||
int32_t RenderRecord::GetUid() const
|
||||
{
|
||||
return uid_;
|
||||
}
|
||||
|
||||
void RenderRecord::SetHostUid(const int32_t hostUid)
|
||||
{
|
||||
hostUid_ = hostUid;
|
||||
@ -1304,14 +1314,45 @@ int32_t AppRunningRecord::UpdateConfiguration(const Configuration &config)
|
||||
return appLifeCycleDeal_->UpdateConfiguration(config);
|
||||
}
|
||||
|
||||
void AppRunningRecord::SetRenderRecord(const std::shared_ptr<RenderRecord> &record)
|
||||
void AppRunningRecord::AddRenderRecord(const std::shared_ptr<RenderRecord> &record)
|
||||
{
|
||||
renderRecord_ = record;
|
||||
if (!record) {
|
||||
HILOG_DEBUG("AddRenderRecord: record is null");
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> renderRecordMapLock(renderRecordMapLock_);
|
||||
renderRecordMap_.emplace(record->GetUid(), record);
|
||||
}
|
||||
|
||||
std::shared_ptr<RenderRecord> AppRunningRecord::GetRenderRecord()
|
||||
void AppRunningRecord::RemoveRenderRecord(const std::shared_ptr<RenderRecord> &record)
|
||||
{
|
||||
return renderRecord_;
|
||||
if (!record) {
|
||||
HILOG_DEBUG("RemoveRenderRecord: record is null");
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> renderRecordMapLock(renderRecordMapLock_);
|
||||
renderRecordMap_.erase(record->GetUid());
|
||||
}
|
||||
|
||||
std::shared_ptr<RenderRecord> AppRunningRecord::GetRenderRecordByPid(const pid_t pid)
|
||||
{
|
||||
std::lock_guard<std::mutex> renderRecordMapLock(renderRecordMapLock_);
|
||||
if (renderRecordMap_.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
for (auto iter : renderRecordMap_) {
|
||||
auto renderRecord = iter.second;
|
||||
if (renderRecord && renderRecord->GetPid() == pid) {
|
||||
return renderRecord;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::map<int32_t, std::shared_ptr<RenderRecord>> AppRunningRecord::GetRenderRecordMap()
|
||||
{
|
||||
std::lock_guard<std::mutex> renderRecordMapLock(renderRecordMapLock_);
|
||||
return renderRecordMap_;
|
||||
}
|
||||
|
||||
void AppRunningRecord::SetStartMsg(const AppSpawnStartMsg &msg)
|
||||
|
@ -393,8 +393,9 @@ void AppStateObserverManager::HandleOnAppProcessCreated(const std::shared_ptr<Ap
|
||||
}
|
||||
ProcessData data = WrapProcessData(appRecord);
|
||||
HILOG_INFO("Process Create, bundle:%{public}s, pid:%{public}d, uid:%{public}d, processType:%{public}d, "
|
||||
"extensionType:%{public}d, processName:%{public}s",
|
||||
data.bundleName.c_str(), data.pid, data.uid, data.processType, data.extensionType, data.processName.c_str());
|
||||
"extensionType:%{public}d, processName:%{public}s, renderUid:%{public}d",
|
||||
data.bundleName.c_str(), data.pid, data.uid, data.processType, data.extensionType, data.processName.c_str(),
|
||||
data.renderUid);
|
||||
HandleOnProcessCreated(data);
|
||||
}
|
||||
|
||||
@ -426,8 +427,8 @@ void AppStateObserverManager::HandleOnRenderProcessCreated(const std::shared_ptr
|
||||
}
|
||||
ProcessData data = WrapRenderProcessData(renderRecord);
|
||||
HILOG_DEBUG("RenderProcess Create, bundle:%{public}s, pid:%{public}d, uid:%{public}d, processType:%{public}d, "
|
||||
"processName:%{public}s",
|
||||
data.bundleName.c_str(), data.pid, data.uid, data.processType, data.processName.c_str());
|
||||
"processName:%{public}s, renderUid:%{public}d",
|
||||
data.bundleName.c_str(), data.pid, data.uid, data.processType, data.processName.c_str(), data.renderUid);
|
||||
HandleOnProcessCreated(data);
|
||||
}
|
||||
|
||||
@ -469,8 +470,8 @@ void AppStateObserverManager::HandleOnAppProcessDied(const std::shared_ptr<AppRu
|
||||
return;
|
||||
}
|
||||
ProcessData data = WrapProcessData(appRecord);
|
||||
HILOG_DEBUG("Process died, bundle:%{public}s, pid:%{public}d, uid:%{public}d",
|
||||
data.bundleName.c_str(), data.pid, data.uid);
|
||||
HILOG_DEBUG("Process died, bundle:%{public}s, pid:%{public}d, uid:%{public}d, renderUid:%{public}d",
|
||||
data.bundleName.c_str(), data.pid, data.uid, data.renderUid);
|
||||
HandleOnProcessDied(data);
|
||||
}
|
||||
|
||||
@ -481,8 +482,8 @@ void AppStateObserverManager::HandleOnRenderProcessDied(const std::shared_ptr<Re
|
||||
return;
|
||||
}
|
||||
ProcessData data = WrapRenderProcessData(renderRecord);
|
||||
HILOG_DEBUG("Render Process died, bundle:%{public}s, pid:%{public}d, uid:%{public}d",
|
||||
data.bundleName.c_str(), data.pid, data.uid);
|
||||
HILOG_DEBUG("Render Process died, bundle:%{public}s, pid:%{public}d, uid:%{public}d, renderUid:%{public}d",
|
||||
data.bundleName.c_str(), data.pid, data.uid, data.renderUid);
|
||||
HandleOnProcessDied(data);
|
||||
}
|
||||
|
||||
@ -522,6 +523,7 @@ ProcessData AppStateObserverManager::WrapRenderProcessData(const std::shared_ptr
|
||||
processData.bundleName = renderRecord->GetHostBundleName();
|
||||
processData.pid = renderRecord->GetPid();
|
||||
processData.uid = renderRecord->GetHostUid();
|
||||
processData.renderUid = renderRecord->GetUid();
|
||||
processData.processName = renderRecord->GetProcessName();
|
||||
processData.processType = renderRecord->GetProcessType();
|
||||
return processData;
|
||||
@ -608,6 +610,15 @@ AppStateData AppStateObserverManager::WrapAppStateData(const std::shared_ptr<App
|
||||
appStateData.accessTokenId = static_cast<int32_t>(appRecord->GetApplicationInfo()->accessTokenId);
|
||||
}
|
||||
appStateData.isFocused = appRecord->GetFocusFlag();
|
||||
auto renderRecordMap = appRecord->GetRenderRecordMap();
|
||||
if (!renderRecordMap.empty()) {
|
||||
for (auto iter : renderRecordMap) {
|
||||
auto renderRecord = iter.second;
|
||||
if (renderRecord != nullptr) {
|
||||
appStateData.renderPids.emplace_back(renderRecord->GetPid());
|
||||
}
|
||||
}
|
||||
}
|
||||
return appStateData;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -116,7 +116,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
std::shared_ptr<UserTestRecord> testRecord;
|
||||
appRecord->SetUserTestInfo(testRecord);
|
||||
std::shared_ptr<RenderRecord> record;
|
||||
appRecord->SetRenderRecord(record);
|
||||
appRecord->AddRenderRecord(record);
|
||||
AppSpawnStartMsg appMsg;
|
||||
appRecord->SetStartMsg(appMsg);
|
||||
bool isDebugApp = *data % ENABLE;
|
||||
@ -137,7 +137,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
appRecord->IsEmptyKeepAliveApp();
|
||||
appRecord->GetRestartResidentProcCount();
|
||||
appRecord->GetUserTestInfo();
|
||||
appRecord->GetRenderRecord();
|
||||
appRecord->GetRenderRecordMap();
|
||||
appRecord->GetStartMsg();
|
||||
appRecord->GetAppIndex();
|
||||
appRecord->GetSecurityFlag();
|
||||
|
@ -134,6 +134,11 @@ public:
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual int GetAllRenderProcesses(std::vector<RenderProcessInfo>& info) override
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) override
|
||||
{
|
||||
return 0;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "ability_info.h"
|
||||
#include "application_info.h"
|
||||
#include "iapp_state_callback.h"
|
||||
#include "render_process_info.h"
|
||||
#include "running_process_info.h"
|
||||
#include "want.h"
|
||||
|
||||
@ -142,6 +143,15 @@ public:
|
||||
*/
|
||||
virtual AppMgrResultCode GetAllRunningProcesses(std::vector<RunningProcessInfo>& info);
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
*
|
||||
* @param info, render process info.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode GetAllRenderProcesses(std::vector<RenderProcessInfo> &info);
|
||||
|
||||
/**
|
||||
* SetAppSuspendTimes, Setting the Freezing Time of APP Background.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "app_record_id.h"
|
||||
#include "iapp_state_callback.h"
|
||||
#include "ams_mgr_interface.h"
|
||||
#include "render_process_info.h"
|
||||
#include "running_process_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -119,6 +120,15 @@ public:
|
||||
*/
|
||||
virtual int GetAllRunningProcesses(std::vector<RunningProcessInfo>& info) = 0;
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
*
|
||||
* @param info, render process info.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int GetAllRenderProcesses(std::vector<RenderProcessInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* SetAppSuspendTimes, Setting the Freezing Time of APP Background.
|
||||
*
|
||||
|
@ -91,6 +91,11 @@ AppMgrResultCode AppMgrClient::GetAllRunningProcesses(std::vector<RunningProcess
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::GetAllRenderProcesses(std::vector<RenderProcessInfo>& info)
|
||||
{
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::ConnectAppMgrService()
|
||||
{
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
MOCK_METHOD1(IsBackgroundRunningRestricted, int(const std::string& bundleName));
|
||||
MOCK_METHOD1(GetAllRunningProcesses, int(std::vector<RunningProcessInfo>& info));
|
||||
MOCK_METHOD2(GetProcessRunningInfosByUserId, int(std::vector<RunningProcessInfo>& info, int32_t userId));
|
||||
MOCK_METHOD1(GetAllRenderProcesses, int(std::vector<RenderProcessInfo>& info));
|
||||
MOCK_METHOD0(GetAmsMgr, sptr<IAmsMgr>());
|
||||
MOCK_METHOD1(GetAppFreezingTime, void(int& time));
|
||||
MOCK_METHOD1(SetAppFreezingTime, void(int time));
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
MOCK_METHOD3(ClearUpApplicationData, void(const std::string&, const int32_t, const pid_t));
|
||||
MOCK_METHOD1(IsBackgroundRunningRestricted, int32_t(const std::string&));
|
||||
MOCK_METHOD1(GetAllRunningProcesses, int32_t(std::vector<RunningProcessInfo>&));
|
||||
MOCK_METHOD1(GetAllRenderProcesses, int32_t(std::vector<RenderProcessInfo>&));
|
||||
MOCK_METHOD1(RegisterAppStateCallback, void(const sptr<IAppStateCallback>& callback));
|
||||
MOCK_METHOD0(StopAllProcess, void());
|
||||
MOCK_CONST_METHOD0(QueryAppSpawnConnectionState, SpawnConnectionState());
|
||||
|
@ -224,6 +224,23 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_GetApplicationInfoByProcessID_001, TestS
|
||||
EXPECT_EQ(application.bundleName, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppMgrClient_GetAllRenderProcesses_001
|
||||
* @tc.desc: get all render processes.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrClientTest, AppMgrClient_GetAllRenderProcesses_001, TestSize.Level0)
|
||||
{
|
||||
HILOG_INFO("GetAllRenderProcesses_001 start");
|
||||
auto appMgrClient = std::make_unique<AppMgrClient>();
|
||||
EXPECT_NE(appMgrClient, nullptr);
|
||||
|
||||
std::vector<RenderProcessInfo> info;
|
||||
auto result = appMgrClient->GetAllRenderProcesses(info);
|
||||
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
|
||||
HILOG_INFO("GetAllRenderProcesses_001 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppMgrClient_GetRenderProcessTerminationStatus_001
|
||||
* @tc.desc: can not get render process termination status with error pid.
|
||||
|
@ -101,6 +101,28 @@ HWTEST_F(AppMgrProxyTest, AppMgrProxy_GetProcessRunningInfosByUserId_0100, TestS
|
||||
GTEST_LOG_(INFO) << "AppMgrProxy_GetProcessRunningInfosByUserId_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AppMgrProxy_GetAllRenderProcesses_0100
|
||||
* @tc.desc: GetAllRenderProcesses
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrProxyTest, AppMgrProxy_GetAllRenderProcesses_0100, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AppMgrProxy_GetAllRenderProcesses_0100 start";
|
||||
|
||||
EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest));
|
||||
|
||||
std::vector<RenderProcessInfo> info;
|
||||
appMgrProxy_->GetAllRenderProcesses(info);
|
||||
|
||||
EXPECT_EQ(
|
||||
mockAppMgrService_->code_, static_cast<uint32_t>(IAppMgr::Message::APP_GET_ALL_RENDER_PROCESSES));
|
||||
|
||||
GTEST_LOG_(INFO) << "AppMgrProxy_GetAllRenderProcesses_0100 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetAppRunningStateByBundleName_0100
|
||||
* @tc.desc: Get app running state by bundle name.
|
||||
|
@ -869,6 +869,20 @@ HWTEST_F(AppMgrServiceInnerTest, GetProcessRunningInfosByUserId_001, TestSize.Le
|
||||
HILOG_INFO("GetProcessRunningInfosByUserId_001 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetAllRenderProcesses_001
|
||||
* @tc.desc: get all render processes.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerTest, GetAllRenderProcesses_001, TestSize.Level0)
|
||||
{
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
|
||||
std::vector<RenderProcessInfo> info;
|
||||
appMgrServiceInner->GetAllRenderProcesses(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NotifyMemoryLevel_001
|
||||
* @tc.desc: notify memory level.
|
||||
@ -1636,7 +1650,7 @@ HWTEST_F(AppMgrServiceInnerTest, RemoveAppFromRecentList_001, TestSize.Level0)
|
||||
std::string renderParam = "test_renderParam";
|
||||
std::shared_ptr<RenderRecord> renderRecord =
|
||||
RenderRecord::CreateRenderRecord(pid, renderParam, 1, 1, 1, appRecord);
|
||||
appRecord->SetRenderRecord(renderRecord);
|
||||
appRecord->AddRenderRecord(renderRecord);
|
||||
appMgrServiceInner->AddAppToRecentList(appName1, processName1, pid, 0);
|
||||
appRecord->SetKeepAliveAppState(true, true);
|
||||
appMgrServiceInner->RemoveAppFromRecentList(appName1, processName1);
|
||||
@ -1706,14 +1720,14 @@ HWTEST_F(AppMgrServiceInnerTest, ClearAppRunningData_001, TestSize.Level0)
|
||||
appMgrServiceInner->ClearAppRunningData(appRecord, false);
|
||||
|
||||
std::shared_ptr<RenderRecord> renderRecord;
|
||||
appRecord->SetRenderRecord(renderRecord);
|
||||
appRecord->AddRenderRecord(renderRecord);
|
||||
appMgrServiceInner->ClearAppRunningData(appRecord, false);
|
||||
|
||||
pid_t pid = 123;
|
||||
std::string renderParam = "test_renderParam";
|
||||
std::shared_ptr<RenderRecord> renderRecord1 =
|
||||
RenderRecord::CreateRenderRecord(pid, renderParam, 1, 1, 1, appRecord);
|
||||
appRecord->SetRenderRecord(renderRecord1);
|
||||
appRecord->AddRenderRecord(renderRecord1);
|
||||
appMgrServiceInner->ClearAppRunningData(appRecord, false);
|
||||
|
||||
appRecord->SetKeepAliveAppState(true, true);
|
||||
@ -2891,7 +2905,7 @@ HWTEST_F(AppMgrServiceInnerTest, StartRenderProcess_002, TestSize.Level0)
|
||||
|
||||
std::shared_ptr<RenderRecord> renderRecord =
|
||||
RenderRecord::CreateRenderRecord(hostPid1, renderParam, 1, 1, 1, appRecord);
|
||||
appRecord->SetRenderRecord(renderRecord);
|
||||
appRecord->AddRenderRecord(renderRecord);
|
||||
ret = appMgrServiceInner->StartRenderProcess(hostPid1, renderParam, 1, 1, 1, renderPid);
|
||||
EXPECT_EQ(ret, 8454244);
|
||||
|
||||
@ -2990,7 +3004,7 @@ HWTEST_F(AppMgrServiceInnerTest, AttachRenderProcess_001, TestSize.Level0)
|
||||
RenderRecord::CreateRenderRecord(pid, renderParam, 1, 1, 1, appRecord);
|
||||
EXPECT_NE(renderRecord, nullptr);
|
||||
renderRecord->SetPid(pid);
|
||||
appRecord->SetRenderRecord(renderRecord);
|
||||
appRecord->AddRenderRecord(renderRecord);
|
||||
appMgrServiceInner->AttachRenderProcess(pid, mockRenderScheduler);
|
||||
|
||||
appMgrServiceInner->appRunningManager_ = nullptr;
|
||||
|
@ -357,6 +357,41 @@ HWTEST_F(AppMgrServiceTest, GetProcessRunningInfosByUserId_001, TestSize.Level0)
|
||||
EXPECT_EQ(res, ERR_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AppMgrService
|
||||
* Function: GetAllRenderProcesses
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AppMgrService GetAllRenderProcesses
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify GetAllRenderProcesses
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceTest, GetAllRenderProcesses_001, TestSize.Level0)
|
||||
{
|
||||
auto appMgrService = std::make_shared<AppMgrService>();
|
||||
std::vector<RenderProcessInfo> info;
|
||||
appMgrService->SetInnerService(nullptr);
|
||||
int32_t res = appMgrService->GetAllRenderProcesses(info);
|
||||
EXPECT_EQ(res, ERR_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AppMgrService
|
||||
* Function: GetAllRenderProcesses
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: AppMgrService GetAllRenderProcesses
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify GetAllRenderProcesses
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceTest, GetAllRenderProcesses_002, TestSize.Level0)
|
||||
{
|
||||
auto appMgrService = std::make_shared<AppMgrService>();
|
||||
std::vector<RenderProcessInfo> info;
|
||||
appMgrService->SetInnerService(std::make_shared<AppMgrServiceInner>());
|
||||
appMgrService->handler_ = std::make_shared<AMSEventHandler>(runner_, appMgrService->appMgrServiceInner_);
|
||||
int32_t res = appMgrService->GetAllRenderProcesses(info);
|
||||
EXPECT_NE(res, ERR_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: AppMgrService
|
||||
* Function: NotifyMemoryLevel
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
MOCK_METHOD1(StartupResidentProcess, void(const std::vector<AppExecFwk::BundleInfo> &bundleInfos));
|
||||
MOCK_METHOD2(StartSpecifiedAbility, void(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo));
|
||||
MOCK_METHOD1(GetAllRunningProcesses, AppMgrResultCode(std::vector<RunningProcessInfo> &info));
|
||||
MOCK_METHOD1(GetAllRenderProcesses, AppMgrResultCode(std::vector<RenderProcessInfo> &info));
|
||||
MOCK_METHOD2(GetProcessRunningInfosByUserId, AppMgrResultCode(
|
||||
std::vector<RunningProcessInfo> &info, int32_t userId));
|
||||
MOCK_METHOD4(StartUserTestProcess, int(
|
||||
|
Loading…
x
Reference in New Issue
Block a user