1 /* 2 * Copyright (c) 2022 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 #ifndef OHOS_FILEMGMT_CLOUD_SYNC_MANAGER_IMPL_H 17 #define OHOS_FILEMGMT_CLOUD_SYNC_MANAGER_IMPL_H 18 19 #include <atomic> 20 21 #include "nocopyable.h" 22 23 #include "cloud_sync_callback_client.h" 24 #include "cloud_sync_common.h" 25 #include "cloud_sync_manager.h" 26 #include "svc_death_recipient.h" 27 28 namespace OHOS::FileManagement::CloudSync { 29 class CloudSyncManagerImpl final : public CloudSyncManager, public NoCopyable { 30 public: 31 static CloudSyncManagerImpl &GetInstance(); 32 33 int32_t RegisterCallback(const std::shared_ptr<CloudSyncCallback> callback) override; 34 int32_t UnRegisterCallback() override; 35 int32_t StartSync() override; 36 int32_t StartSync(bool forceFlag, const std::shared_ptr<CloudSyncCallback> callback) override; 37 int32_t StopSync() override; 38 int32_t ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) override; 39 int32_t Clean(const std::string &accountId, const CleanOptions &cleanOptions) override; 40 int32_t NotifyDataChange(const std::string &accoutId, const std::string &bundleName) override; 41 int32_t EnableCloud(const std::string &accoutId, const SwitchDataObj &switchData) override; 42 int32_t DisableCloud(const std::string &accoutId) override; 43 int32_t StartDownloadFile(const std::string &uri) override; 44 int32_t StopDownloadFile(const std::string &uri) override; 45 int32_t RegisterDownloadFileCallback(const std::shared_ptr<CloudDownloadCallback> downloadCallback) override; 46 int32_t UnregisterDownloadFileCallback() override; 47 private: 48 CloudSyncManagerImpl() = default; 49 void SetDeathRecipient(const sptr<IRemoteObject> &remoteObject); 50 51 std::atomic_flag isFirstCall_{false}; 52 sptr<SvcDeathRecipient> deathRecipient_; 53 std::shared_ptr<CloudSyncCallback> callback_; 54 }; 55 } // namespace OHOS::FileManagement::CloudSync 56 57 #endif // OHOS_FILEMGMT_CLOUD_SYNC_MANAGER_IMPL_H 58