mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
!19830 merge FixOnconnectDebugTimeOut into master
修复extension的onConnect调试超时 Created-by: SKY2001 Commit-by: SKY2001 Merged-by: openharmony_ci Description: **IssueNo**: https://gitcode.com/openharmony/ability_ability_runtime/issues/15641?ref=&did=4154168#tid-4154168 **Description**: **稳定性自检:** | 自检项 | 自检结果 | | ------------------------------------------------------------ | -------- | | 涉及跨进程调用的相关操作需要抛至主线程或加锁防止并发 | pass | | 成员变量进行赋值或创建需要排查并发 | pass | | 谨慎在lambda表达式中使用引用捕获 | pass | | 谨慎在未经拷贝的情况下使用外部传入的string、C字符串 | pass | | map\vector\list\set等stl模板类使用时需要排查并发 | pass | | 谨慎考虑加锁范围 | pass | | 在IPC通信中谨慎使用同步通信方式 | pass | | 禁止传递this指针至其他模块或线程(特别是eventhandler任务) | pass | | 禁止将外部传入的裸指针在内部直接构造智能指针 | pass | | 禁止多个独立创建的智能指针管理同一地址 | pass | | 禁止在析构函数中抛异步任务 | pass | | 禁止js对象在非js线程(例如在IPC线程)创建、使用或销毁 | pass | | 禁止在对外接口中未经判空直接使用外部传入的指针 | pass | | 禁止接口返回局部变量引用 | pass | | 禁止在信号函数中加锁 | pass | | 禁止在关键流程(SA启动、应用启动等主流程)执行耗时的操作 | pass | | 禁止将同一个cpp编译在不同的so中 | pass | **安全编码自检:** | 自检项 | 自检结果 | | -------------------------------------------------------------- | -------- | | 裸指针避免通过隐式转换构造为sptr | pass | | json对象在取值之前必须先判断类型,避免类型不匹配 | pass | | 序列化时必须对传入的数组大小进行校验,避免出现超大数组 | pass | | 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型 | pass | | 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验 | pass | | 指针变量、表示资源描述符的变量、bool变量必须赋初值 | pass | | readParcelable获取的对象使用前需要判空 | pass | | 分配和释放内存的函数需要成对出现 | pass | | 申请内存后异常退出前需要及时进行内存释放 | pass | | 内存申请前必须对内存大小进行合法性校验 | pass | | 内存分配后必须判断是否成功 | pass | | 禁止使用realloc、alloca函数 | pass | | 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰 | pass | | 禁止打印内存地址 | pass | | 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0 | pass | | 禁止对有符号整数进行位操作符运算 | pass | | 禁止对指针进行逻辑或位运算 | pass | | 循环次数如果收外部数据控制,需要检验其合法性 | pass | | 禁止使用内存操作类危险函数,需要使用安全函数 | pass | | 谨慎使用不可重入函数 | pass | | 必须检查安全函数的返回值,并进行正确处理 | pass | | 禁止仅通过TokenType类型判断绕过权限校验 | pass | **TDD Result**: pass **XTS Result**: pass ### 是否已执行L0用例 - [ ] 已验证 - [ ] 不涉及。如不涉及,请写明理由 See merge request: openharmony/ability_ability_runtime!19830
This commit is contained in:
@@ -812,6 +812,13 @@ public:
|
||||
*/
|
||||
bool IsMainProcessDebug(int32_t uid);
|
||||
|
||||
/**
|
||||
* @brief Query whether the corresponding process of the app (identified by abilityInfo) is in attach debug mode.
|
||||
* @param abilityInfo The ability info used to locate the corresponding process.
|
||||
* @return Returns true if the corresponding process is in attach debug mode, false otherwise.
|
||||
*/
|
||||
bool IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo);
|
||||
|
||||
/**
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
|
||||
@@ -701,6 +701,16 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Query whether the corresponding process of the app (identified by abilityInfo) is in attach debug mode.
|
||||
* @param abilityInfo The ability info used to locate the corresponding process.
|
||||
* @return Returns true if the corresponding process is in attach debug mode, false otherwise.
|
||||
*/
|
||||
virtual bool IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* start native process for debugger.
|
||||
*
|
||||
|
||||
@@ -163,6 +163,7 @@ enum class AppMgrInterfaceCode {
|
||||
REPORT_DUMP_MEM_RESULT = 138,
|
||||
IS_MAIN_PROCESS_DEBUG = 139,
|
||||
DUMP_JSHANDLE_MAP_PROCESS = 140,
|
||||
IS_CORRESPONDING_PROCESS_ATTACH_DEBUG = 141,
|
||||
};
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
|
||||
@@ -551,6 +551,13 @@ public:
|
||||
*/
|
||||
virtual bool IsMainProcessDebug(int32_t uid) override;
|
||||
|
||||
/**
|
||||
* @brief Query whether the corresponding process of the app (identified by abilityInfo) is in attach debug mode.
|
||||
* @param abilityInfo The ability info used to locate the corresponding process.
|
||||
* @return Returns true if the corresponding process is in attach debug mode, false otherwise.
|
||||
*/
|
||||
virtual bool IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo) override;
|
||||
|
||||
/**
|
||||
* start native process for debugger.
|
||||
*
|
||||
|
||||
@@ -137,6 +137,7 @@ private:
|
||||
#endif
|
||||
int32_t HandleIsSharedBundleRunning(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsMainProcessDebug(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsCorrespondingProcessAttachDebug(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleStartNativeProcessForDebugger(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleNotifyFault(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleNotifyFaultBySA(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -540,6 +540,15 @@ bool AppMgrClient::IsMainProcessDebug(int32_t uid)
|
||||
return service->IsMainProcessDebug(uid);
|
||||
}
|
||||
|
||||
bool AppMgrClient::IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return service->IsCorrespondingProcessAttachDebug(abilityInfo);
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::GetProcessRunningInfosByAccessTokenId(uint32_t accessTokenId,
|
||||
std::vector<RunningProcessInfo> &info)
|
||||
{
|
||||
|
||||
@@ -1609,6 +1609,27 @@ bool AppMgrProxy::IsMainProcessDebug(int32_t uid)
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool AppMgrProxy::IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed.");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteParcelable(&abilityInfo)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "abilityInfo write failed.");
|
||||
return false;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto ret = SendRequest(AppMgrInterfaceCode::IS_CORRESPONDING_PROCESS_ATTACH_DEBUG, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest failed, error code: %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::StartNativeProcessForDebugger(const AAFwk::Want &want)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
||||
@@ -475,6 +475,8 @@ int32_t AppMgrStub::OnRemoteRequestInnerNinth(uint32_t code, MessageParcel &data
|
||||
return HandleEnableDelayedProcessExit(data, reply);
|
||||
case static_cast<uint32_t>(AppMgrInterfaceCode::CANCEL_DELAYED_EXIT_TASK):
|
||||
return HandleCancelDelayedExitTask(data, reply);
|
||||
case static_cast<uint32_t>(AppMgrInterfaceCode::IS_CORRESPONDING_PROCESS_ATTACH_DEBUG):
|
||||
return HandleIsCorrespondingProcessAttachDebug(data, reply);
|
||||
}
|
||||
return INVALID_FD;
|
||||
}
|
||||
@@ -1503,6 +1505,21 @@ int32_t AppMgrStub::HandleIsMainProcessDebug(MessageParcel &data, MessageParcel
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleIsCorrespondingProcessAttachDebug(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::unique_ptr<AbilityInfo> abilityInfo(data.ReadParcelable<AbilityInfo>());
|
||||
if (abilityInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "abilityInfo is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
bool result = IsCorrespondingProcessAttachDebug(*abilityInfo);
|
||||
if (!reply.WriteBool(result)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleStartNativeProcessForDebugger(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
||||
@@ -667,6 +667,13 @@ public:
|
||||
*/
|
||||
bool IsMainProcessDebug(int32_t uid);
|
||||
|
||||
/**
|
||||
* @brief Query whether the corresponding process of the app (identified by abilityInfo) is in attach debug mode.
|
||||
* @param abilityInfo The ability info used to locate the corresponding process.
|
||||
* @return Returns true if the corresponding process is in attach debug mode, false otherwise.
|
||||
*/
|
||||
bool IsCorrespondingProcessAttachDebug(const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
|
||||
/**
|
||||
* To clear the process by ability token.
|
||||
*
|
||||
|
||||
@@ -1322,7 +1322,7 @@ void AbilityConnectManager::LoadAbility(const std::shared_ptr<BaseExtensionRecor
|
||||
}
|
||||
int32_t loadTimeoutFinal =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * GetLoadTimeout(loadTimeout);
|
||||
if (!abilityRecord->IsDebugApp()) {
|
||||
if (!abilityRecord->IsDebug()) {
|
||||
TAG_LOGD(AAFwkTag::EXT, "IsDebug is false, here is not debug app");
|
||||
PostLoadTimeoutTask(abilityRecord, loadTimeoutFinal);
|
||||
}
|
||||
@@ -1573,7 +1573,11 @@ void AbilityConnectManager::PostTimeOutTask(const std::shared_ptr<BaseExtensionR
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
CHECK_POINTER(taskHandler_);
|
||||
|
||||
if (abilityRecord->IsDebug()) {
|
||||
TAG_LOGD(AAFwkTag::EXT, "Debug task: %{public}s/%{public}s" PRId64,
|
||||
abilityRecord->GetAbilityInfo().bundleName.c_str(), abilityRecord->GetAbilityInfo().name.c_str());
|
||||
return;
|
||||
}
|
||||
std::string taskName;
|
||||
auto recordId = abilityRecord->GetAbilityRecordId();
|
||||
TAG_LOGD(AAFwkTag::EXT, "task: %{public}s/%{public}s, %{public}d, %{public}" PRId64,
|
||||
@@ -3422,6 +3426,13 @@ void AbilityConnectManager::GetOrCreateServiceRecord(const AbilityRequest &abili
|
||||
TAG_LOGD(AAFwkTag::EXT, "AGENT extension inherit debug from main process, ability:%{public}s",
|
||||
abilityRequest.abilityInfo.name.c_str());
|
||||
}
|
||||
bool isAttachDebug = IN_PROCESS_CALL(
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->IsCorrespondingProcessAttachDebug(
|
||||
abilityRequest.abilityInfo));
|
||||
targetService->SetAttachDebug(isAttachDebug);
|
||||
TAG_LOGD(AAFwkTag::EXT, "AGENT extension sync attach debug from corresponding process, "
|
||||
"ability:%{public}s, isAttachDebug:%{public}d",
|
||||
abilityRequest.abilityInfo.name.c_str(), isAttachDebug);
|
||||
}
|
||||
isLoadedAbility = false;
|
||||
|
||||
|
||||
@@ -722,6 +722,12 @@ bool AppScheduler::IsMainProcessDebug(int32_t uid)
|
||||
return appMgrClient_->IsMainProcessDebug(uid);
|
||||
}
|
||||
|
||||
bool AppScheduler::IsCorrespondingProcessAttachDebug(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(appMgrClient_, false);
|
||||
return appMgrClient_->IsCorrespondingProcessAttachDebug(abilityInfo);
|
||||
}
|
||||
|
||||
void AppScheduler::ClearProcessByToken(sptr<IRemoteObject> token) const
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
||||
@@ -602,6 +602,13 @@ public:
|
||||
*/
|
||||
virtual bool IsMainProcessDebug(int32_t uid) override;
|
||||
|
||||
/**
|
||||
* @brief Query whether the corresponding process of the app (identified by abilityInfo) is in attach debug mode.
|
||||
* @param abilityInfo The ability info used to locate the corresponding process.
|
||||
* @return Returns true if the corresponding process is in attach debug mode, false otherwise.
|
||||
*/
|
||||
virtual bool IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo) override;
|
||||
|
||||
/**
|
||||
* start native process for debugger.
|
||||
*
|
||||
|
||||
@@ -1226,6 +1226,8 @@ public:
|
||||
|
||||
bool IsMainProcessDebug(int32_t uid);
|
||||
|
||||
bool IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo);
|
||||
|
||||
/**
|
||||
* Notify Fault Data
|
||||
*
|
||||
|
||||
@@ -1512,6 +1512,15 @@ bool AppMgrService::IsMainProcessDebug(int32_t uid)
|
||||
return appMgrServiceInner_->IsMainProcessDebug(uid);
|
||||
}
|
||||
|
||||
bool AppMgrService::IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "not ready");
|
||||
return false;
|
||||
}
|
||||
return appMgrServiceInner_->IsCorrespondingProcessAttachDebug(abilityInfo);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
|
||||
@@ -9975,6 +9975,43 @@ bool AppMgrServiceInner::IsMainProcessDebug(int32_t uid)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AppMgrServiceInner::IsCorrespondingProcessAttachDebug(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
if (IPCSkeleton::GetCallingUid() != FOUNDATION_UID) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "not foundation call");
|
||||
return false;
|
||||
}
|
||||
bool isAgentUI = AAFwk::UIExtensionWrapper::IsAgentUIExtension(abilityInfo.extensionAbilityType);
|
||||
if (!isAgentUI && abilityInfo.extensionAbilityType != AppExecFwk::ExtensionAbilityType::AGENT) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Not agentUI or agent extension");
|
||||
return false;
|
||||
}
|
||||
if (!CheckRemoteClient() || !appRunningManager_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "nullptr");
|
||||
return false;
|
||||
}
|
||||
auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo);
|
||||
int32_t appIndex = abilityInfo.appIndex;
|
||||
BundleInfo bundleInfo;
|
||||
HapModuleInfo hapModuleInfo;
|
||||
if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetBundleAndHapInfo failed");
|
||||
return false;
|
||||
}
|
||||
auto abilityInfoPtr = std::make_shared<AbilityInfo>(abilityInfo);
|
||||
std::string processName = appInfo->bundleName + ":" + AGENT_EXTENSION_TYPE;;
|
||||
std::string customProcessFlag = "";
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "processName: %{public}s, customProcessFlag: %{public}s",
|
||||
processName.c_str(), customProcessFlag.c_str());
|
||||
auto appRecord = appRunningManager_->CheckAppRunningRecordIsExist(appInfo->name,
|
||||
processName, appInfo->uid, bundleInfo, "", nullptr, "", customProcessFlag);
|
||||
if (appRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRecord nullptr");
|
||||
return false;
|
||||
}
|
||||
return appRecord->IsAttachDebug();
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::KillRenderProcess(const std::shared_ptr<AppRunningRecord> &appRecord) {
|
||||
if (appRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRecord null");
|
||||
|
||||
@@ -359,6 +359,11 @@ bool AppScheduler::IsMainProcessDebug(int32_t uid)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AppScheduler::IsCorrespondingProcessAttachDebug(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void AppScheduler::OnCacheExitInfo(uint32_t accessTokenId, const AppExecFwk::RunningProcessInfo &exitInfo,
|
||||
const std::string &bundleName, const std::vector<std::string> &abilityNames,
|
||||
const std::vector<std::string> &uiExtensionNames) {}
|
||||
|
||||
+130
@@ -2941,5 +2941,135 @@ HWTEST_F(AppMgrServiceInnerSecondTest, IsMainProcessDebug_006, TestSize.Level1)
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsMainProcessDebug_006 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCorrespondingProcessAttachDebug_001
|
||||
* @tc.desc: Test IsCorrespondingProcessAttachDebug when caller is not foundation process, should return false.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerSecondTest, IsCorrespondingProcessAttachDebug_001, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_001 start");
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
|
||||
IPCSkeleton::SetCallingUid(0); // not foundation uid
|
||||
AbilityInfo abilityInfo;
|
||||
abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::AGENT;
|
||||
EXPECT_FALSE(appMgrServiceInner->IsCorrespondingProcessAttachDebug(abilityInfo));
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_001 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCorrespondingProcessAttachDebug_002
|
||||
* @tc.desc: Test IsCorrespondingProcessAttachDebug when extension type is not agent, should return false.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerSecondTest, IsCorrespondingProcessAttachDebug_002, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_002 start");
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
|
||||
IPCSkeleton::SetCallingUid(FOUNDATION_UID); // foundation call
|
||||
AbilityInfo abilityInfo;
|
||||
// default extensionAbilityType is not AGENT or AgentUI
|
||||
EXPECT_FALSE(appMgrServiceInner->IsCorrespondingProcessAttachDebug(abilityInfo));
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_002 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCorrespondingProcessAttachDebug_003
|
||||
* @tc.desc: Test IsCorrespondingProcessAttachDebug when remoteClientManager_ is nullptr, should return false.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerSecondTest, IsCorrespondingProcessAttachDebug_003, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_003 start");
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
appMgrServiceInner->remoteClientManager_ = nullptr;
|
||||
appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
|
||||
IPCSkeleton::SetCallingUid(FOUNDATION_UID); // foundation call
|
||||
AbilityInfo abilityInfo;
|
||||
abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::AGENT;
|
||||
EXPECT_FALSE(appMgrServiceInner->IsCorrespondingProcessAttachDebug(abilityInfo));
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_003 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCorrespondingProcessAttachDebug_004
|
||||
* @tc.desc: Test IsCorrespondingProcessAttachDebug when spawn client is nullptr, should return false.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerSecondTest, IsCorrespondingProcessAttachDebug_004, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_004 start");
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
appMgrServiceInner->remoteClientManager_ = std::make_shared<RemoteClientManager>();
|
||||
appMgrServiceInner->remoteClientManager_->SetSpawnClient(nullptr);
|
||||
appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
|
||||
IPCSkeleton::SetCallingUid(FOUNDATION_UID); // foundation call
|
||||
AbilityInfo abilityInfo;
|
||||
abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::AGENT;
|
||||
EXPECT_FALSE(appMgrServiceInner->IsCorrespondingProcessAttachDebug(abilityInfo));
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_004 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCorrespondingProcessAttachDebug_005
|
||||
* @tc.desc: Test IsCorrespondingProcessAttachDebug when bundle manager helper is nullptr, should return false.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerSecondTest, IsCorrespondingProcessAttachDebug_005, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_005 start");
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
appMgrServiceInner->remoteClientManager_ = std::make_shared<RemoteClientManager>();
|
||||
// spawn client is created by RemoteClientManager constructor, but bundle manager helper is not set
|
||||
appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
|
||||
IPCSkeleton::SetCallingUid(FOUNDATION_UID); // foundation call
|
||||
AbilityInfo abilityInfo;
|
||||
abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::AGENT;
|
||||
EXPECT_FALSE(appMgrServiceInner->IsCorrespondingProcessAttachDebug(abilityInfo));
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_005 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCorrespondingProcessAttachDebug_006
|
||||
* @tc.desc: Test IsCorrespondingProcessAttachDebug when appRunningManager_ is nullptr, should return false.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerSecondTest, IsCorrespondingProcessAttachDebug_006, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_006 start");
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
appMgrServiceInner->remoteClientManager_ = std::make_shared<RemoteClientManager>();
|
||||
appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(bundleMgrHelper_);
|
||||
appMgrServiceInner->appRunningManager_ = nullptr;
|
||||
IPCSkeleton::SetCallingUid(FOUNDATION_UID); // foundation call
|
||||
AbilityInfo abilityInfo;
|
||||
abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::AGENT;
|
||||
EXPECT_FALSE(appMgrServiceInner->IsCorrespondingProcessAttachDebug(abilityInfo));
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_006 end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: IsCorrespondingProcessAttachDebug_007
|
||||
* @tc.desc: Test IsCorrespondingProcessAttachDebug when GetBundleAndHapInfo fails, should return false.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AppMgrServiceInnerSecondTest, IsCorrespondingProcessAttachDebug_007, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_007 start");
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
appMgrServiceInner->remoteClientManager_ = std::make_shared<RemoteClientManager>();
|
||||
appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(bundleMgrHelper_);
|
||||
appMgrServiceInner->appRunningManager_ = std::make_shared<AppRunningManager>();
|
||||
IPCSkeleton::SetCallingUid(FOUNDATION_UID); // foundation call
|
||||
AbilityInfo abilityInfo;
|
||||
abilityInfo.bundleName = "com.test.attachdebug";
|
||||
abilityInfo.applicationInfo.bundleName = "com.test.attachdebug";
|
||||
abilityInfo.extensionAbilityType = AppExecFwk::ExtensionAbilityType::AGENT;
|
||||
EXPECT_FALSE(appMgrServiceInner->IsCorrespondingProcessAttachDebug(abilityInfo));
|
||||
TAG_LOGI(AAFwkTag::TEST, "IsCorrespondingProcessAttachDebug_007 end");
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
Reference in New Issue
Block a user