1 /*
2  * Copyright (C) 2024 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 #ifndef OHOS_MEDIALIBRARY_RESTORE_H
16 #define OHOS_MEDIALIBRARY_RESTORE_H
17 
18 #include <string>
19 #include <memory>
20 #include "result_set.h"
21 
22 namespace OHOS {
23 namespace Media {
24 #define EXPORT __attribute__ ((visibility ("default")))
25 class MediaLibraryRestore {
26 public:
27     MediaLibraryRestore() = default;
28     virtual ~MediaLibraryRestore() = default;
29     EXPORT static MediaLibraryRestore &GetInstance();
30 
31     EXPORT void CheckRestore(const int32_t &errCode);
32     EXPORT bool IsRestoring() const;
33     EXPORT bool IsBackuping() const;
34     EXPORT bool IsWaiting() const;
35     EXPORT void CheckBackup();
36     EXPORT void InterruptBackup();
37     EXPORT void CheckResultSet(const std::shared_ptr<NativeRdb::ResultSet> &resultSet);
38 private:
39 #ifdef CLOUD_SYNC_MANAGER
40     void StopCloudSync();
41     void StartCloudSync();
42 #endif
43     void DoRdbBackup();
44     void ResetHAModeSwitchStatus();
45     void SaveHAModeSwitchStatusToPara(const int64_t &status);
46     bool isRestoring_{false};
47     std::atomic<bool> isBackuping_{false};
48     std::atomic<bool> isWaiting_{false};
49     std::atomic<bool> isInterrupting_{false};
50 };
51 } // namespace Media
52 } // namespace OHOS
53 #endif // OHOS_MEDIALIBRARY_RESTORE_H
54