1 /*
2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "photo_job_repository.h"
17
18 #include "dp_log.h"
19 #include "dps_event_report.h"
20 #include "events_monitor.h"
21 #include "steady_clock.h"
22
23 namespace OHOS {
24 namespace CameraStandard {
25 namespace DeferredProcessing {
26
PhotoJobRepository(const int32_t userId)27 PhotoJobRepository::PhotoJobRepository(const int32_t userId) : userId_(userId)
28 {
29 DP_DEBUG_LOG("entered, userid: %{public}d", userId_);
30 }
31
~PhotoJobRepository()32 PhotoJobRepository::~PhotoJobRepository()
33 {
34 DP_DEBUG_LOG("entered, userid: %{public}d", userId_);
35 offlineJobMap_.clear();
36 backgroundJobMap_.clear();
37 offlineJobList_.clear();
38 jobQueue_.clear();
39 jobListeners_.clear();
40 priotyToNum_.clear();
41 }
42
AddDeferredJob(const std::string & imageId,bool discardable,DpsMetadata & metadata)43 void PhotoJobRepository::AddDeferredJob(const std::string& imageId, bool discardable, DpsMetadata& metadata)
44 {
45 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s, discardable: %{public}d", imageId.c_str(), discardable);
46 DeferredPhotoJobPtr jobPtrFind = GetJobUnLocked(imageId);
47 if (jobPtrFind != nullptr) {
48 DP_INFO_LOG("DPS_PHOTO: already existed, imageId: %{public}s", imageId.c_str());
49 return;
50 }
51
52 DeferredPhotoJobPtr jobPtr = std::make_shared<DeferredPhotoJob>(imageId, discardable, metadata);
53 int type;
54 metadata.Get(DEFERRED_PROCESSING_TYPE_KEY, type);
55 if (type == DeferredProcessingType::DPS_BACKGROUND) {
56 DP_INFO_LOG("DPS_PHOTO: add background job, imageId: %{public}s", imageId.c_str());
57 backgroundJobMap_.emplace(imageId, jobPtr);
58 } else {
59 DP_INFO_LOG("DPS_PHOTO: add offline job, imageId: %{public}s", imageId.c_str());
60 offlineJobList_.push_back(jobPtr);
61 offlineJobMap_.emplace(imageId, jobPtr);
62 }
63 jobPtr->SetPhotoJobType(type);
64 bool priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::NORMAL);
65 bool statusChanged = jobPtr->SetJobStatus(PhotoJobStatus::PENDING);
66 NotifyJobChanged(priorityChanged, statusChanged, jobPtr);
67 RecordPriotyNum(priorityChanged, jobPtr);
68 ReportEvent(jobPtr, DeferredProcessingServiceInterfaceCode::DPS_ADD_IMAGE);
69 EventsMonitor::GetInstance().NotifyPhotoProcessSize(static_cast<int32_t>(offlineJobList_.size()),
70 static_cast<int32_t>(backgroundJobMap_.size()));
71 }
72
RemoveDeferredJob(const std::string & imageId,bool restorable)73 void PhotoJobRepository::RemoveDeferredJob(const std::string& imageId, bool restorable)
74 {
75 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s, restorable: %{public}d", imageId.c_str(), restorable);
76 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
77 DP_CHECK_ERROR_RETURN_LOG(jobPtr == nullptr, "Does not existed, imageId: %{public}s", imageId.c_str());
78
79 UpdateJobQueueUnLocked(false, jobPtr);
80 bool priorityChanged = false;
81 bool statusChanged = false;
82 if (restorable) {
83 priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::LOW);
84 } else {
85 priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::DELETED);
86 statusChanged = jobPtr->SetJobStatus(PhotoJobStatus::DELETED);
87 if (backgroundJobMap_.count(imageId) == 1) {
88 backgroundJobMap_.erase(imageId);
89 DP_INFO_LOG("DPS_PHOTO: Background job removed, imageId: %{public}s", imageId.c_str());
90 } else if (offlineJobMap_.count(imageId) == 1) {
91 auto it = std::find_if(offlineJobList_.begin(), offlineJobList_.end(),
92 [jobPtr](const auto& ptr) { return ptr == jobPtr; });
93 if (it != offlineJobList_.end()) {
94 offlineJobList_.erase(it);
95 }
96 offlineJobMap_.erase(imageId);
97 DP_INFO_LOG("DPS_PHOTO: Offline job removed, imageId: %{public}s", imageId.c_str());
98 }
99 }
100 UpdateRunningCountUnLocked(statusChanged, jobPtr);
101 RecordPriotyNum(priorityChanged, jobPtr);
102 ReportEvent(jobPtr, DeferredProcessingServiceInterfaceCode::DPS_REMOVE_IMAGE);
103 if (!restorable) {
104 EventsMonitor::GetInstance().NotifyPhotoProcessSize(static_cast<int32_t>(offlineJobList_.size()),
105 static_cast<int32_t>(backgroundJobMap_.size()));
106 }
107 }
108
RequestJob(const std::string & imageId)109 bool PhotoJobRepository::RequestJob(const std::string& imageId)
110 {
111 bool priorityChanged = false;
112 bool statusChanged = false;
113 DP_INFO_LOG("DPS_PHOTO: RequestJob imageId: %{public}s", imageId.c_str());
114 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
115 DP_CHECK_ERROR_RETURN_RET_LOG(jobPtr == nullptr, false, "Does not existed, imageId: %{public}s", imageId.c_str());
116
117 UpdateJobQueueUnLocked(true, jobPtr);
118 priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::HIGH);
119 if (jobPtr->GetCurStatus() == PhotoJobStatus::FAILED) {
120 DP_INFO_LOG("Failed to Pending, imageId: %{public}s", imageId.c_str());
121 statusChanged = jobPtr->SetJobStatus(PhotoJobStatus::PENDING);
122 }
123 NotifyJobChanged(priorityChanged, statusChanged, jobPtr);
124 RecordPriotyNum(priorityChanged, jobPtr);
125 return true;
126 }
127
CancelJob(const std::string & imageId)128 void PhotoJobRepository::CancelJob(const std::string& imageId)
129 {
130 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s", imageId.c_str());
131 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
132 DP_CHECK_ERROR_RETURN_LOG(jobPtr == nullptr, "Does not existed, imageId: %{public}s", imageId.c_str());
133
134 UpdateJobQueueUnLocked(false, jobPtr);
135 bool priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::NORMAL);
136 NotifyJobChanged(priorityChanged, false, jobPtr);
137 RecordPriotyNum(priorityChanged, jobPtr);
138 ReportEvent(jobPtr, DeferredProcessingServiceInterfaceCode::DPS_CANCEL_PROCESS_IMAGE);
139 }
140
RestoreJob(const std::string & imageId)141 void PhotoJobRepository::RestoreJob(const std::string& imageId)
142 {
143 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s", imageId.c_str());
144 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
145 DP_CHECK_ERROR_RETURN_LOG(jobPtr == nullptr, "Does not existed, imageId: %{public}s", imageId.c_str());
146
147 bool priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::NORMAL);
148 NotifyJobChanged(priorityChanged, false, jobPtr);
149 RecordPriotyNum(priorityChanged, jobPtr);
150 ReportEvent(jobPtr, DeferredProcessingServiceInterfaceCode::DPS_RESTORE_IMAGE);
151 }
152
SetJobPending(const std::string & imageId)153 void PhotoJobRepository::SetJobPending(const std::string& imageId)
154 {
155 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s", imageId.c_str());
156 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
157 DP_CHECK_ERROR_RETURN_LOG(jobPtr == nullptr, "Does not existed, imageId: %{public}s", imageId.c_str());
158
159 bool statusChanged = jobPtr->SetJobStatus(PhotoJobStatus::PENDING);
160 UpdateRunningCountUnLocked(statusChanged, jobPtr);
161 NotifyJobChanged(false, statusChanged, jobPtr);
162 }
163
SetJobRunning(const std::string & imageId)164 void PhotoJobRepository::SetJobRunning(const std::string& imageId)
165 {
166 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s", imageId.c_str());
167 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
168 DP_CHECK_ERROR_RETURN_LOG(jobPtr == nullptr, "Does not existed, imageId: %{public}s", imageId.c_str());
169
170 bool statusChanged = jobPtr->SetJobStatus(PhotoJobStatus::RUNNING);
171 jobPtr->RecordJobRunningPriority();
172 UpdateRunningCountUnLocked(statusChanged, jobPtr);
173 ReportEvent(jobPtr, DeferredProcessingServiceInterfaceCode::DPS_PROCESS_IMAGE);
174 }
175
SetJobCompleted(const std::string & imageId)176 void PhotoJobRepository::SetJobCompleted(const std::string& imageId)
177 {
178 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s", imageId.c_str());
179 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
180 DP_CHECK_ERROR_RETURN_LOG(jobPtr == nullptr, "Does not existed, imageId: %{public}s", imageId.c_str());
181
182 UpdateJobQueueUnLocked(false, jobPtr);
183 bool priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::NORMAL);
184 bool statusChanged = jobPtr->SetJobStatus(PhotoJobStatus::COMPLETED);
185 UpdateRunningCountUnLocked(statusChanged, jobPtr);
186 NotifyJobChanged(priorityChanged, statusChanged, jobPtr);
187 RecordPriotyNum(priorityChanged, jobPtr);
188 }
189
SetJobFailed(const std::string & imageId)190 void PhotoJobRepository::SetJobFailed(const std::string& imageId)
191 {
192 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s", imageId.c_str());
193 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
194 DP_CHECK_ERROR_RETURN_LOG(jobPtr == nullptr, "Does not existed, imageId: %{public}s", imageId.c_str());
195
196 UpdateJobQueueUnLocked(false, jobPtr);
197 bool priorityChanged = jobPtr->SetJobPriority(PhotoJobPriority::NORMAL);
198 bool statusChanged = jobPtr->SetJobStatus(PhotoJobStatus::FAILED);
199 UpdateRunningCountUnLocked(statusChanged, jobPtr);
200 NotifyJobChanged(priorityChanged, statusChanged, jobPtr);
201 RecordPriotyNum(priorityChanged, jobPtr);
202 }
203
GetJobStatus(const std::string & imageId)204 PhotoJobStatus PhotoJobRepository::GetJobStatus(const std::string& imageId)
205 {
206 DP_INFO_LOG("DPS_PHOTO: imageId: %{public}s", imageId.c_str());
207 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
208 if (jobPtr == nullptr) {
209 DP_INFO_LOG("Does not existed, imageId: %{public}s", imageId.c_str());
210 return PhotoJobStatus::NONE;
211 } else {
212 return jobPtr->GetCurStatus();
213 }
214 }
215
GetLowPriorityJob()216 DeferredPhotoJobPtr PhotoJobRepository::GetLowPriorityJob()
217 {
218 DP_INFO_LOG("DPS_PHOTO: job queue size: %{public}d, offline job size: %{public}d,"
219 "background job size: %{public}d, running num: %{public}d",
220 static_cast<int>(jobQueue_.size()), static_cast<int>(offlineJobList_.size()),
221 static_cast<int>(backgroundJobMap_.size()), runningNum_);
222 auto it = std::find_if(offlineJobList_.begin(), offlineJobList_.end(), [](auto& jobPtr) {
223 return (jobPtr->GetCurPriority() == PhotoJobPriority::LOW) &&
224 (jobPtr->GetCurStatus() == PhotoJobStatus::PENDING);
225 });
226 if (it != offlineJobList_.end()) {
227 return *it;
228 }
229 it = std::find_if(offlineJobList_.begin(), offlineJobList_.end(), [](auto& jobPtr) {
230 return jobPtr->GetCurPriority() == PhotoJobPriority::LOW &&
231 jobPtr->GetCurStatus() == PhotoJobStatus::FAILED;
232 });
233 return it != offlineJobList_.end() ? *it : nullptr;
234 }
235
GetNormalPriorityJob()236 DeferredPhotoJobPtr PhotoJobRepository::GetNormalPriorityJob()
237 {
238 DP_INFO_LOG("DPS_PHOTO: job queue size: %{public}d, offline job size: %{public}d,"
239 "background job size: %{public}d, running num: %{public}d",
240 static_cast<int>(jobQueue_.size()), static_cast<int>(offlineJobList_.size()),
241 static_cast<int>(backgroundJobMap_.size()), runningNum_);
242 auto it = std::find_if(offlineJobList_.begin(), offlineJobList_.end(), [](auto& jobPtr) {
243 return (jobPtr->GetCurPriority() == PhotoJobPriority::NORMAL) &&
244 (jobPtr->GetCurStatus() == PhotoJobStatus::PENDING);
245 });
246 if (it != offlineJobList_.end()) {
247 return *it;
248 }
249 DP_INFO_LOG("DPS_PHOTO: no job pending, try reset failed to pending");
250 for (auto& jobPtr : offlineJobList_) {
251 if ((jobPtr->GetCurPriority() == PhotoJobPriority::NORMAL) &&
252 (jobPtr->GetCurStatus() == PhotoJobStatus::FAILED)) {
253 jobPtr->SetJobStatus(PhotoJobStatus::PENDING);
254 }
255 }
256 it = std::find_if(offlineJobList_.begin(), offlineJobList_.end(), [](auto& jobPtr) {
257 return (jobPtr->GetCurPriority() == PhotoJobPriority::NORMAL) &&
258 (jobPtr->GetCurStatus() == PhotoJobStatus::PENDING);
259 });
260 return it != offlineJobList_.end() ? *it : nullptr;
261 }
262
GetHighPriorityJob()263 DeferredPhotoJobPtr PhotoJobRepository::GetHighPriorityJob()
264 {
265 DP_INFO_LOG("DPS_PHOTO: job queue size: %{public}d, offline job size: %{public}d,"
266 "background job size: %{public}d, running num: %{public}d",
267 static_cast<int>(jobQueue_.size()), static_cast<int>(offlineJobList_.size()),
268 static_cast<int>(backgroundJobMap_.size()), runningNum_);
269 auto it = std::find_if(jobQueue_.begin(), jobQueue_.end(), [](auto& jobPtr) {
270 return jobPtr->GetCurStatus() == PhotoJobStatus::PENDING;
271 });
272 return it != jobQueue_.end() ? *it : nullptr;
273 }
274
GetRunningJobCounts()275 int PhotoJobRepository::GetRunningJobCounts()
276 {
277 DP_DEBUG_LOG("Running jobs num: %{public}d", runningNum_);
278 return runningNum_;
279 }
280
GetJobPriority(std::string imageId)281 PhotoJobPriority PhotoJobRepository::GetJobPriority(std::string imageId)
282 {
283 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
284 if (jobPtr == nullptr) {
285 DP_DEBUG_LOG("Does not existed, imageId: %{public}s", imageId.c_str());
286 return PhotoJobPriority::NONE;
287 } else {
288 return jobPtr->GetCurPriority();
289 }
290 }
291
GetJobRunningPriority(std::string imageId)292 PhotoJobPriority PhotoJobRepository::GetJobRunningPriority(std::string imageId)
293 {
294 DeferredPhotoJobPtr jobPtr = GetJobUnLocked(imageId);
295 if (jobPtr == nullptr) {
296 DP_INFO_LOG("Does not existed, imageId: %{public}s", imageId.c_str());
297 return PhotoJobPriority::NONE;
298 } else {
299 return jobPtr->GetRunningPriority();
300 }
301 }
302
NotifyJobChanged(bool priorityChanged,bool statusChanged,DeferredPhotoJobPtr jobPtr)303 void PhotoJobRepository::NotifyJobChanged(bool priorityChanged, bool statusChanged, DeferredPhotoJobPtr jobPtr)
304 {
305 DP_INFO_LOG("DPS_PHOTO: priorityChanged: %{public}d, statusChanged: %{public}d, imageId: %{public}s",
306 priorityChanged, statusChanged, jobPtr->GetImageId().c_str());
307 for (auto& listenerWptr : jobListeners_) {
308 if (auto listenerSptr = listenerWptr.lock()) {
309 listenerSptr->OnPhotoJobChanged(priorityChanged, statusChanged, jobPtr);
310 }
311 }
312 }
313
UpdateRunningCountUnLocked(bool statusChanged,DeferredPhotoJobPtr jobPtr)314 void PhotoJobRepository::UpdateRunningCountUnLocked(bool statusChanged, DeferredPhotoJobPtr jobPtr)
315 {
316 if (statusChanged && (jobPtr->GetPreStatus() == PhotoJobStatus::RUNNING)) {
317 runningNum_ = runningNum_ - 1;
318 }
319 if (statusChanged && (jobPtr->GetCurStatus() == PhotoJobStatus::RUNNING)) {
320 runningNum_ = runningNum_ + 1;
321 }
322 DP_INFO_LOG("DPS_PHOTO: running jobs num: %{public}d, imageId: %{public}s",
323 runningNum_, jobPtr->GetImageId().c_str());
324 }
325
UpdateJobQueueUnLocked(bool saved,DeferredPhotoJobPtr jobPtr)326 void PhotoJobRepository::UpdateJobQueueUnLocked(bool saved, DeferredPhotoJobPtr jobPtr)
327 {
328 if (saved) {
329 auto it = std::find_if(jobQueue_.begin(), jobQueue_.end(), [jobPtr](const auto& ptr) { return ptr == jobPtr; });
330 if (it != jobQueue_.end()) {
331 jobQueue_.erase(it);
332 DP_INFO_LOG("already existed, move to front, imageId: %{public}s", jobPtr->GetImageId().c_str());
333 }
334 //最新的请求最先处理,所以要放到队首。GetHighPriorityJob取任务从队首取。如果确认是这样顺序,则应该用栈保存
335 jobQueue_.push_front(jobPtr);
336 } else {
337 auto it = std::find_if(jobQueue_.begin(), jobQueue_.end(), [jobPtr](const auto& ptr) { return ptr == jobPtr; });
338 if (it != jobQueue_.end()) {
339 DP_INFO_LOG("erase high priority, imageId: %{public}s", jobPtr->GetImageId().c_str());
340 jobQueue_.erase(it);
341 } else {
342 DP_INFO_LOG("already not high priority, imageId: %{public}s", jobPtr->GetImageId().c_str());
343 }
344 }
345 }
346
RegisterJobListener(std::weak_ptr<IPhotoJobRepositoryListener> listener)347 void PhotoJobRepository::RegisterJobListener(std::weak_ptr<IPhotoJobRepositoryListener> listener)
348 {
349 jobListeners_.emplace_back(listener);
350 }
351
GetJobUnLocked(const std::string & imageId)352 DeferredPhotoJobPtr PhotoJobRepository::GetJobUnLocked(const std::string& imageId)
353 {
354 auto item = backgroundJobMap_.find(imageId);
355 if (item != backgroundJobMap_.end()) {
356 DP_INFO_LOG("DPS_PHOTO: background job, imageId: %{public}s", imageId.c_str());
357 return item->second;
358 }
359
360 item = offlineJobMap_.find(imageId);
361 if (item != offlineJobMap_.end()) {
362 DP_INFO_LOG("DPS_PHOTO: offline job, imageId: %{public}s", imageId.c_str());
363 return item->second;
364 }
365
366 return nullptr;
367 }
368
GetBackgroundJobSize()369 int PhotoJobRepository::GetBackgroundJobSize()
370 {
371 int size = static_cast<int>(backgroundJobMap_.size());
372 DP_DEBUG_LOG("background job size: %{public}d", size);
373 return size;
374 }
375
GetOfflineJobSize()376 int PhotoJobRepository::GetOfflineJobSize()
377 {
378 int size = static_cast<int>(offlineJobMap_.size());
379 DP_DEBUG_LOG("offline job size: %{public}d", size);
380 return size;
381 }
382
GetOfflineIdleJobSize()383 int PhotoJobRepository::GetOfflineIdleJobSize()
384 {
385 int size = static_cast<int>(offlineJobList_.size());
386 for (auto& jobPtr : offlineJobList_) {
387 if ((jobPtr->GetCurStatus() == PhotoJobStatus::COMPLETED) ||
388 (jobPtr->GetCurStatus() == PhotoJobStatus::DELETED)) {
389 size--;
390 }
391 }
392 DP_DEBUG_LOG("offline idle job size: %{public}d", size);
393 return size;
394 }
395
IsOfflineJob(std::string imageId)396 bool PhotoJobRepository::IsOfflineJob(std::string imageId)
397 {
398 return offlineJobMap_.find(imageId) != offlineJobMap_.end();
399 }
400
HasUnCompletedBackgroundJob()401 bool PhotoJobRepository::HasUnCompletedBackgroundJob()
402 {
403 auto it = std::find_if(backgroundJobMap_.begin(), backgroundJobMap_.end(), [](auto& ptr) {
404 return ptr.second->GetCurStatus() == PhotoJobStatus::PENDING;
405 });
406 return it != backgroundJobMap_.end();
407 }
408
RecordPriotyNum(bool priorityChanged,const DeferredPhotoJobPtr & jobPtr)409 void PhotoJobRepository::RecordPriotyNum(bool priorityChanged, const DeferredPhotoJobPtr& jobPtr)
410 {
411 DP_CHECK_RETURN(!priorityChanged);
412 auto it = priotyToNum_.find(jobPtr->GetCurPriority());
413 if (it != priotyToNum_.end()) {
414 (it->second)++;
415 }
416 it = priotyToNum_.find(jobPtr->GetPrePriority());
417 if (it != priotyToNum_.end()) {
418 (it->second)--;
419 }
420 }
421
ReportEvent(DeferredPhotoJobPtr jobPtr,DeferredProcessingServiceInterfaceCode event)422 void PhotoJobRepository::ReportEvent(DeferredPhotoJobPtr jobPtr, DeferredProcessingServiceInterfaceCode event)
423 {
424 int32_t highJobNum = priotyToNum_.find(PhotoJobPriority::HIGH)->second;
425 int32_t normalJobNum = priotyToNum_.find(PhotoJobPriority::NORMAL)->second;
426 int32_t lowJobNum = priotyToNum_.find(PhotoJobPriority::LOW)->second;
427 std::string imageId = jobPtr->GetImageId();
428 DPSEventInfo dpsEventInfo;
429 dpsEventInfo.imageId = imageId;
430 dpsEventInfo.userId = userId_;
431 dpsEventInfo.lowJobNum = lowJobNum;
432 dpsEventInfo.normalJobNum = normalJobNum;
433 dpsEventInfo.highJobNum = highJobNum;
434 dpsEventInfo.discardable = jobPtr->GetDiscardable();
435 dpsEventInfo.photoJobType = static_cast<PhotoJobType>(jobPtr->GetPhotoJobType());
436 dpsEventInfo.operatorStage = event;
437 uint64_t endTime = SteadyClock::GetTimestampMilli();
438 switch (static_cast<int32_t>(event)) {
439 case static_cast<int32_t>(DeferredProcessingServiceInterfaceCode::DPS_ADD_IMAGE): {
440 dpsEventInfo.dispatchTimeEndTime = endTime;
441 break;
442 }
443 case static_cast<int32_t>(DeferredProcessingServiceInterfaceCode::DPS_REMOVE_IMAGE): {
444 dpsEventInfo.removeTimeBeginTime = endTime;
445 break;
446 }
447 case static_cast<int32_t>(DeferredProcessingServiceInterfaceCode::DPS_RESTORE_IMAGE): {
448 dpsEventInfo.restoreTimeBeginTime = endTime;
449 break;
450 }
451 case static_cast<int32_t>(DeferredProcessingServiceInterfaceCode::DPS_PROCESS_IMAGE): {
452 dpsEventInfo.processTimeBeginTime = endTime;
453 break;
454 }
455 }
456 DPSEventReport::GetInstance().ReportOperateImage(imageId, userId_, dpsEventInfo);
457 }
458 } // namespace DeferredProcessing
459 } // namespace CameraStandard
460 } // namespace OHOS