• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #ifndef OHOS_FILEMGMT_BACKUP_SERVICE_CLIENT_H
17 #define OHOS_FILEMGMT_BACKUP_SERVICE_CLIENT_H
18 
19 #include <condition_variable>
20 #include <cstddef>
21 #include <cstdint>
22 #include <mutex>
23 #include "backup_file_info.h"
24 #include "backup_incremental_data.h"
25 #include "iservice.h"
26 #include "system_ability_load_callback_stub.h"
27 
28 namespace OHOS::FileManagement::Backup {
29 class ServiceClient {
30 
31 public:
32     static sptr<IService> GetServiceProxyPointer();
33     static sptr<IService> GetInstance();
34     static void InvaildInstance();
35     bool CheckServiceProxy();
36 public:
37  explicit ServiceClient();
38     ~ServiceClient();
39 public:
40     class ServiceProxyLoadCallback : public SystemAbilityLoadCallbackStub {
41     public:
42         void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject) override;
43         void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
44 
45     public:
46         std::condition_variable proxyConVar_;
47         std::atomic<bool> isLoadSuccess_ = {false};
48     };
49 
50 private:
51     static inline std::mutex proxyMutex_;
52     static inline std::mutex getInstanceMutex_;
53     static inline sptr<IService> serviceProxy_ = nullptr;
54 };
55 } // namespace OHOS::FileManagement::Backup
56 
57 #endif // OHOS_FILEMGMT_BACKUP_SERVICE_CLIENT_H