fix: fix codex

Signed-off-by: liujiandong <liujiandong1@huawei.com>
This commit is contained in:
YOUR_NAME 2024-08-30 10:17:38 +08:00
parent 80532b37bb
commit f60ee966ba
3 changed files with 27 additions and 7 deletions

View File

@ -47,6 +47,8 @@ private:
AppExecFwk::InnerEvent::TimePoint GetHandleTime();
int32_t GetNextQueueId();
void SubmitToFFRT(int32_t queueId, AppExecFwk::InnerEvent::TimePoint handleTime, int64_t delayTime);
AppExecFwk::InnerEvent::TimePoint GetCurHandleTime();
void SetCurHandleTime(AppExecFwk::InnerEvent::TimePoint handleTime);
private:
static const uint32_t EVENT_QUEUE_NUM = 3;
@ -54,6 +56,7 @@ private:
AppExecFwk::InnerEvent::TimePoint curHandleTime_ { AppExecFwk::InnerEvent::TimePoint::max() };
std::mutex eventCtx_;
std::mutex taskCtx_;
std::mutex memberCtx_;
ffrt::task_handle curTask_;
std::string name_;
std::atomic_int queueId_ { 0 };

View File

@ -48,10 +48,22 @@ TelEventQueue::~TelEventQueue()
queue_ = nullptr;
}
AppExecFwk::InnerEvent::TimePoint TelEventQueue::GetCurHandleTime()
{
std::lock_guard<std::mutex> lock(memberCtx_);
return curHandleTime_;
}
void TelEventQueue::SetCurHandleTime(AppExecFwk::InnerEvent::TimePoint handleTime)
{
std::lock_guard<std::mutex> lock(memberCtx_);
curHandleTime_ = handleTime;
}
void TelEventQueue::Submit(AppExecFwk::InnerEvent::Pointer &event, AppExecFwk::EventQueue::Priority priority)
{
InsertEventsInner(event, priority);
if (GetHandleTime() < curHandleTime_) {
if (GetHandleTime() < GetCurHandleTime()) {
GetNextQueueId();
ClearCurrentTask(false);
SubmitInner(queueId_.load());
@ -136,10 +148,10 @@ void TelEventQueue::SubmitToFFRT(int32_t queueId, AppExecFwk::InnerEvent::TimePo
std::lock_guard<std::mutex> lock(taskCtx_);
if (queueId != queueId_.load()) {
TELEPHONY_LOGD("%{public}s task no need to submit", name_.c_str());
curHandleTime_ = AppExecFwk::InnerEvent::TimePoint::max();
SetCurHandleTime(AppExecFwk::InnerEvent::TimePoint::max());
return;
}
curHandleTime_ = handleTime;
SetCurHandleTime(handleTime);
curTask_ = queue_->submit_h(
[this, queueId = queueId]() {
bool isNeedSubmit = true;
@ -175,7 +187,7 @@ void TelEventQueue::RemoveEvent(uint32_t innerEventId)
eventLists_[i].events.remove_if(filter);
}
if (IsEmpty()) {
curHandleTime_ = AppExecFwk::InnerEvent::TimePoint::max();
SetCurHandleTime(AppExecFwk::InnerEvent::TimePoint::max());
}
TELEPHONY_LOGD("%{public}s remove eventId %{public}d finish", name_.c_str(), innerEventId);
}
@ -201,7 +213,7 @@ void TelEventQueue::RemoveAllEvents()
for (uint32_t i = 0; i < EVENT_QUEUE_NUM; ++i) {
eventLists_[i].events.clear();
}
curHandleTime_ = AppExecFwk::InnerEvent::TimePoint::max();
SetCurHandleTime(AppExecFwk::InnerEvent::TimePoint::max());
TELEPHONY_LOGD("%{public}s RemoveAllEvents finish", name_.c_str());
}
@ -220,7 +232,7 @@ AppExecFwk::InnerEvent::Pointer TelEventQueue::PopEvent(int32_t queueId, bool &i
std::lock_guard<std::mutex> lock(eventCtx_);
if (IsEmpty() || queueId != queueId_.load()) {
isNeedSubmit = false;
curHandleTime_ = AppExecFwk::InnerEvent::TimePoint::max();
SetCurHandleTime(AppExecFwk::InnerEvent::TimePoint::max());
return AppExecFwk::InnerEvent::Pointer(nullptr, nullptr);
}
uint32_t priorityIndex = GetPriorityIndex();
@ -228,7 +240,7 @@ AppExecFwk::InnerEvent::Pointer TelEventQueue::PopEvent(int32_t queueId, bool &i
eventLists_[priorityIndex].events.pop_front();
if (IsEmpty()) {
isNeedSubmit = false;
curHandleTime_ = AppExecFwk::InnerEvent::TimePoint::max();
SetCurHandleTime(AppExecFwk::InnerEvent::TimePoint::max());
}
return event;
}

View File

@ -39,11 +39,16 @@ bool TelephonyPermission::GetBundleNameByUid(int32_t uid, std::string &bundleNam
{
OHOS::sptr<OHOS::ISystemAbilityManager> systemAbilityManager =
OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (systemAbilityManager == nullptr) {
TELEPHONY_LOGE("systemAbilityManager is nullptr");
return false;
}
OHOS::sptr<OHOS::IRemoteObject> remoteObject =
systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
sptr<AppExecFwk::IBundleMgr> iBundleMgr = OHOS::iface_cast<AppExecFwk::IBundleMgr>(remoteObject);
if (iBundleMgr == nullptr) {
TELEPHONY_LOGE("iBundleMgr is nullptr");
return false;
}
std::string identity = IPCSkeleton::ResetCallingIdentity();