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 f846e868a5039e78c1d3bb9a9c9de67eff75bb5f..b33e4693b58bca9a3f119410752b5c6b83c8592a 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 = DEFAULT_INVAL_VALUE); /** * 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 23f1637d927522d367d0a77392a77422198749d7..f65045c1d1bdaa4c7fbdf358694eaa937bdb1f45 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 = DEFAULT_INVAL_VALUE) = 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 b2ffb02bd460732e156bd2b1a084fb14eb9ed25e..76cad08ddefc868720a58d8a5a9dba7a85c89cba 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 = DEFAULT_INVAL_VALUE) 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 7833693174d2fd7f70d9f8cd8f15b30739281228..684bc02520be01758e42d0ea3b7fe3878f801095 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 396c3d446b8c03fcbfa9f871f51d029b783fcb6d..34ffabc71fadcf2ed2ab42c5ce2e61067ac8b64a 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 = DEFAULT_INVAL_VALUE) 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 30ece18d74d9f1bab95b034a0712478f53459845..92fee617af9ed404814efebab3689d9d1b3b44cc 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 = DEFAULT_INVAL_VALUE); 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 4e3ce704dd0f675c6dfce2895fcac0a9622a4bab..dcd643ea5c30fc30f14f404708c89f8b5659376b 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 9a5c544c4563842791c067adc22d06e2fe16bb53..363bd67176ac0858b484a4433bd31b3033102267 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 = -1) { 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; }