• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #define MLOG_TAG "Media_Background"
17 
18 #include "media_cloud_sync_backgroud_task.h"
19 
20 #include "media_hidden_and_recycle_task.h"
21 #include "medialibrary_subscriber.h"
22 #include "media_log.h"
23 
24 namespace OHOS::Media::Background {
25 // LCOV_EXCL_START
MediaCloudSyncBackgroundTask()26 MediaCloudSyncBackgroundTask::MediaCloudSyncBackgroundTask()
27 {
28     this->tasks_ = {
29         std::make_shared<MediaHiddenAndRecycleTask>(),
30     };
31 }
32 
Accept()33 bool MediaCloudSyncBackgroundTask::Accept()
34 {
35     return MedialibrarySubscriber::IsCurrentStatusOn();
36 }
37 
Execute()38 void MediaCloudSyncBackgroundTask::Execute()
39 {
40     for (auto &task : this->tasks_) {
41         CHECK_AND_CONTINUE_ERR_LOG(task != nullptr, "task is null");
42         CHECK_AND_RETURN_INFO_LOG(this->Accept(), "check accept failed");
43         task->Execute();
44     }
45     return;
46 }
47 // LCOV_EXCL_STOP
48 }  // namespace OHOS::Media::CloudSync