diff --git a/frameworks/native/geofence_sdk/source/geofence_request.cpp b/frameworks/native/geofence_sdk/source/geofence_request.cpp index 12b37360..e6bccf92 100644 --- a/frameworks/native/geofence_sdk/source/geofence_request.cpp +++ b/frameworks/native/geofence_sdk/source/geofence_request.cpp @@ -149,6 +149,16 @@ void GeofenceRequest::SetBundleName(const std::string& bundleName) bundleName_ = bundleName; } +int32_t GeofenceRequest::GetUid() +{ + return uid_; +} + +void GeofenceRequest::SetUid(int32_t uid) +{ + uid_ = uid; +} + void GeofenceRequest::ReadFromParcel(Parcel& data) { std::unique_lock lock(geofenceRequestMutex_); @@ -182,6 +192,7 @@ void GeofenceRequest::ReadFromParcel(Parcel& data) #endif callback_ = data.ReadObject(); bundleName_ = data.ReadString(); + uid_ = data.ReadInt32(); auto wantAgent = data.ReadParcelable(); if (wantAgent != nullptr) { wantAgent_ = *(wantAgent); @@ -218,6 +229,7 @@ bool GeofenceRequest::Marshalling(Parcel& parcel) const #endif parcel.WriteRemoteObject(callback_); parcel.WriteString(bundleName_); + parcel.WriteInt32(uid_); parcel.WriteParcelable(&wantAgent_); return true; } diff --git a/interfaces/inner_api/include/geofence_request.h b/interfaces/inner_api/include/geofence_request.h index 341a12b3..64ff277c 100644 --- a/interfaces/inner_api/include/geofence_request.h +++ b/interfaces/inner_api/include/geofence_request.h @@ -80,6 +80,10 @@ public: void SetBundleName(const std::string& bundleName); + int32_t GetUid(); + + void SetUid(int32_t uid); + void ReadFromParcel(Parcel& parcel); bool Marshalling(Parcel& parcel) const override; static std::shared_ptr Unmarshalling(Parcel& parcel); @@ -92,6 +96,7 @@ private: GeoFence geofence_{0.0, 0.0, 0.0, WGS84}; int scenario_; int fenceId_; + int32_t uid_; AbilityRuntime::WantAgent::WantAgent wantAgent_; std::string bundleName_; mutable std::mutex geofenceRequestMutex_; diff --git a/services/location_gnss/gnss/source/gnss_ability.cpp b/services/location_gnss/gnss/source/gnss_ability.cpp index aa28e211..2e28a9e9 100644 --- a/services/location_gnss/gnss/source/gnss_ability.cpp +++ b/services/location_gnss/gnss/source/gnss_ability.cpp @@ -881,7 +881,7 @@ void GnssAbility::ReportGeofenceEvent(int fenceIndex, GeofenceEvent event) auto notificationRequestList = request->GetNotificationRequestList(); if (transitionStatusList.size() == notificationRequestList.size()) { auto notificationRequest = notificationRequestList[i]; - notificationRequest.SetCreatorUid(IPCSkeleton::GetCallingUid()); + notificationRequest.SetCreatorUid(request->GetUid()); Notification::NotificationHelper::PublishNotification(notificationRequest); } else { LBSLOGE(GNSS, "transitionStatusList size does not equals to notificationRequestList size"); diff --git a/services/location_locator/locator/source/locator_skeleton.cpp b/services/location_locator/locator/source/locator_skeleton.cpp index 3aa3a33e..c2155770 100644 --- a/services/location_locator/locator/source/locator_skeleton.cpp +++ b/services/location_locator/locator/source/locator_skeleton.cpp @@ -736,6 +736,7 @@ int LocatorAbilityStub::PreAddGnssGeofence(MessageParcel &data, MessageParcel &r auto locatorAbility = LocatorAbility::GetInstance(); auto request = GeofenceRequest::Unmarshalling(data); request->SetBundleName(identity.GetBundleName()); + request->SetUid(identity.GetUid()); reply.WriteInt32(locatorAbility->AddGnssGeofence(request)); return ERRCODE_SUCCESS; }