fix notification problem

Signed-off-by: 李文龙 <liwenlong22@huawei.com>
This commit is contained in:
李文龙 2024-08-29 20:27:14 +08:00
parent 886e13a289
commit 8a7ede21dc
4 changed files with 19 additions and 1 deletions

View File

@ -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<std::mutex> lock(geofenceRequestMutex_);
@ -182,6 +192,7 @@ void GeofenceRequest::ReadFromParcel(Parcel& data)
#endif
callback_ = data.ReadObject<IRemoteObject>();
bundleName_ = data.ReadString();
uid_ = data.ReadInt32();
auto wantAgent = data.ReadParcelable<AbilityRuntime::WantAgent::WantAgent>();
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;
}

View File

@ -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<GeofenceRequest> 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_;

View File

@ -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");

View File

@ -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;
}