• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef OHOS_FILEMGMT_CLOUD_SYNC_SERVICE_H
17 #define OHOS_FILEMGMT_CLOUD_SYNC_SERVICE_H
18 
19 #include <map>
20 
21 #include "nocopyable.h"
22 #include "system_ability.h"
23 
24 #include "cloud_sync_service_stub.h"
25 #include "i_cloud_download_callback.h"
26 #include "i_cloud_sync_callback.h"
27 #include "sync_rule/battery_status_listener.h"
28 
29 namespace OHOS::FileManagement::CloudSync {
30 class CloudSyncService final : public SystemAbility, public CloudSyncServiceStub, protected NoCopyable {
31     DECLARE_SYSTEM_ABILITY(CloudSyncService);
32 
33 public:
34     explicit CloudSyncService(int32_t saID, bool runOnCreate = true);
35     virtual ~CloudSyncService() = default;
36     int32_t UnRegisterCallbackInner() override;
37     int32_t RegisterCallbackInner(const sptr<IRemoteObject> &remoteObject) override;
38     int32_t StartSyncInner(bool forceFlag) override;
39     int32_t StopSyncInner() override;
40     int32_t ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) override;
41     int32_t Clean(const std::string &accountId, const CleanOptions &cleanOptions) override;
42     int32_t NotifyDataChange(const std::string &accoutId, const std::string &bundleName) override;
43     int32_t EnableCloud(const std::string &accoutId, const SwitchDataObj &switchData) override;
44     int32_t DisableCloud(const std::string &accoutId) override;
45     int32_t StartDownloadFile(const std::string &path) override;
46     int32_t StopDownloadFile(const std::string &path) override;
47     int32_t RegisterDownloadFileCallback(const sptr<IRemoteObject> &downloadCallback) override;
48     int32_t UnregisterDownloadFileCallback() override;
49     int32_t UploadAsset(const int32_t userId, const std::string &request, std::string &result) override;
50     int32_t DownloadFile(const int32_t userId, const std::string &bundleName, AssetInfoObj &assetInfoObj) override;
51 
52 private:
53     std::string GetHmdfsPath(const std::string &uri, int32_t userId);
54     void OnStart() override;
55     void OnStop() override;
56     void PublishSA();
57     void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
58     void Init();
59 
60     std::shared_ptr<DataSyncManager> dataSyncManager_;
61     std::shared_ptr<BatteryStatusListener> batteryStatusListener_;
62 };
63 } // namespace OHOS::FileManagement::CloudSync
64 
65 #endif // OHOS_FILEMGMT_CLOUD_SYNC_SERVICE_H
66