diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 068e934151..65f4d37271 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -1565,15 +1565,16 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con debugOption.isDebugApp = appInfo.debug; debugOption.isStartWithNative = appLaunchData.isNativeStart(); debugOption.appProvisionType = applicationInfo_->appProvisionType; + debugOption.isDebugFromLocal = appLaunchData.GetDebugFromLocal(); + debugOption.perfCmd = perfCmd; + debugOption.isDeveloperMode = isDeveloperMode_; + runtime->SetDebugOption(debugOption); if (perfCmd.find(PERFCMD_PROFILE) != std::string::npos || perfCmd.find(PERFCMD_DUMPHEAP) != std::string::npos) { TAG_LOGD(AAFwkTag::APPKIT, "perfCmd is %{public}s", perfCmd.c_str()); - debugOption.perfCmd = perfCmd; runtime->StartProfiler(debugOption); } else { - if (isDeveloperMode_) { - runtime->StartDebugMode(debugOption); - } + runtime->StartDebugMode(debugOption); } std::vector hqfInfos = appInfo.appQuickFix.deployedAppqfInfo.hqfInfos; @@ -3484,10 +3485,47 @@ int32_t MainThread::ChangeAppGcState(int32_t state) return NO_ERROR; } -void MainThread::AttachAppDebug() +void MainThread::AttachAppDebug(bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::APPKIT, "called"); SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ATTACH_DEBUG_MODE, true); + + if (!isDebugFromLocal) { + TAG_LOGE(AAFwkTag::APPKIT, "no local debug"); + return; + } + wptr weak = this; + auto task = [weak] { + auto appThread = weak.promote(); + if (appThread == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "null appThread"); + return; + } + appThread->OnAttachLocalDebug(true); + }; + if (mainHandler_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "null handler"); + return; + } + if (!mainHandler_->PostTask(task, "MainThread:AttachAppDebug")) { + TAG_LOGE(AAFwkTag::APPKIT, "PostTask task failed"); + } +} + +int32_t MainThread::OnAttachLocalDebug(bool isDebugFromLocal) +{ + TAG_LOGD(AAFwkTag::APPKIT, "called"); + if (application_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "null application_"); + return ERR_INVALID_VALUE; + } + auto &runtime = application_->GetRuntime(); + if (runtime == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "null runtime"); + return ERR_INVALID_VALUE; + } + runtime->StartLocalDebugMode(isDebugFromLocal); + return NO_ERROR; } void MainThread::DetachAppDebug() diff --git a/frameworks/native/runtime/cj_runtime.cpp b/frameworks/native/runtime/cj_runtime.cpp index d52420c02d..e81308c68a 100644 --- a/frameworks/native/runtime/cj_runtime.cpp +++ b/frameworks/native/runtime/cj_runtime.cpp @@ -231,6 +231,7 @@ void CJRuntime::StartDebugMode(const DebugOption dOption) TAG_LOGI(AAFwkTag::CJRUNTIME, "StartDebugMode %{public}s", bundleName_.c_str()); HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp, + HdcRegister::DebugRegisterMode::HDC_DEBUG_REG, [bundleName, isStartWithDebug, isDebugApp, instanceId](int socketFd, std::string option) { TAG_LOGI(AAFwkTag::CJRUNTIME, "hdcRegister callback call, socket fd: %{public}d, option: %{public}s.", socketFd, option.c_str()); diff --git a/frameworks/native/runtime/hdc_register.cpp b/frameworks/native/runtime/hdc_register.cpp index 79b7ff366c..219e7ba8f7 100644 --- a/frameworks/native/runtime/hdc_register.cpp +++ b/frameworks/native/runtime/hdc_register.cpp @@ -37,37 +37,64 @@ HdcRegister& HdcRegister::Get() } void HdcRegister::StartHdcRegister(const std::string& bundleName, const std::string& processName, bool debugApp, - HdcRegisterCallback callback) + DebugRegisterMode debugMode, HdcRegisterCallback callback) { TAG_LOGD(AAFwkTag::JSRUNTIME, "called"); - registerHandler_ = dlopen("libhdc_register.z.so", RTLD_LAZY); - if (registerHandler_ == nullptr) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "null registerHandler_"); - return; + if (debugMode == BOTH_REG) { + registerLocalHandler_ = dlopen("libda_register.z.so", RTLD_LAZY); + registerHdcHandler_ = dlopen("libhdc_register.z.so", RTLD_LAZY); + } else if (debugMode == LOCAL_DEBUG_REG) { + registerLocalHandler_ = dlopen("libda_register.z.so", RTLD_LAZY); + } else { + registerHdcHandler_ = dlopen("libhdc_register.z.so", RTLD_LAZY); } - auto startRegister = reinterpret_cast(dlsym(registerHandler_, "StartConnect")); - if (startRegister == nullptr) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "null StartConnect"); - return; + if (registerLocalHandler_ != nullptr) { + auto startRegister = reinterpret_cast(dlsym(registerLocalHandler_, "StartConnect")); + if (startRegister != nullptr) { + startRegister(processName, bundleName, debugApp, callback); + } + } else { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null registerLocalHandler_"); + } + if (registerHdcHandler_ != nullptr) { + auto startRegister = reinterpret_cast(dlsym(registerHdcHandler_, "StartConnect")); + if (startRegister != nullptr) { + startRegister(processName, bundleName, debugApp, callback); + } + } else { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null registerHdcHandler_"); } - startRegister(processName, bundleName, debugApp, callback); } void HdcRegister::StopHdcRegister() { TAG_LOGD(AAFwkTag::JSRUNTIME, "called"); - if (registerHandler_ == nullptr) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "null registerHandler_"); - return; - } - auto stopRegister = reinterpret_cast(dlsym(registerHandler_, "StopConnect")); - if (stopRegister != nullptr) { - stopRegister(); + + if (registerLocalHandler_ != nullptr) { + auto stopRegister = reinterpret_cast(dlsym(registerLocalHandler_, "StopConnect")); + if (stopRegister != nullptr) { + stopRegister(); + } else { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null StopConnect"); + } + dlclose(registerLocalHandler_); + registerLocalHandler_ = nullptr; } else { - TAG_LOGE(AAFwkTag::JSRUNTIME, "null StopConnect"); + TAG_LOGE(AAFwkTag::JSRUNTIME, "null registerLocalHandler_"); + } + + if (registerHdcHandler_ != nullptr) { + auto stopRegister = reinterpret_cast(dlsym(registerHdcHandler_, "StopConnect")); + if (stopRegister != nullptr) { + stopRegister(); + } else { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null StopConnect"); + } + dlclose(registerHdcHandler_); + registerHdcHandler_ = nullptr; + } else { + TAG_LOGE(AAFwkTag::JSRUNTIME, "null registerHdcHandler_"); } - dlclose(registerHandler_); - registerHandler_ = nullptr; } } // namespace OHOS::AbilityRuntime diff --git a/frameworks/native/runtime/hdc_register.h b/frameworks/native/runtime/hdc_register.h index b263f621f9..132a818fa2 100644 --- a/frameworks/native/runtime/hdc_register.h +++ b/frameworks/native/runtime/hdc_register.h @@ -25,9 +25,14 @@ using HdcRegisterCallback = std::function JsRuntime::Create(const Options& options) void JsRuntime::StartDebugMode(const DebugOption dOption) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); - if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { + TAG_LOGD(AAFwkTag::JSRUNTIME, "localDebug %{public}d", dOption.isDebugFromLocal); + if (!dOption.isDebugFromLocal && !dOption.isDeveloperMode) { TAG_LOGE(AAFwkTag::JSRUNTIME, "developer Mode false"); return; } @@ -183,12 +184,18 @@ void JsRuntime::StartDebugMode(const DebugOption dOption) uint32_t instanceId = instanceId_; auto weak = jsEnv_; std::string inputProcessName = bundleName_ != dOption.processName ? dOption.processName : ""; - HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp, [bundleName, - isStartWithDebug, instanceId, weak, isDebugApp, appProvisionType] (int socketFd, std::string option) { - TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister msg, fd= %{public}d, option= %{public}s", - socketFd, option.c_str()); + HdcRegister::DebugRegisterMode debugMode = HdcRegister::DebugRegisterMode::HDC_DEBUG_REG; + if (debugOption_.isDebugFromLocal && debugOption_.isDeveloperMode) { + debugMode = HdcRegister::DebugRegisterMode::BOTH_REG; + } else if (debugOption_.isDebugFromLocal) { + debugMode = HdcRegister::DebugRegisterMode::LOCAL_DEBUG_REG; + } + HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp, debugMode, + [bundleName, isStartWithDebug, instanceId, weak, isDebugApp, appProvisionType] + (int socketFd, std::string option) { + TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister msg, fd= %{public}d, option= %{public}s", socketFd, option.c_str()); if (weak == nullptr) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "null weak"); + TAG_LOGE(AAFwkTag::JSRUNTIME, "null weak"); return; } // system is debuggable when const.secure is false and const.debuggable is true @@ -317,7 +324,8 @@ int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_ void JsRuntime::StartProfiler(const DebugOption dOption) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); - if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { + TAG_LOGD(AAFwkTag::JSRUNTIME, "localDebug %{public}d", dOption.isDebugFromLocal); + if (!dOption.isDebugFromLocal && !dOption.isDeveloperMode) { TAG_LOGE(AAFwkTag::JSRUNTIME, "developer Mode false"); return; } @@ -335,6 +343,7 @@ void JsRuntime::StartProfiler(const DebugOption dOption) uint32_t instanceId = instanceId_; std::string inputProcessName = bundleName_ != dOption.processName ? dOption.processName : ""; HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp, + HdcRegister::DebugRegisterMode::HDC_DEBUG_REG, [bundleName, isStartWithDebug, instanceId, weak, isDebugApp, appProvisionType](int socketFd, std::string option) { TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister msg, fd= %{public}d, option= %{public}s", socketFd, option.c_str()); if (weak == nullptr) { @@ -1673,5 +1682,15 @@ void JsRuntime::UpdatePkgContextInfoJson(const std::string& moduleName, const st panda::JSNApi::UpdatePkgNameList(vm, packageNameList); } +void JsRuntime::SetDebugOption(const DebugOption debugOption) +{ + debugOption_ = debugOption; +} + +void JsRuntime::StartLocalDebugMode(bool isDebugFromLocal) +{ + debugOption_.isDebugFromLocal = isDebugFromLocal; + StartDebugMode(debugOption_); +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index 962fcaf7f4..bd5f2d95ab 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1418,14 +1418,14 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - ErrCode AttachAppDebug(const std::string &bundleName); + ErrCode AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal = false); /** * @brief Detach app debug. * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - ErrCode DetachAppDebug(const std::string &bundleName); + ErrCode DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal = false); /** * @brief Check if ability controller can start. diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index c1450b188d..92b992425d 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -1640,14 +1640,14 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - virtual int32_t AttachAppDebug(const std::string &bundleName) = 0; + virtual int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) = 0; /** * @brief Detach app debug. * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - virtual int32_t DetachAppDebug(const std::string &bundleName) = 0; + virtual int32_t DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal) = 0; /** * @brief Execute intent. diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h index 58bbcf6e9b..1482fe41bc 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h @@ -335,7 +335,7 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - virtual int32_t AttachAppDebug(const std::string &bundleName) = 0; + virtual int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) = 0; /** * @brief Detach app debug. diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h index 8197459a1a..ecc3e5942c 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h @@ -296,7 +296,7 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName) override; + int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; /** * @brief Detach app debug. diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_launch_data.h b/interfaces/inner_api/app_manager/include/appmgr/app_launch_data.h index ac46a4f962..6816d529c6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_launch_data.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_launch_data.h @@ -299,6 +299,19 @@ public: */ bool IsAllowedNWebPreload() const; + /** + * @brief Setting debug mode. + * + * @param ideDebugMode, false:old debug, true:local debug. + */ + void SetDebugFromLocal(bool isDebugFromLocal); + /** + * @brief Get debug mode. + * + * @return Returns debug mode. + */ + bool GetDebugFromLocal() const; + private: bool debugApp_ = false; bool jitEnabled_ = false; @@ -318,6 +331,7 @@ private: std::string appRunningUniqueId_; std::string instanceKey_; std::string preloadModuleName_; + bool isDebugFromLocal_; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index 2a34827d8c..3f7108c7f4 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -642,7 +642,7 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName); + int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal); /** * @brief Detach app debug. diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h index 36188d7638..333c51c0ed 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_interface.h @@ -256,7 +256,7 @@ public: /** * @brief Attach app debug. */ - virtual void AttachAppDebug() = 0; + virtual void AttachAppDebug(bool isDebugFromLocal) = 0; /** * @brief Detach app debug. diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h index 05ea98ca59..f51cc0cce9 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_scheduler_proxy.h @@ -249,7 +249,7 @@ public: /** * @brief Attach app debug. */ - void AttachAppDebug() override; + void AttachAppDebug(bool isDebugFromLocal) override; /** * @brief Detach app debug. diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp index dff4e18be7..834fdec2f1 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp @@ -991,7 +991,7 @@ int32_t AmsMgrProxy::UnregisterAppDebugListener(const sptr &l return reply.ReadInt32(); } -int32_t AmsMgrProxy::AttachAppDebug(const std::string &bundleName) +int32_t AmsMgrProxy::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::APPMGR, "called"); MessageParcel data; @@ -1005,6 +1005,11 @@ int32_t AmsMgrProxy::AttachAppDebug(const std::string &bundleName) return ERR_INVALID_DATA; } + if (!data.WriteBool(isDebugFromLocal)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write isDebugFromLocal failed"); + return ERR_INVALID_DATA; + } + MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::ATTACH_APP_DEBUG), diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp index 251c8b8882..f91b614670 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp @@ -651,8 +651,9 @@ int32_t AmsMgrStub::HandleAttachAppDebug(MessageParcel &data, MessageParcel &rep TAG_LOGE(AAFwkTag::APPMGR, "Bundle name is empty."); return ERR_INVALID_VALUE; } + auto isDebugFromLocal = data.ReadBool(); - auto result = AttachAppDebug(bundleName); + auto result = AttachAppDebug(bundleName, isDebugFromLocal); if (!reply.WriteInt32(result)) { TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result."); return ERR_INVALID_VALUE; diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_launch_data.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_launch_data.cpp index c7122fc242..4597cfd1a4 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_launch_data.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_launch_data.cpp @@ -130,6 +130,11 @@ bool AppLaunchData::MarshallingExtend(Parcel &parcel) const TAG_LOGE(AAFwkTag::APPMGR, "Marshalling, Failed to write preloadModuleName."); return false; } + + if (!parcel.WriteBool(isDebugFromLocal_)) { + TAG_LOGE(AAFwkTag::APPMGR, "Marshalling, Failed to write isDebugFromLocal"); + return false; + } return true; } @@ -180,6 +185,7 @@ bool AppLaunchData::ReadFromParcel(Parcel &parcel) isNeedPreloadModule_ = parcel.ReadBool(); isAllowedNWebPreload_ = parcel.ReadBool(); preloadModuleName_ = parcel.ReadString(); + isDebugFromLocal_ = parcel.ReadBool(); return true; } @@ -290,5 +296,15 @@ bool AppLaunchData::IsAllowedNWebPreload() const { return isAllowedNWebPreload_; } + +void AppLaunchData::SetDebugFromLocal(bool isDebugFromLocal) +{ + isDebugFromLocal_ = isDebugFromLocal; +} + +bool AppLaunchData::GetDebugFromLocal() const +{ + return isDebugFromLocal_; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index 25ce80ac4e..c1e81685e3 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -1028,12 +1028,12 @@ int32_t AppMgrClient::UnregisterAppDebugListener(const sptr & return amsService_->UnregisterAppDebugListener(listener); } -int32_t AppMgrClient::AttachAppDebug(const std::string &bundleName) +int32_t AppMgrClient::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { if (!IsAmsServiceReady()) { return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED; } - return amsService_->AttachAppDebug(bundleName); + return amsService_->AttachAppDebug(bundleName, isDebugFromLocal); } int32_t AppMgrClient::DetachAppDebug(const std::string &bundleName) diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_host.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_host.cpp index eaf710d311..39c56c78b4 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_host.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_host.cpp @@ -444,7 +444,8 @@ int32_t AppSchedulerHost::HandleScheduleChangeAppGcState(MessageParcel &data, Me int32_t AppSchedulerHost::HandleAttachAppDebug(MessageParcel &data, MessageParcel &reply) { HITRACE_METER(HITRACE_TAG_APP); - AttachAppDebug(); + auto isDebugFromLocal = data.ReadBool(); + AttachAppDebug(isDebugFromLocal); return NO_ERROR; } diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_proxy.cpp index c0a0544398..325a4f11af 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_scheduler_proxy.cpp @@ -658,7 +658,7 @@ int32_t AppSchedulerProxy::ScheduleChangeAppGcState(int32_t state) return NO_ERROR; } -void AppSchedulerProxy::AttachAppDebug() +void AppSchedulerProxy::AttachAppDebug(bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::APPMGR, "called"); MessageParcel data; @@ -666,6 +666,10 @@ void AppSchedulerProxy::AttachAppDebug() TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); return; } + if (!data.WriteBool(isDebugFromLocal)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write AttachAppDebug isDebugFromLocal failed"); + return; + } MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 44b3fc0998..f7e97f55d7 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -103,6 +103,8 @@ public: const std::string& hapPath, bool isEsMode, bool useCommonTrunk) override; bool PopPreloadObj(const std::string& key, std::unique_ptr& obj); void StartDebugMode(const DebugOption debugOption) override; + void SetDebugOption(const DebugOption debugOption) override; + void StartLocalDebugMode(bool isDebugFromLocal) override; void DebuggerConnectionHandler(bool isDebugApp, bool isStartWithDebug); void StopDebugMode(); bool LoadRepairPatch(const std::string& hqfFile, const std::string& hapPath) override; @@ -172,6 +174,7 @@ private: std::map> preloadList_; static std::atomic hasInstance; + DebugOption debugOption_; private: bool CreateJsEnv(const Options& options); diff --git a/interfaces/inner_api/runtime/include/runtime.h b/interfaces/inner_api/runtime/include/runtime.h index 4010b2db65..4352d27ba8 100644 --- a/interfaces/inner_api/runtime/include/runtime.h +++ b/interfaces/inner_api/runtime/include/runtime.h @@ -75,6 +75,8 @@ public: bool isDebugApp = true; bool isStartWithDebug = false; bool isStartWithNative = false; + bool isDebugFromLocal = false; + bool isDeveloperMode; }; static std::unique_ptr Create(const Options& options); @@ -87,6 +89,8 @@ public: virtual Language GetLanguage() const = 0; virtual void StartDebugMode(const DebugOption debugOption) = 0; + virtual void SetDebugOption(const DebugOption debugOption) {}; + virtual void StartLocalDebugMode(bool isDebugFromLocal) {}; virtual void DumpHeapSnapshot(bool isPrivate) = 0; virtual void DumpCpuProfile() = 0; virtual void DestroyHeapProfiler() = 0; diff --git a/interfaces/kits/native/appkit/app/main_thread.h b/interfaces/kits/native/appkit/app/main_thread.h index b126d187cc..4061b1ccbd 100644 --- a/interfaces/kits/native/appkit/app/main_thread.h +++ b/interfaces/kits/native/appkit/app/main_thread.h @@ -311,7 +311,7 @@ public: */ int32_t ScheduleChangeAppGcState(int32_t state) override; - void AttachAppDebug() override; + void AttachAppDebug(bool isDebugFromLocal) override; void DetachAppDebug() override; bool NotifyDeviceDisConnect(); @@ -649,6 +649,8 @@ private: */ void ParseAppConfigurationParams(const std::string configuration, Configuration &config); + int32_t OnAttachLocalDebug(bool isDebugFromLocal); + #if defined(NWEB) && defined(NWEB_GRAPHIC) void HandleNWebPreload(); #endif diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index 7ad60b3872..be80543d88 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -1290,14 +1290,14 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName) override; + int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; /** * @brief Detach app debug. * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t DetachAppDebug(const std::string &bundleName) override; + int32_t DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; /** * @brief Execute intent. diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index 5abf5a5112..796e5f1ce9 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -1624,14 +1624,14 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName) override; + int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; /** * @brief Detach app debug. * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t DetachAppDebug(const std::string &bundleName) override; + int32_t DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; /** * @brief Execute intent. diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index 2f6fef15a2..ceb987ccec 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -521,7 +521,7 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName); + int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal); /** * @brief Detach app debug. diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index cb3279c2fe..a981a58498 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -146,6 +146,7 @@ ErrCode AbilityManagerClient::StartAbility(const Want &want, int requestCode, in CHECK_POINTER_RETURN_NOT_CONNECTED(abms); TAG_LOGI(AAFwkTag::ABILITYMGR, "StartAbility ability:%{public}s, userId:%{public}d, appCloneIndex:%{public}d", want.GetElement().GetURI().c_str(), userId, want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, -1)); + HandleDlpApp(const_cast(want)); return abms->StartAbility(want, userId, requestCode); } @@ -1848,20 +1849,20 @@ ErrCode AbilityManagerClient::UnregisterAppDebugListener(sptrUnregisterAppDebugListener(listener); } -ErrCode AbilityManagerClient::AttachAppDebug(const std::string &bundleName) +ErrCode AbilityManagerClient::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); auto abms = GetAbilityManager(); CHECK_POINTER_RETURN_NOT_CONNECTED(abms); - return abms->AttachAppDebug(bundleName); + return abms->AttachAppDebug(bundleName, isDebugFromLocal); } -ErrCode AbilityManagerClient::DetachAppDebug(const std::string &bundleName) +ErrCode AbilityManagerClient::DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); auto abms = GetAbilityManager(); CHECK_POINTER_RETURN_NOT_CONNECTED(abms); - return abms->DetachAppDebug(bundleName); + return abms->DetachAppDebug(bundleName, isDebugFromLocal); } ErrCode AbilityManagerClient::ExecuteIntent(uint64_t key, sptr callerToken, diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index 09f1dbcde0..be08ada220 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -4953,7 +4953,7 @@ int32_t AbilityManagerProxy::UnregisterAppDebugListener(sptr(isDebugApp), static_cast(hasWindowOptions), static_cast(isNativeDebugApp)); - bool checkDeveloperModeFlag = (isDebugApp || hasWindowOptions || isNativeDebugApp); + bool isDebugFromLocal = want.GetBoolParam(DEBUG_FROM, false); + TAG_LOGD(AAFwkTag::ABILITYMGR, + "isDebugApp=%{public}d, hasWindowOptions=%{public}d, isNativeDebugApp=%{public}d, isDebugFromLocal=%{public}d", + static_cast(isDebugApp), static_cast(hasWindowOptions), static_cast(isNativeDebugApp), + isDebugFromLocal); + bool checkDeveloperModeFlag = (isDebugApp || hasWindowOptions || isNativeDebugApp || isDebugFromLocal); if (checkDeveloperModeFlag) { - if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { + if (isDebugFromLocal && !AAFwk::PermissionVerification::GetInstance()-> VerifyStartLocalDebug()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "local debugging, permission denied"); + return CHECK_PERMISSION_FAILED; + } else if (!isDebugFromLocal && !system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "not developer Mode"); return ERR_NOT_DEVELOPER_MODE; } @@ -11027,11 +11034,14 @@ std::shared_ptr AbilityManagerService::ConnectInitAbilityDebug return abilityDebugDeal_; } -int32_t AbilityManagerService::AttachAppDebug(const std::string &bundleName) +int32_t AbilityManagerService::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); - if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "developer Mode false"); + if (isDebugFromLocal && !AAFwk::PermissionVerification::GetInstance()-> VerifyStartLocalDebug()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "local debugging, permission denied"); + return CHECK_PERMISSION_FAILED; + } else if (!isDebugFromLocal && !system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "not developer Mode"); return ERR_NOT_DEVELOPER_MODE; } @@ -11049,14 +11059,17 @@ int32_t AbilityManagerService::AttachAppDebug(const std::string &bundleName) } ConnectInitAbilityDebugDeal(); - return IN_PROCESS_CALL(DelayedSingleton::GetInstance()->AttachAppDebug(bundleName)); + return IN_PROCESS_CALL(DelayedSingleton::GetInstance()->AttachAppDebug(bundleName, isDebugFromLocal)); } -int32_t AbilityManagerService::DetachAppDebug(const std::string &bundleName) +int32_t AbilityManagerService::DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); - if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "developer Mode false"); + if (isDebugFromLocal && !AAFwk::PermissionVerification::GetInstance()-> VerifyStartLocalDebug()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "local debugging, permission denied"); + return CHECK_PERMISSION_FAILED; + } else if (!isDebugFromLocal && !system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "not developer Mode"); return ERR_NOT_DEVELOPER_MODE; } diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index b74b616f32..df3d438aa6 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -3637,8 +3637,8 @@ int32_t AbilityManagerStub::AttachAppDebugInner(MessageParcel &data, MessageParc TAG_LOGE(AAFwkTag::ABILITYMGR, "empty bundleName"); return ERR_INVALID_VALUE; } - - auto result = AttachAppDebug(bundleName); + bool isDebugFromLocal = data.ReadBool(); + auto result = AttachAppDebug(bundleName, isDebugFromLocal); if (!reply.WriteInt32(result)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail"); return ERR_INVALID_VALUE; @@ -3654,7 +3654,8 @@ int32_t AbilityManagerStub::DetachAppDebugInner(MessageParcel &data, MessageParc return ERR_INVALID_VALUE; } - auto result = DetachAppDebug(bundleName); + bool isDebugFromLocal = data.ReadBool(); + auto result = DetachAppDebug(bundleName, isDebugFromLocal); if (!reply.WriteInt32(result)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "write result fail"); return ERR_INVALID_VALUE; diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index 12581a621b..a0772ddf1f 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -576,10 +576,10 @@ int32_t AppScheduler::UnregisterAppDebugListener(const sptr(appMgrClient_->AttachAppDebug(bundleName)); + auto ret = static_cast(appMgrClient_->AttachAppDebug(bundleName, isDebugFromLocal)); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "attach app debug failed"); return INNER_ERR; diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index c2b9fdc498..7581f20447 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -322,7 +322,7 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName) override; + int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) override; /** * @brief Detach app debug. diff --git a/services/appmgr/include/app_lifecycle_deal.h b/services/appmgr/include/app_lifecycle_deal.h index 491dff5006..ff740ef275 100644 --- a/services/appmgr/include/app_lifecycle_deal.h +++ b/services/appmgr/include/app_lifecycle_deal.h @@ -257,7 +257,7 @@ public: * * @return ERR_OK, return back success, others fail. */ - int32_t AttachAppDebug(); + int32_t AttachAppDebug(bool isDebugFromLocal); /** * @brief detach a debugging process. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 972071c802..f1c93fb09d 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1103,7 +1103,7 @@ public: * @param bundleName The application bundle name. * @return Returns ERR_OK on success, others on failure. */ - int32_t AttachAppDebug(const std::string &bundleName); + int32_t AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal); /** * @brief Detach app debug. diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index c36cc7a112..2317b85fed 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -302,7 +302,7 @@ public: * @param bundleName The application bundle name. * @param isAttachDebug Determine if it is in attach debug mode. */ - void SetAttachAppDebug(const std::string &bundleName, const bool &isAttachDebug); + void SetAttachAppDebug(const std::string &bundleName, const bool &isAttachDebug, bool isDebugFromLocal); /** * @brief Obtain app debug infos through bundleName. diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index a843d6c627..fc49ab8b36 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -801,7 +801,7 @@ public: */ int32_t ChangeAppGcState(int32_t state); - void SetAttachDebug(bool isAttachDebug); + void SetAttachDebug(bool isAttachDebug, bool isDebugFromLocal); bool IsAttachDebug() const; void SetApplicationPendingState(ApplicationPendingState pendingState); @@ -1049,6 +1049,13 @@ public: return reasonExist_; } + void SetDebugFromLocal(bool isDebugFromLocal); + + bool GetDebugFromLocal() const + { + return isDebugFromLocal_; + } + private: /** * SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data. @@ -1223,6 +1230,7 @@ private: int32_t rssValue_ = 0; int32_t pssValue_ = 0; bool reasonExist_ = false; + bool isDebugFromLocal_ = false; }; } // namespace AppExecFwk diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index 34c0a18c92..683ddbcc74 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -550,7 +550,7 @@ int32_t AmsMgrScheduler::UnregisterAppDebugListener(const sptrUnregisterAppDebugListener(listener); } -int32_t AmsMgrScheduler::AttachAppDebug(const std::string &bundleName) +int32_t AmsMgrScheduler::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); @@ -560,7 +560,7 @@ int32_t AmsMgrScheduler::AttachAppDebug(const std::string &bundleName) TAG_LOGE(AAFwkTag::APPMGR, "caller is not foundation"); return ERR_INVALID_OPERATION; } - return amsMgrServiceInner_->AttachAppDebug(bundleName); + return amsMgrServiceInner_->AttachAppDebug(bundleName, isDebugFromLocal); } int32_t AmsMgrScheduler::DetachAppDebug(const std::string &bundleName) diff --git a/services/appmgr/src/app_lifecycle_deal.cpp b/services/appmgr/src/app_lifecycle_deal.cpp index f3ff1c5021..6380f4f7ae 100644 --- a/services/appmgr/src/app_lifecycle_deal.cpp +++ b/services/appmgr/src/app_lifecycle_deal.cpp @@ -325,7 +325,7 @@ int32_t AppLifeCycleDeal::ChangeAppGcState(int32_t state) return appThread->ScheduleChangeAppGcState(state); } -int32_t AppLifeCycleDeal::AttachAppDebug() +int32_t AppLifeCycleDeal::AttachAppDebug(bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::APPMGR, "called"); auto appThread = GetApplicationClient(); @@ -333,7 +333,7 @@ int32_t AppLifeCycleDeal::AttachAppDebug() TAG_LOGE(AAFwkTag::APPMGR, "null appThread"); return ERR_INVALID_VALUE; } - appThread->AttachAppDebug(); + appThread->AttachAppDebug(isDebugFromLocal); return ERR_OK; } diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index b3158ec183..b90ff17999 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -77,6 +77,7 @@ constexpr const char* FOUNDATION_PROCESS = "foundation"; constexpr const char* BS_PROCESS_NAME = "bgtaskmgr_service"; constexpr int32_t USER_UID = 2000; constexpr const char* HIVIEW_PROCESS_NAME = "hiview"; +constexpr const char* DEBUG_FROM = "ohos.param.debugFrom"; } // namespace REGISTER_SYSTEM_ABILITY_BY_ID(AppMgrService, APP_MGR_SERVICE_ID, true); @@ -1194,6 +1195,12 @@ int32_t AppMgrService::StartNativeProcessForDebugger(const AAFwk::Want &want) TAG_LOGE(AAFwkTag::APPMGR, "permission denied"); return ERR_INVALID_OPERATION; } + bool isDebugFromLocal = want.GetBoolParam(DEBUG_FROM, false); + if (isDebugFromLocal && + !AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug()) { + TAG_LOGE(AAFwkTag::APPMGR, "local debug permission denied"); + return ERR_PERMISSION_DENIED; + } auto ret = appMgrServiceInner_->StartNativeProcessForDebugger(want); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "start native process fail"); diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 63d75743cb..7947c3748c 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -193,6 +193,7 @@ constexpr const char* SERVICE_EXT_MULTI_PROCESS_WHITE_LIST = "component.startup. constexpr const char* SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard"; constexpr const char* DEBUG_APP = "debugApp"; constexpr const char* NATIVE_DEBUG = "nativeDebug"; +constexpr const char* DEBUG_FROM = "ohos.param.debugFrom"; constexpr const char* SERVICE_EXTENSION = ":ServiceExtension"; constexpr const char* KEEP_ALIVE = ":KeepAlive"; constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag"; @@ -2718,7 +2719,8 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord( const HapModuleInfo &hapModuleInfo, std::shared_ptr want, bool isKia) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); - if (want != nullptr && (want->GetBoolParam(DEBUG_APP, false) || want->GetBoolParam(NATIVE_DEBUG, false))) { + if (want != nullptr && (want->GetBoolParam(DEBUG_APP, false) || want->GetBoolParam(NATIVE_DEBUG, false) || + want->GetBoolParam(DEBUG_FROM, false))) { if (appInfo != nullptr && appInfo->appProvisionType != AppExecFwk::Constants::APP_PROVISION_TYPE_DEBUG) { TAG_LOGE(AAFwkTag::APPMGR, "release app not support debug"); return nullptr; @@ -2744,6 +2746,7 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord( if (want) { appRecord->SetDebugApp(want->GetBoolParam(DEBUG_APP, false)); appRecord->SetNativeDebug(want->GetBoolParam("nativeDebug", false)); + appRecord->SetDebugFromLocal(want->GetBoolParam(DEBUG_FROM, false)); if (want->GetBoolParam(COLD_START, false)) { appRecord->SetDebugApp(true); } @@ -2762,6 +2765,7 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord( appRecord->SetCallerTokenId(want->GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, -1)); appRecord->SetAssignTokenId(want->GetIntParam("specifyTokenId", 0)); appRecord->SetNativeStart(want->GetBoolParam("native", false)); + appRecord->SetDebugFromLocal(want->GetBoolParam(DEBUG_FROM, false)); } return appRecord; } @@ -3979,8 +3983,9 @@ void AppMgrServiceInner::ProcessAppDebug(const std::shared_ptr } auto bundleName = appRecord->GetBundleName(); + auto isDebugFromLocal = appRecord->GetDebugFromLocal(); if (appDebugManager_->IsAttachDebug(bundleName)) { - appRecord->SetAttachDebug(true); + appRecord->SetAttachDebug(true, isDebugFromLocal); startDebug(false); } } @@ -4884,6 +4889,9 @@ int AppMgrServiceInner::StartEmptyProcess(const AAFwk::Want &want, const sptrSetDebugApp(isDebug); + bool isDebugFromLocal = want.GetBoolParam(DEBUG_FROM, false); + TAG_LOGI(AAFwkTag::APPMGR, "SetDebugFromLocal: %{public}d", isDebugFromLocal); + appRecord->SetDebugFromLocal(isDebugFromLocal); if (want.GetBoolParam(COLD_START, false)) { appRecord->SetDebugApp(true); } @@ -5035,6 +5043,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap appRecord->SetCallerUid(wantPtr->GetIntParam(Want::PARAM_RESV_CALLER_UID, -1)); appRecord->SetCallerTokenId(wantPtr->GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, -1)); appRecord->SetDebugApp(wantPtr->GetBoolParam(DEBUG_APP, false)); + appRecord->SetDebugFromLocal(wantPtr->GetBoolParam(DEBUG_FROM, false)); if (appRecord->IsDebugApp()) { ProcessAppDebug(appRecord, true); } @@ -7117,7 +7126,7 @@ int32_t AppMgrServiceInner::UnregisterAppDebugListener(const sptrUnregisterAppDebugListener(listener); } -int32_t AppMgrServiceInner::AttachAppDebug(const std::string &bundleName) +int32_t AppMgrServiceInner::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) { @@ -7135,7 +7144,7 @@ int32_t AppMgrServiceInner::AttachAppDebug(const std::string &bundleName) TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ null"); return ERR_NO_INIT; } - appRunningManager_->SetAttachAppDebug(bundleName, true); + appRunningManager_->SetAttachAppDebug(bundleName, true, isDebugFromLocal); auto debugInfos = appRunningManager_->GetAppDebugInfosByBundleName(bundleName, false); if (!debugInfos.empty() && appDebugManager_ != nullptr) { @@ -7162,7 +7171,7 @@ int32_t AppMgrServiceInner::DetachAppDebug(const std::string &bundleName) auto debugInfos = appRunningManager_->GetAppDebugInfosByBundleName(bundleName, true); if (!debugInfos.empty()) { - appRunningManager_->SetAttachAppDebug(bundleName, false); + appRunningManager_->SetAttachAppDebug(bundleName, false, false); if (appDebugManager_ != nullptr) { appDebugManager_->StopDebug(debugInfos); } diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 06582cf1a4..30a930f8e8 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -1403,7 +1403,8 @@ bool AppRunningManager::IsApplicationUnfocused(const std::string &bundleName) return true; } -void AppRunningManager::SetAttachAppDebug(const std::string &bundleName, const bool &isAttachDebug) +void AppRunningManager::SetAttachAppDebug(const std::string &bundleName, const bool &isAttachDebug, + bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::APPMGR, "called"); auto appRunningMap = GetAppRunningRecordMap(); @@ -1414,7 +1415,7 @@ void AppRunningManager::SetAttachAppDebug(const std::string &bundleName, const b } if (appRecord->GetBundleName() == bundleName) { TAG_LOGD(AAFwkTag::APPMGR, "The application: %{public}s will be set debug mode.", bundleName.c_str()); - appRecord->SetAttachDebug(isAttachDebug); + appRecord->SetAttachDebug(isAttachDebug, isDebugFromLocal); } } } diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index 78af655c9b..3899a22886 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -342,6 +342,7 @@ void AppRunningRecord::LaunchApplication(const Configuration &config) launchData.SetIsNeedPreloadModule(isNeedPreloadModule_); launchData.SetNWebPreload(isAllowedNWebPreload_); launchData.SetPreloadModuleName(preloadModuleName_); + launchData.SetDebugFromLocal(isDebugFromLocal_); TAG_LOGD(AAFwkTag::APPMGR, "%{public}s called,app is %{public}s.", __func__, GetName().c_str()); AddAppLifecycleEvent("AppRunningRecord::LaunchApplication"); @@ -2107,16 +2108,17 @@ int32_t AppRunningRecord::ChangeAppGcState(int32_t state) return appLifeCycleDeal_->ChangeAppGcState(state); } -void AppRunningRecord::SetAttachDebug(bool isAttachDebug) +void AppRunningRecord::SetAttachDebug(bool isAttachDebug, bool isDebugFromLocal) { TAG_LOGD(AAFwkTag::APPMGR, "called"); isAttachDebug_ = isAttachDebug; + isDebugFromLocal_ = isDebugFromLocal; if (appLifeCycleDeal_ == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "null appLifeCycleDeal_"); return; } - isAttachDebug_ ? appLifeCycleDeal_->AttachAppDebug() : appLifeCycleDeal_->DetachAppDebug(); + isAttachDebug_ ? appLifeCycleDeal_->AttachAppDebug(isDebugFromLocal_) : appLifeCycleDeal_->DetachAppDebug(); } bool AppRunningRecord::IsAttachDebug() const @@ -2609,5 +2611,10 @@ uint32_t AppRunningRecord::GetAddStageTimeout() const } return AMSEventHandler::ADD_ABILITY_STAGE_INFO_TIMEOUT; } + +void AppRunningRecord::SetDebugFromLocal(bool isDebugFromLocal) +{ + isDebugFromLocal_ = isDebugFromLocal; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/common/include/permission_constants.h b/services/common/include/permission_constants.h index 1cdce5cb31..ee72eb0c58 100644 --- a/services/common/include/permission_constants.h +++ b/services/common/include/permission_constants.h @@ -70,6 +70,7 @@ constexpr const char* PERMISSION_GET_TELEPHONY_STATE = "ohos.permission.GET_TELE constexpr const char* PERMISSION_MANAGE_APP_KEEP_ALIVE = "ohos.permission.MANAGE_APP_KEEP_ALIVE"; constexpr const char* PERMISSION_MANAGE_APP_KEEP_ALIVE_INTERNAL = "ohos.permission.MANAGE_APP_KEEP_ALIVE_INTERNAL"; constexpr const char* PERMISSION_SET_LAUNCH_REASON_MESSAGE = "ohos.permission.SET_LAUNCH_REASON_MESSAGE"; +constexpr const char* PERMISSION_PERFORM_LOCAL_DEBUG = "ohos.permission.PERFORM_LOCAL_DEBUG"; constexpr const char* PERMISSION_NDK_START_SELF_UI_ABILITY = "ohos.permission.NDK_START_SELF_UI_ABILITY"; constexpr const char* PERMISSION_FUSION_ACCESS = "ohos.permission.ACCESS_AMS_FROM_FUSION"; } // namespace PermissionConstants diff --git a/services/common/include/permission_verification.h b/services/common/include/permission_verification.h index 4a42bb6b7c..b2fd2b23b4 100644 --- a/services/common/include/permission_verification.h +++ b/services/common/include/permission_verification.h @@ -117,6 +117,8 @@ struct VerificationInfo { bool VerifySuperviseKiaServicePermission() const; + bool VerifyStartLocalDebug() const; + bool VerifyStartSelfUIAbility(int tokenId) const; bool VerifyFusionAccessPermission() const; diff --git a/services/common/src/permission_verification.cpp b/services/common/src/permission_verification.cpp index 12d137cbf8..c01230f6b9 100644 --- a/services/common/src/permission_verification.cpp +++ b/services/common/src/permission_verification.cpp @@ -567,6 +567,16 @@ bool PermissionVerification::VerifySuperviseKiaServicePermission() const return false; } +bool PermissionVerification::VerifyStartLocalDebug() const +{ + if (VerifyCallingPermission(PermissionConstants::PERMISSION_PERFORM_LOCAL_DEBUG)) { + TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted"); + return true; + } + TAG_LOGE(AAFwkTag::DEFAULT, "Permission denied"); + return false; +} + bool PermissionVerification::VerifyStartSelfUIAbility(int tokenId) const { if (!IsSACall() && VerifyPermissionByTokenId(tokenId, PermissionConstants::PERMISSION_NDK_START_SELF_UI_ABILITY)) { diff --git a/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp b/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp index 9ad5da825c..512aac393d 100644 --- a/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp +++ b/test/fuzztest/abilityappmgrapprunningmanager_fuzzer/abilityappmgrapprunningmanager_fuzzer.cpp @@ -124,7 +124,7 @@ void DoSomethingInterestingWithMyAPIaddb(const char* data, size_t size) manager->IsApplicationFirstFocused(foregroundingRecord); manager->IsApplicationUnfocused(jsonStr); bool isAttachDebug = *data % ENABLE; - manager->SetAttachAppDebug(jsonStr, isAttachDebug); + manager->SetAttachAppDebug(jsonStr, isAttachDebug, false); bool isDetachDebug = *data % ENABLE; manager->GetAppDebugInfosByBundleName(jsonStr, isDetachDebug); std::vector> abilityTokens; diff --git a/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h b/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h index 10642dc81b..fb63186e9f 100644 --- a/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h +++ b/test/mock/frameworks_kits_ability_ability_runtime_test/AMS/mock_serviceability_manager_service.h @@ -333,8 +333,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h index 0c48c1fa65..24e645bb0d 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_service.h @@ -294,8 +294,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h b/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h index fd21c0a175..59b307afb2 100644 --- a/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h +++ b/test/mock/frameworks_kits_appkit_native_test/ability_delegator/mock_ability_delegator_stub.h @@ -186,8 +186,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, @@ -366,8 +366,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h index d19abbc4a0..c2aa0454fd 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_ability_mgr_service.h @@ -142,8 +142,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h b/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h index e94fbee850..eeddb8c204 100644 --- a/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h +++ b/test/mock/frameworks_kits_test/AMS/mock_ability_manager_service.h @@ -285,8 +285,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h b/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h index e8bfe51a69..6a8d1dcce4 100644 --- a/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h +++ b/test/mock/frameworks_kits_test/AMS/mock_serviceability_manager_service.h @@ -301,8 +301,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp index 30854b1eb6..f4019b1c58 100644 --- a/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp +++ b/test/mock/services_abilitymgr_test/libs/appexecfwk_core/src/appmgr/mock_app_scheduler.cpp @@ -228,7 +228,7 @@ int32_t AppScheduler::UnregisterAppDebugListener(const sptr &listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(const sptr &listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD1(RegisterAbilityDebugResponse, int32_t(const sptr &response)); MOCK_METHOD1(IsAttachDebug, bool(const std::string &bundleName)); diff --git a/test/mock/services_appmgr_test/include/mock_app_scheduler.h b/test/mock/services_appmgr_test/include/mock_app_scheduler.h index 6d0b70fe2a..4f82c98641 100644 --- a/test/mock/services_appmgr_test/include/mock_app_scheduler.h +++ b/test/mock/services_appmgr_test/include/mock_app_scheduler.h @@ -55,7 +55,7 @@ public: const sptr& callback, const int32_t recordId)); MOCK_METHOD1(ScheduleNotifyAppFault, int32_t(const FaultData &faultData)); MOCK_METHOD1(ScheduleChangeAppGcState, int32_t(int32_t state)); - MOCK_METHOD0(AttachAppDebug, void()); + MOCK_METHOD1(AttachAppDebug, void(bool isDebugFromLocal)); MOCK_METHOD0(DetachAppDebug, void()); MOCK_METHOD1(ScheduleJsHeapMemory, void(OHOS::AppExecFwk::JsHeapDumpInfo &info)); MOCK_METHOD2(SetAppWaitingDebug, int32_t(const std::string &bundleName, bool isPersist)); diff --git a/test/mock/services_appmgr_test/include/mock_app_scheduler_client.h b/test/mock/services_appmgr_test/include/mock_app_scheduler_client.h index abaf89eee2..79ccae40ce 100644 --- a/test/mock/services_appmgr_test/include/mock_app_scheduler_client.h +++ b/test/mock/services_appmgr_test/include/mock_app_scheduler_client.h @@ -55,7 +55,7 @@ public: const sptr& callback, const int32_t recordId)); MOCK_METHOD1(ScheduleNotifyAppFault, int32_t(const FaultData &faultData)); MOCK_METHOD1(ScheduleChangeAppGcState, int32_t(int32_t state)); - MOCK_METHOD0(AttachAppDebug, void()); + MOCK_METHOD1(AttachAppDebug, void(bool isDebugFromLocal)); MOCK_METHOD0(DetachAppDebug, void()); MOCK_METHOD1(ScheduleJsHeapMemory, void(OHOS::AppExecFwk::JsHeapDumpInfo &info)); MOCK_METHOD2(SetAppWaitingDebug, int32_t(const std::string &bundleName, bool isPersist)); diff --git a/test/mock/services_appmgr_test/include/mock_application.h b/test/mock/services_appmgr_test/include/mock_application.h index 034dad1c1b..8ee54aece4 100644 --- a/test/mock/services_appmgr_test/include/mock_application.h +++ b/test/mock/services_appmgr_test/include/mock_application.h @@ -49,7 +49,7 @@ public: MOCK_METHOD3(ScheduleNotifyUnLoadRepairPatch, int32_t(const std::string& bundleName, const sptr& callback, const int32_t recordId)); MOCK_METHOD1(ScheduleNotifyAppFault, int32_t(const FaultData &faultData)); - MOCK_METHOD0(AttachAppDebug, void()); + MOCK_METHOD1(AttachAppDebug, void(bool isDebugFromLocal)); MOCK_METHOD0(DetachAppDebug, void()); MOCK_METHOD2(SetAppWaitingDebug, int32_t(const std::string &bundleName, bool isPersist)); MOCK_METHOD0(CancelAppWaitingDebug, int32_t()); diff --git a/test/mock/services_appmgr_test/include/mock_application_proxy.h b/test/mock/services_appmgr_test/include/mock_application_proxy.h index 1f27d3d114..cfddf2ab5d 100644 --- a/test/mock/services_appmgr_test/include/mock_application_proxy.h +++ b/test/mock/services_appmgr_test/include/mock_application_proxy.h @@ -50,7 +50,7 @@ public: MOCK_METHOD3(ScheduleNotifyUnLoadRepairPatch, int32_t(const std::string& bundleName, const sptr& callback, const int32_t recordId)); MOCK_METHOD1(ScheduleNotifyAppFault, int32_t(const FaultData &faultData)); - MOCK_METHOD0(AttachAppDebug, void()); + MOCK_METHOD1(AttachAppDebug, void(bool isDebugFromLocal)); MOCK_METHOD0(DetachAppDebug, void()); MOCK_METHOD2(SetAppWaitingDebug, int32_t(const std::string &bundleName, bool isPersist)); MOCK_METHOD0(CancelAppWaitingDebug, int32_t()); diff --git a/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp b/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp index a64e95122d..27523fd930 100644 --- a/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp +++ b/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp @@ -183,7 +183,7 @@ public: return 0; } - void AttachAppDebug() override + void AttachAppDebug(bool isDebugFromLocal) override {} void DetachAppDebug() override diff --git a/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp b/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp index 18c498cdc3..4b05293cee 100644 --- a/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp +++ b/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp @@ -104,7 +104,7 @@ public: return 0; } - void AttachAppDebug() override + void AttachAppDebug(bool isDebugFromLocal) override {} void DetachAppDebug() override diff --git a/test/moduletest/mock/include/mock_ability_mgr_service.h b/test/moduletest/mock/include/mock_ability_mgr_service.h index 95dd84f2b4..cb18960c7e 100644 --- a/test/moduletest/mock/include/mock_ability_mgr_service.h +++ b/test/moduletest/mock/include/mock_ability_mgr_service.h @@ -271,8 +271,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/moduletest/mock/include/mock_app_scheduler.h b/test/moduletest/mock/include/mock_app_scheduler.h index 6a13eb2f11..840c523f40 100644 --- a/test/moduletest/mock/include/mock_app_scheduler.h +++ b/test/moduletest/mock/include/mock_app_scheduler.h @@ -48,7 +48,7 @@ public: MOCK_METHOD1(ScheduleChangeAppGcState, int32_t(int32_t state)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(const sptr &listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(const sptr &listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD1(RegisterAbilityDebugResponse, int32_t(const sptr &response)); MOCK_METHOD1(ScheduleJsHeapMemory, void(OHOS::AppExecFwk::JsHeapDumpInfo &info)); diff --git a/test/unittest/ability_manager_client_branch_second_test/ability_manager_stub_mock_second_test.h b/test/unittest/ability_manager_client_branch_second_test/ability_manager_stub_mock_second_test.h index b84ea6f1b9..ba6074a06e 100644 --- a/test/unittest/ability_manager_client_branch_second_test/ability_manager_stub_mock_second_test.h +++ b/test/unittest/ability_manager_client_branch_second_test/ability_manager_stub_mock_second_test.h @@ -421,8 +421,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h b/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h index c0d2ae0a30..88be7d651a 100644 --- a/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h +++ b/test/unittest/ability_manager_client_branch_test/ability_manager_stub_mock_test.h @@ -421,8 +421,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp b/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp index c6cda7f99a..182c9491d6 100644 --- a/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp +++ b/test/unittest/ability_manager_proxy_test/ability_manager_proxy_test.cpp @@ -2550,7 +2550,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_AttachAppDebug_0100, TestS { EXPECT_NE(proxy_, nullptr); std::string bundleName = "bundleName"; - auto result = proxy_->AttachAppDebug(bundleName); + auto result = proxy_->AttachAppDebug(bundleName, false); EXPECT_EQ(result, NO_ERROR); } @@ -2563,7 +2563,7 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_DetachAppDebug_0100, TestS { EXPECT_NE(proxy_, nullptr); std::string bundleName = "bundleName"; - auto result = proxy_->DetachAppDebug(bundleName); + auto result = proxy_->DetachAppDebug(bundleName, false); EXPECT_EQ(result, NO_ERROR); } diff --git a/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h b/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h index f4fc783d50..98fd670053 100644 --- a/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h +++ b/test/unittest/ability_manager_proxy_test/ability_manager_stub_mock.h @@ -423,8 +423,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD1(IsAbilityControllerStart, bool(const Want& want)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); diff --git a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp index 13628500bc..52791aa730 100644 --- a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp +++ b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp @@ -1428,7 +1428,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, AttachAppDebug_001, TestSize.Level1) { auto abilityMs_ = std::make_shared(); std::string bundleName; - abilityMs_->AttachAppDebug(bundleName); + abilityMs_->AttachAppDebug(bundleName, false); EXPECT_NE(abilityMs_, nullptr); } @@ -1442,7 +1442,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, DetachAppDebug_001, TestSize.Level1) auto abilityMs_ = std::make_shared(); EXPECT_NE(abilityMs_, nullptr); std::string bundleName; - auto result = abilityMs_->DetachAppDebug(bundleName); + auto result = abilityMs_->DetachAppDebug(bundleName, false); EXPECT_EQ(result, CHECK_PERMISSION_FAILED); } diff --git a/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h b/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h index 901b4d75d6..8f993136f1 100644 --- a/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h +++ b/test/unittest/ability_manager_stub_test/ability_manager_stub_impl_mock.h @@ -433,8 +433,8 @@ public: MOCK_METHOD2(PrepareTerminateAbilityBySCB, int32_t(const sptr &sessionInfo, bool &isPrepareTerminate)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD1(IsAbilityControllerStart, bool(const Want& want)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); diff --git a/test/unittest/ability_manager_test/ability_manager_stub_mock.h b/test/unittest/ability_manager_test/ability_manager_stub_mock.h index 4bce7d73d6..60088fc8f2 100644 --- a/test/unittest/ability_manager_test/ability_manager_stub_mock.h +++ b/test/unittest/ability_manager_test/ability_manager_stub_mock.h @@ -421,7 +421,7 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); diff --git a/test/unittest/ams_mgr_proxy_test/ams_mgr_proxy_test.cpp b/test/unittest/ams_mgr_proxy_test/ams_mgr_proxy_test.cpp index e83f004205..65dee912e6 100644 --- a/test/unittest/ams_mgr_proxy_test/ams_mgr_proxy_test.cpp +++ b/test/unittest/ams_mgr_proxy_test/ams_mgr_proxy_test.cpp @@ -115,11 +115,11 @@ HWTEST_F(AmsMgrProxyTest, AttachAppDebug_0100, TestSize.Level1) EXPECT_CALL(*mockAmsMgrScheduler_, SendRequest(_, _, _, _)) .Times(1) .WillOnce(Return(0)); - auto result = amsMgrProxy_->AttachAppDebug(STRING_BUNDLE_NAME); + auto result = amsMgrProxy_->AttachAppDebug(STRING_BUNDLE_NAME, false); EXPECT_EQ(result, NO_ERROR); EXPECT_CALL(*mockAmsMgrScheduler_, SendRequest(_, _, _, _)).Times(0); - result = amsMgrProxy_->AttachAppDebug(EMPTY_BUNDLE_NAME); + result = amsMgrProxy_->AttachAppDebug(EMPTY_BUNDLE_NAME, false); EXPECT_EQ(result, ERR_INVALID_DATA); } diff --git a/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp b/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp index ece99b6864..69dd7427d6 100644 --- a/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp +++ b/test/unittest/ams_mgr_scheduler_second_test/ams_mgr_scheduler_second_test.cpp @@ -1267,7 +1267,7 @@ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_AttachAppDebug_001 * @tc.steps: step1. amsMgrScheduler isReady false * @tc.expected: step1. expect ERR_INVALID_OPERATION */ - auto ret = amsMgrScheduler->AttachAppDebug(""); + auto ret = amsMgrScheduler->AttachAppDebug("", false); EXPECT_EQ(ret, ERR_INVALID_OPERATION); TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_AttachAppDebug_001 end"); } @@ -1289,7 +1289,7 @@ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_AttachAppDebug_002 * @tc.expected: step1. expect ERR_INVALID_OPERATION */ MyFlag::flag_ = 0; - auto ret = amsMgrScheduler->AttachAppDebug(""); + auto ret = amsMgrScheduler->AttachAppDebug("", false); EXPECT_EQ(ret, ERR_INVALID_OPERATION); TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_AttachAppDebug_002 end"); } @@ -1311,7 +1311,7 @@ HWTEST_F(AmsMgrSchedulerSecondTest, AmsMgrSchedulerSecondTest_AttachAppDebug_003 * @tc.expected: step1. expect ERR_INVALID_OPERATION */ MyFlag::flag_ = MyFlag::IS_SA_CALL; - auto ret = amsMgrScheduler->AttachAppDebug(""); + auto ret = amsMgrScheduler->AttachAppDebug("", false); EXPECT_EQ(ret, ERR_OK); TAG_LOGI(AAFwkTag::TEST, "AmsMgrSchedulerSecondTest_AttachAppDebug_003 end"); } diff --git a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp index 64e09931c8..d39f98528a 100644 --- a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp +++ b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp @@ -907,12 +907,12 @@ HWTEST_F(AmsMgrSchedulerTest, AttachAppDebug_001, TestSize.Level0) auto amsMgrScheduler = std::make_unique(nullptr, nullptr); EXPECT_NE(amsMgrScheduler, nullptr); std::string bundleName = ""; - int32_t res = amsMgrScheduler->AttachAppDebug(bundleName); + int32_t res = amsMgrScheduler->AttachAppDebug(bundleName, false); EXPECT_EQ(res, ERR_INVALID_OPERATION); amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); - res = amsMgrScheduler->AttachAppDebug(bundleName); + res = amsMgrScheduler->AttachAppDebug(bundleName, false); EXPECT_EQ(res, ERR_INVALID_OPERATION); } diff --git a/test/unittest/ams_mgr_stub_test/ams_mgr_stub_test.cpp b/test/unittest/ams_mgr_stub_test/ams_mgr_stub_test.cpp index 01136a54e6..c09ed0bac7 100644 --- a/test/unittest/ams_mgr_stub_test/ams_mgr_stub_test.cpp +++ b/test/unittest/ams_mgr_stub_test/ams_mgr_stub_test.cpp @@ -159,7 +159,7 @@ HWTEST_F(AmsMgrStubTest, HandleUnregisterAppDebugListener_0200, TestSize.Level1) HWTEST_F(AmsMgrStubTest, HandleAttachAppDebug_0100, TestSize.Level1) { EXPECT_NE(mockAmsMgrScheduler_, nullptr); - EXPECT_CALL(*mockAmsMgrScheduler_, AttachAppDebug(_)).Times(1); + EXPECT_CALL(*mockAmsMgrScheduler_, AttachAppDebug(_, _)).Times(1); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); @@ -179,7 +179,7 @@ HWTEST_F(AmsMgrStubTest, HandleAttachAppDebug_0100, TestSize.Level1) HWTEST_F(AmsMgrStubTest, HandleAttachAppDebug_0200, TestSize.Level1) { EXPECT_NE(mockAmsMgrScheduler_, nullptr); - EXPECT_CALL(*mockAmsMgrScheduler_, AttachAppDebug(_)).Times(0); + EXPECT_CALL(*mockAmsMgrScheduler_, AttachAppDebug(_, _)).Times(0); MessageParcel data; MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); diff --git a/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp b/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp index 252d9b248b..3a665dd856 100644 --- a/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp +++ b/test/unittest/app_lifecycle_deal_test/app_lifecycle_deal_test.cpp @@ -82,7 +82,7 @@ HWTEST_F(AppLifecycleDealTest, AttachAppDebug_001, TestSize.Level1) { auto appLifeCycle = std::make_shared(); EXPECT_NE(appLifeCycle, nullptr); - auto result = appLifeCycle->AttachAppDebug(); + auto result = appLifeCycle->AttachAppDebug(false); EXPECT_EQ(result, ERR_INVALID_VALUE); } @@ -97,7 +97,7 @@ HWTEST_F(AppLifecycleDealTest, AttachAppDebug_002, TestSize.Level1) EXPECT_NE(appLifeCycle, nullptr); sptr mockAppScheduler = new (std::nothrow) MockAppScheduler(); appLifeCycle->SetApplicationClient(mockAppScheduler); - auto result = appLifeCycle->AttachAppDebug(); + auto result = appLifeCycle->AttachAppDebug(false); EXPECT_EQ(ERR_OK, result); } diff --git a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp index 6c63f14c9b..850a3673f9 100644 --- a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp +++ b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp @@ -908,7 +908,7 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_AttachAppDebug_001, TestSize.Level1) EXPECT_EQ(result, AppMgrResultCode::RESULT_OK); std::string bundleName = "bundleName"; - auto resultCode = appMgrClient->AttachAppDebug(bundleName); + auto resultCode = appMgrClient->AttachAppDebug(bundleName, false); EXPECT_EQ(resultCode, ERR_OK); } diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 3b70d7c321..f183fad6db 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -3541,7 +3541,7 @@ HWTEST_F(AppMgrServiceInnerTest, AttachAppDebug_001, TestSize.Level0) std::string bundleName; appMgrServiceInner->appRunningManager_ = std::make_shared(); appMgrServiceInner->appDebugManager_ = std::make_shared(); - auto result = appMgrServiceInner->AttachAppDebug(bundleName); + auto result = appMgrServiceInner->AttachAppDebug(bundleName, false); EXPECT_EQ(result, ERR_OK); } @@ -3557,7 +3557,7 @@ HWTEST_F(AppMgrServiceInnerTest, AttachAppDebug_002, TestSize.Level0) std::string bundleName; appMgrServiceInner->appRunningManager_ = nullptr; appMgrServiceInner->appDebugManager_ = std::make_shared(); - auto result = appMgrServiceInner->AttachAppDebug(bundleName); + auto result = appMgrServiceInner->AttachAppDebug(bundleName, false); EXPECT_EQ(result, ERR_NO_INIT); } diff --git a/test/unittest/app_running_manager_test/app_running_manager_test.cpp b/test/unittest/app_running_manager_test/app_running_manager_test.cpp index b38dadca09..29369fbe9b 100644 --- a/test/unittest/app_running_manager_test/app_running_manager_test.cpp +++ b/test/unittest/app_running_manager_test/app_running_manager_test.cpp @@ -76,11 +76,11 @@ HWTEST_F(AppRunningManagerTest, AppRunningManager_SetAttachAppDebug_0100, TestSi std::string processName; auto appRunningRecord = std::make_shared(appInfo, recordId, processName); appRunningManager->appRunningRecordMap_.insert(make_pair(RECORD_ID, appRunningRecord)); - appRunningManager->SetAttachAppDebug(bundleName, true); + appRunningManager->SetAttachAppDebug(bundleName, true, false); for (const auto &item : appRunningManager->appRunningRecordMap_) { const auto &appRecord = item.second; if (appRecord->GetBundleName() == bundleName) { - appRecord->SetAttachDebug(true); + appRecord->SetAttachDebug(true, false); EXPECT_EQ(appRecord->isAttachDebug_, true); } } @@ -102,11 +102,11 @@ HWTEST_F(AppRunningManagerTest, AppRunningManager_SetAttachAppDebug_0200, TestSi std::string processName; auto appRunningRecord = std::make_shared(appInfo, recordId, processName); appRunningManager->appRunningRecordMap_.insert(make_pair(RECORD_ID, appRunningRecord)); - appRunningManager->SetAttachAppDebug(bundleName, isAttachDebug); + appRunningManager->SetAttachAppDebug(bundleName, isAttachDebug, false); for (const auto &item : appRunningManager->appRunningRecordMap_) { const auto &appRecord = item.second; if (appRecord->GetBundleName() == bundleName) { - appRecord->SetAttachDebug(true); + appRecord->SetAttachDebug(true, false); EXPECT_EQ(appRecord->isAttachDebug_, true); } } diff --git a/test/unittest/app_running_record_test/app_running_record_test.cpp b/test/unittest/app_running_record_test/app_running_record_test.cpp index f8f50d42d1..a5ce3b5d65 100644 --- a/test/unittest/app_running_record_test/app_running_record_test.cpp +++ b/test/unittest/app_running_record_test/app_running_record_test.cpp @@ -123,7 +123,7 @@ HWTEST_F(AppRunningRecordTest, AppRunningRecord_SetAttachDebug_0100, TestSize.Le std::string processName; auto appRunningRecord = std::make_shared(appInfo, recordId, processName); EXPECT_NE(appRunningRecord, nullptr); - appRunningRecord->SetAttachDebug(isAttachDebug); + appRunningRecord->SetAttachDebug(isAttachDebug, false); EXPECT_EQ(appRunningRecord->isAttachDebug_, true); } @@ -140,7 +140,7 @@ HWTEST_F(AppRunningRecordTest, AppRunningRecord_SetAttachDebug_0200, TestSize.Le std::string processName; auto appRunningRecord = std::make_shared(appInfo, recordId, processName); EXPECT_NE(appRunningRecord, nullptr); - appRunningRecord->SetAttachDebug(isAttachDebug); + appRunningRecord->SetAttachDebug(isAttachDebug, false); EXPECT_EQ(appRunningRecord->isAttachDebug_, false); } diff --git a/test/unittest/app_scheduler_host_test/app_scheduler_host_test.cpp b/test/unittest/app_scheduler_host_test/app_scheduler_host_test.cpp index 0d722f52e1..0ebe408af6 100644 --- a/test/unittest/app_scheduler_host_test/app_scheduler_host_test.cpp +++ b/test/unittest/app_scheduler_host_test/app_scheduler_host_test.cpp @@ -110,7 +110,7 @@ HWTEST_F(AppSchedulerHostTest, ScheduleChangeAppGcState_001, TestSize.Level1) HWTEST_F(AppSchedulerHostTest, HandleAttachAppDebug_001, TestSize.Level1) { EXPECT_NE(mockAppScheduler_, nullptr); - EXPECT_CALL(*mockAppScheduler_, AttachAppDebug()).Times(1); + EXPECT_CALL(*mockAppScheduler_, AttachAppDebug(_)).Times(1); MessageParcel data; MessageParcel reply; MessageOption option; @@ -129,7 +129,7 @@ HWTEST_F(AppSchedulerHostTest, HandleAttachAppDebug_001, TestSize.Level1) HWTEST_F(AppSchedulerHostTest, HandleAttachAppDebug_002, TestSize.Level1) { EXPECT_NE(mockAppScheduler_, nullptr); - EXPECT_CALL(*mockAppScheduler_, AttachAppDebug()).Times(0); + EXPECT_CALL(*mockAppScheduler_, AttachAppDebug(_)).Times(0); MessageParcel data; MessageParcel reply; MessageOption option; diff --git a/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp b/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp index 43e3da6861..7bdf69e6b1 100644 --- a/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp +++ b/test/unittest/app_scheduler_proxy_test/app_scheduler_proxy_test.cpp @@ -95,8 +95,8 @@ HWTEST_F(AppSchedulerProxyTest, AttachAppDebug_001, TestSize.Level1) sptr appSchedulerProxy = new AppSchedulerProxy(mockAppScheduler_); EXPECT_NE(appSchedulerProxy, nullptr); - EXPECT_CALL(*mockAppScheduler_, AttachAppDebug()).Times(1); - appSchedulerProxy->AttachAppDebug(); + EXPECT_CALL(*mockAppScheduler_, AttachAppDebug(_)).Times(1); + appSchedulerProxy->AttachAppDebug(false); } /** diff --git a/test/unittest/app_scheduler_test/app_scheduler_test.cpp b/test/unittest/app_scheduler_test/app_scheduler_test.cpp index caa6df94a9..92bf2373f9 100644 --- a/test/unittest/app_scheduler_test/app_scheduler_test.cpp +++ b/test/unittest/app_scheduler_test/app_scheduler_test.cpp @@ -1111,7 +1111,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_AttachAppDebug_001, TestSize.Level1) { AAFwk::IsMockSaCall::IsMockSpecificSystemAbilityAccessPermission(); std::string bundleName = "bundleName"; - int res = DelayedSingleton::GetInstance()->AttachAppDebug(bundleName); + int res = DelayedSingleton::GetInstance()->AttachAppDebug(bundleName, false); EXPECT_EQ(res, ERR_OK); } diff --git a/test/unittest/runtime_test/hdc_register_test.cpp b/test/unittest/runtime_test/hdc_register_test.cpp index 8e5ee206dd..a614e1ef24 100644 --- a/test/unittest/runtime_test/hdc_register_test.cpp +++ b/test/unittest/runtime_test/hdc_register_test.cpp @@ -58,9 +58,10 @@ HWTEST_F(HdcRegisterTest, HdcRegisterTest_0100, TestSize.Level0) bool debugApp = true; auto &pHdcRegister = AbilityRuntime::HdcRegister::Get(); - pHdcRegister.StartHdcRegister(bundleName, processName, debugApp, nullptr); + pHdcRegister.StartHdcRegister(bundleName, processName, debugApp, + AbilityRuntime::HdcRegister::DebugRegisterMode::HDC_DEBUG_REG, nullptr); - EXPECT_NE(pHdcRegister.registerHandler_, nullptr); + EXPECT_NE(pHdcRegister.registerHdcHandler_, nullptr); } /** @@ -71,10 +72,10 @@ HWTEST_F(HdcRegisterTest, HdcRegisterTest_0100, TestSize.Level0) HWTEST_F(HdcRegisterTest, HdcRegisterTest_0200, TestSize.Level0) { auto &pHdcRegister = AbilityRuntime::HdcRegister::Get(); - pHdcRegister.registerHandler_ = nullptr; + pHdcRegister.registerHdcHandler_ = nullptr; pHdcRegister.StopHdcRegister(); - EXPECT_EQ(pHdcRegister.registerHandler_, nullptr); + EXPECT_EQ(pHdcRegister.registerHdcHandler_, nullptr); } /** @@ -88,10 +89,11 @@ HWTEST_F(HdcRegisterTest, HdcRegisterTest_0300, TestSize.Level0) const std::string bundleName = "123"; bool debugApp = true; auto &pHdcRegister = AbilityRuntime::HdcRegister::Get(); - pHdcRegister.StartHdcRegister(bundleName, processName, debugApp, nullptr); + pHdcRegister.StartHdcRegister(bundleName, processName, debugApp, + AbilityRuntime::HdcRegister::DebugRegisterMode::HDC_DEBUG_REG, nullptr); pHdcRegister.StopHdcRegister(); - EXPECT_EQ(pHdcRegister.registerHandler_, nullptr); + EXPECT_EQ(pHdcRegister.registerHdcHandler_, nullptr); } } // namespace AbilityRuntime } // namespace OHOS diff --git a/test/unittest/service_extension_context_test/ability_manager_stub_mock.h b/test/unittest/service_extension_context_test/ability_manager_stub_mock.h index ba7ac98fef..2e7647f5a1 100644 --- a/test/unittest/service_extension_context_test/ability_manager_stub_mock.h +++ b/test/unittest/service_extension_context_test/ability_manager_stub_mock.h @@ -397,8 +397,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h b/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h index 064c0ae667..e861fc0862 100644 --- a/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h +++ b/test/unittest/sys_mgr_client_test/mock_ability_manager_service.h @@ -276,8 +276,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId, diff --git a/tools/test/mock/mock_ability_manager_stub.h b/tools/test/mock/mock_ability_manager_stub.h index 3a70968920..c3f7267ac5 100644 --- a/tools/test/mock/mock_ability_manager_stub.h +++ b/tools/test/mock/mock_ability_manager_stub.h @@ -272,8 +272,8 @@ public: MOCK_METHOD2(IsValidMissionIds, int32_t(const std::vector&, std::vector&)); MOCK_METHOD1(RegisterAppDebugListener, int32_t(sptr listener)); MOCK_METHOD1(UnregisterAppDebugListener, int32_t(sptr listener)); - MOCK_METHOD1(AttachAppDebug, int32_t(const std::string &bundleName)); - MOCK_METHOD1(DetachAppDebug, int32_t(const std::string &bundleName)); + MOCK_METHOD2(AttachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); + MOCK_METHOD2(DetachAppDebug, int32_t(const std::string &bundleName, bool isDebugFromLocal)); MOCK_METHOD3(ExecuteIntent, int32_t(uint64_t key, const sptr &callerToken, const InsightIntentExecuteParam ¶m)); MOCK_METHOD3(ExecuteInsightIntentDone, int32_t(const sptr &token, uint64_t intentId,