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 16 #ifndef DMS_SWITCH_STATUS_DEPENDENCY_H 17 #define DMS_SWITCH_STATUS_DEPENDENCY_H 18 19 #include <string> 20 #include <mutex> 21 #include <vector> 22 #include "json/json.h" 23 #include "datashare_helper.h" 24 25 namespace OHOS { 26 namespace DistributedSchedule { 27 28 class SwitchStatusDependency { 29 public: 30 static SwitchStatusDependency &GetInstance(); 31 bool IsContinueSwitchOn(); 32 33 static const std::string SETTINGS_USER_SECURE_URI; 34 static const std::string SETTINGS_DATA_FIELD_KEY; 35 static const std::string SETTINGS_DATA_FIELD_VAL; 36 static const std::string CONTINUE_SWITCH_STATUS_KEY; 37 static const std::string CONTINUE_SWITCH_OFF; 38 static const std::string CONTINUE_SWITCH_ON; 39 40 private: 41 std::string GetSwitchStatus(const std::string &key, const std::string &defaultValue); 42 std::shared_ptr<DataShare::DataShareHelper> GetDataShareHelper(); 43 std::mutex dataShareMutex_; 44 std::string switchStatus_; 45 }; 46 } // namespace DistributedSchedule 47 } // namespace OHOS 48 49 #endif // DMS_SWITCH_STATUS_DEPENDENCY_H