From 0403db15ab217966f7bfbfe7948e383374df08fc Mon Sep 17 00:00:00 2001 From: zhang_hao_zheng Date: Thu, 28 Aug 2025 16:28:17 +0800 Subject: [PATCH] chage enableIsolationUid to isolationUid Signed-off-by: zhang_hao_zheng Change-Id: I9d059bf14e79be793b459e1904d00b7d172d2eb2 --- .../src/native_child_process.cpp | 4 ++-- .../child_process/native_child_process.h | 19 +++++++++++-------- services/appmgr/src/app_mgr_service_inner.cpp | 7 +++---- .../mock/include/mock_app_mgr_service.h | 2 +- .../child_process_manager_test.cpp | 3 ++- .../mock/include/mock_child_process_manager.h | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/frameworks/native/child_process/src/native_child_process.cpp b/frameworks/native/child_process/src/native_child_process.cpp index 41daea91e6..5fc1852644 100644 --- a/frameworks/native/child_process/src/native_child_process.cpp +++ b/frameworks/native/child_process/src/native_child_process.cpp @@ -346,12 +346,12 @@ Ability_NativeChildProcess_ErrCode OH_Ability_UnregisterNativeChildProcessExitCa } Ability_NativeChildProcess_ErrCode OH_Ability_ChildProcessConfigs_SetIsolationUid( - Ability_ChildProcessConfigs* configs, bool enableIsolationUid) + Ability_ChildProcessConfigs* configs, bool isolationUid) { if (configs == nullptr) { TAG_LOGE(AAFwkTag::PROCESSMGR, "null Ability_ChildProcessConfigs"); return NCP_ERR_INVALID_PARAM; } - configs->isIsolationUid = enableIsolationUid; + configs->isIsolationUid = isolationUid; return NCP_NO_ERROR; } \ No newline at end of file diff --git a/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h b/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h index 270c8741eb..288c51857e 100644 --- a/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h +++ b/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h @@ -176,17 +176,20 @@ Ability_NativeChildProcess_ErrCode OH_Ability_ChildProcessConfigs_SetIsolationMo Ability_ChildProcessConfigs* configs, NativeChildProcess_IsolationMode isolationMode); /** - * @brief Sets whether to enable the isolation UID for the specified child process configs. - * The isolationUid only takes effect in {@link OH_Ability_StartNativeChildProcessWithConfigs}. - * + * @brief Sets the UID isolation flag for the specified child process configs. + * The isolationUid only takes effect when {@link OH_Ability_ChildProcessConfigs_SetIsolationMode} + * is set to {@link NCP_ISOLATION_MODE_ISOLATED}. + * * @param configs Pointer to the child process configs object. Must not be nullptr. - * @param enableIsolationUid Whether to enable the isolation UID. - * @return Returns {@link NCP_NO_ERROR} if the isolation UID is set successful. - * Returns {@link NCP_NO_ERR_INVALID_PARAM} if the input parameters are invalid. - * @since 20 + * @param isolationUid The UID isolation setting to apply. + * - true: uses independent UID + * - false: uses parent process's UID + * @return Returns {@link NCP_NO_ERROR} if the UID isolation flag is set successfully. + * Returns {@link NCP_ERR_INVALID_PARAM} if the input parameters are invalid. + * @since 21 */ Ability_NativeChildProcess_ErrCode OH_Ability_ChildProcessConfigs_SetIsolationUid( - Ability_ChildProcessConfigs* configs, bool enableIsolationUid); + Ability_ChildProcessConfigs* configs, bool isolationUid); /** * @brief Sets the process name for the specified child process configs. diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 233fb0662f..f63896abd5 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -8500,10 +8500,9 @@ int32_t AppMgrServiceInner::StartChildProcess(const pid_t callingPid, pid_t &chi auto &options = request.options; childProcessRecord->SetEntryParams(args.entryParams); TAG_LOGI(AAFwkTag::APPMGR, "srcEntry:%{private}s, args.entryParams size:%{public}zu," - " processName:%{public}s, args.fds size:%{public}zu, options.isolationMode:%{public}d," - "option.isolationUid: %{public}d", + " processName:%{public}s, args.fds size:%{public}zu, options.isolationMode:%{public}d,", request.srcEntry.c_str(), args.entryParams.length(), childProcessRecord->GetProcessName().c_str(), - args.fds.size(), options.isolationMode, options.isolationUid); + args.fds.size(), options.isolationMode); return StartChildProcessImpl(childProcessRecord, appRecord, childPid, args, options); } @@ -8722,7 +8721,7 @@ int32_t AppMgrServiceInner::GetChildProcessInfo(const std::shared_ptrGetBaseSharedBundleInfos(bundleInfo.name, info.hspList, + if (IN_PROCESS_CALL(bundleMgrHelper->GetBaseSharedBundleInfos(appRecord->GetBundleName(), info.hspList, AppExecFwk::GetDependentBundleInfoFlag::GET_ALL_DEPENDENT_BUNDLE_INFO))) { TAG_LOGE(AAFwkTag::APPMGR, "GetBaseSharedBundleInfos fail"); return ERR_INVALID_VALUE; diff --git a/test/unittest/ability_permission_util_second_test/mock/include/mock_app_mgr_service.h b/test/unittest/ability_permission_util_second_test/mock/include/mock_app_mgr_service.h index bec44c09bb..c320e789f3 100644 --- a/test/unittest/ability_permission_util_second_test/mock/include/mock_app_mgr_service.h +++ b/test/unittest/ability_permission_util_second_test/mock/include/mock_app_mgr_service.h @@ -113,7 +113,7 @@ public: MOCK_METHOD2(SetProcessCacheEnable, int32_t(int32_t pid, bool enable)); MOCK_METHOD2(SetSupportedProcessCache, int32_t(int32_t pid, bool isSupport)); #ifdef SUPPORT_CHILD_PROCESS - MOCK_METHOD4(CreateNativeChildProcess, int32_t(const std::string &libName, + MOCK_METHOD3(CreateNativeChildProcess, int32_t(const std::string &libName, const sptr &callback, const ChildProcessRequest &request)); #endif // SUPPORT_CHILD_PROCESS MOCK_METHOD2(GetSupportedProcessCachePids, int32_t(const std::string &bundleName, diff --git a/test/unittest/child_process_manager_test/child_process_manager_test.cpp b/test/unittest/child_process_manager_test/child_process_manager_test.cpp index 2f7d078f1a..e37dbe7d33 100644 --- a/test/unittest/child_process_manager_test/child_process_manager_test.cpp +++ b/test/unittest/child_process_manager_test/child_process_manager_test.cpp @@ -334,7 +334,8 @@ HWTEST_F(ChildProcessManagerTest, CreateNativeChildProcessByAppSpawnFork_0200, T { TAG_LOGD(AAFwkTag::TEST, "CreateNativeChildProcessByAppSpawnFork_0200 called."); sptr callback; - auto ret = ChildProcessManager::GetInstance().CreateNativeChildProcessByAppSpawnFork("test.so", callback, "abc_123"); + auto ret = ChildProcessManager::GetInstance().CreateNativeChildProcessByAppSpawnFork("test.so", callback, + "abc_123"); EXPECT_NE(ret, ChildProcessManagerErrorCode::ERR_FORK_FAILED); } diff --git a/test/unittest/native_child_process_test/mock/include/mock_child_process_manager.h b/test/unittest/native_child_process_test/mock/include/mock_child_process_manager.h index 33ca87aca0..a0521a3c38 100644 --- a/test/unittest/native_child_process_test/mock/include/mock_child_process_manager.h +++ b/test/unittest/native_child_process_test/mock/include/mock_child_process_manager.h @@ -45,7 +45,7 @@ public: ChildProcessManagerErrorCode StartChildProcessWithArgs(const std::string &srcEntry, pid_t &pid, int32_t childProcessType, const AppExecFwk::ChildProcessArgs &args, const AppExecFwk::ChildProcessOptions &options); - ChildProcessManagerErrorCode CreateChildProcessByAppSpawnFork( + ChildProcessManagerErrorCode CreateNativeChildProcessByAppSpawnFork( const std::string &libName, const sptr &callbackStub, const std::string &customProcessName = "", const bool isolationMode = false, const bool isIsolationUid = false); bool GetBundleInfo(AppExecFwk::BundleInfo &bundleInfo);