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 #ifndef SETTING_DATA_HELPER_H 16 #define SETTING_DATA_HELPER_H 17 #include <mutex> 18 #include <string> 19 20 #include "data_ability_observer_stub.h" 21 22 namespace OHOS { 23 namespace FileManagement { 24 namespace CloudFile { 25 class SyncSwitchObserver : public AAFwk::DataAbilityObserverStub { 26 public: 27 SyncSwitchObserver() = default; 28 ~SyncSwitchObserver() = default; 29 void OnChange() override; 30 }; 31 32 class SettingDataHelper { 33 public: 34 static SettingDataHelper &GetInstance(); 35 void SetUserData(void *data); 36 bool InitActiveBundle(); 37 void UpdateActiveBundle(); 38 39 private: 40 std::string GetActiveBundle(); 41 bool IsDataShareReady(); 42 void RegisterObserver(); 43 void SetActiveBundle(std::string bundle); 44 45 private: 46 void *data_ = nullptr; 47 bool isDataShareReady_ = false; 48 bool isBundleInited_ = false; 49 std::mutex dataMtx_; 50 std::mutex initMtx_; 51 }; 52 } // namespace CloudFile 53 } // namespace FileManagement 54 } // namespace OHOS 55 #endif