From f86de19c4b91f0f7dd12e46e2ba6cb7c74658b0b Mon Sep 17 00:00:00 2001 From: RuiChen Date: Thu, 4 Sep 2025 10:00:12 +0800 Subject: [PATCH] add support sh Signed-off-by: RuiChen --- .../app_manager/include/appmgr/app_mgr_client.h | 5 +++-- .../app_manager/include/appmgr/app_mgr_interface.h | 5 +++-- .../app_manager/include/appmgr/app_mgr_proxy.h | 3 ++- .../app_manager/src/appmgr/app_mgr_client.cpp | 5 +++-- .../app_manager/src/appmgr/app_mgr_proxy.cpp | 8 +++++++- .../inner_api/app_manager/src/appmgr/app_mgr_stub.cpp | 3 ++- services/appmgr/include/app_mgr_service.h | 6 +++--- services/appmgr/include/app_mgr_service_inner.h | 3 ++- services/appmgr/src/app_mgr_service.cpp | 5 +++-- services/appmgr/src/app_mgr_service_inner.cpp | 11 ++++++++--- 10 files changed, 36 insertions(+), 18 deletions(-) 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 f846e868a50..4368c7b7113 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 @@ -439,10 +439,11 @@ public: * Register configuration observer. * * @param observer Configuration observer. When configuration changed, observer will be called. + * @param userId The userId provided by caller. * @return Returns RESULT_OK on success, others on failure. */ - virtual AppMgrResultCode RegisterConfigurationObserver(const sptr &observer); - + virtual AppMgrResultCode RegisterConfigurationObserver(const sptr &observer, + const int32_t userId = -1); /** * Unregister configuration observer. * diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 23f1637d927..ee8f42c2977 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -484,10 +484,11 @@ public: * Register configuration observer. * * @param observer Configuration observer. When configuration changed, observer will be called. + * @param userId The userId provided by caller. * @return Returns RESULT_OK on success, others on failure. */ - virtual int32_t RegisterConfigurationObserver(const sptr &observer) = 0; - + virtual int32_t RegisterConfigurationObserver(const sptr &observer, + const int32_t userId = -1) = 0; /** * Unregister configuration observer. * diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index b2ffb02bd46..886b620bb7e 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -446,7 +446,8 @@ public: virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name, int32_t appIndex = 0) override; - virtual int32_t RegisterConfigurationObserver(const sptr &observer) override; + virtual int32_t RegisterConfigurationObserver(const sptr &observer, + const int32_t userId = -1) override; virtual int32_t UnregisterConfigurationObserver(const sptr &observer) override; 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 7833693174d..684bc02520b 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 @@ -895,11 +895,12 @@ AppMgrResultCode AppMgrClient::UpdateConfigurationByBundleName(const Configurati return AppMgrResultCode::RESULT_OK; } -AppMgrResultCode AppMgrClient::RegisterConfigurationObserver(const sptr &observer) +AppMgrResultCode AppMgrClient::RegisterConfigurationObserver(const sptr &observer, + const int32_t userId) { sptr service = iface_cast(mgrHolder_->GetRemoteObject()); if (service != nullptr) { - int32_t result = service->RegisterConfigurationObserver(observer); + int32_t result = service->RegisterConfigurationObserver(observer, userId); if (result == ERR_OK) { return AppMgrResultCode::RESULT_OK; } diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index 396c3d446b8..34ffabc71fa 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -1076,7 +1076,8 @@ int32_t AppMgrProxy::GetConfiguration(Configuration& config) return reply.ReadInt32(); } -int32_t AppMgrProxy::RegisterConfigurationObserver(const sptr& observer) +int32_t AppMgrProxy::RegisterConfigurationObserver(const sptr& observer, + const int32_t userId) { if (!observer) { TAG_LOGE(AAFwkTag::APPMGR, "observer null"); @@ -1095,6 +1096,11 @@ int32_t AppMgrProxy::RegisterConfigurationObserver(const sptr &observer) override; - + virtual int32_t RegisterConfigurationObserver(const sptr &observer, + const int32_t userId = -1) override; /** * @brief unregister a configuration observer registered before. * @param observer the configuration observer registered before. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 30ece18d74d..59f67ce3f48 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -822,7 +822,8 @@ public: std::shared_ptr GetConfiguration(); - int32_t RegisterConfigurationObserver(const sptr& observer); + int32_t RegisterConfigurationObserver(const sptr& observer, + const int32_t userId = -1); int32_t UnregisterConfigurationObserver(const sptr& observer); diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 4e3ce704dd0..dcd643ea5c3 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -1151,13 +1151,14 @@ int32_t AppMgrService::UpdateConfigurationByBundleName(const Configuration& conf return appMgrServiceInner_->UpdateConfigurationByBundleName(config, name, appIndex); } -int32_t AppMgrService::RegisterConfigurationObserver(const sptr &observer) +int32_t AppMgrService::RegisterConfigurationObserver(const sptr &observer, + const int32_t userId) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "not ready"); return ERR_INVALID_OPERATION; } - return appMgrServiceInner_->RegisterConfigurationObserver(observer); + return appMgrServiceInner_->RegisterConfigurationObserver(observer, userId); } int32_t AppMgrService::UnregisterConfigurationObserver(const sptr &observer) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 9a5c544c456..f2708247694 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -6028,7 +6028,8 @@ void AppMgrServiceInner::HandleConfigurationChange(const Configuration& config, } } -int32_t AppMgrServiceInner::RegisterConfigurationObserver(const sptr& observer) +int32_t AppMgrServiceInner::RegisterConfigurationObserver(const sptr& observer, + const int32_t userId) { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (!AAFwk::PermissionVerification::GetInstance()->IsSACall()) { @@ -6049,8 +6050,12 @@ int32_t AppMgrServiceInner::RegisterConfigurationObserver(const sptr= 0) { + configurationObservers_.push_back(ConfigurationObserverWithUserId { observer, userId }); + } else { + configurationObservers_.push_back( + ConfigurationObserverWithUserId { observer, GetUserIdByUid(IPCSkeleton::GetCallingUid()) }); + } return NO_ERROR; } -- Gitee