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 ACCESSIBILITY_SETTING_PROVIDER_H 17 #define ACCESSIBILITY_SETTING_PROVIDER_H 18 19 #include "errors.h" 20 #include "mutex" 21 #include "accessibility_setting_observer.h" 22 #include "accessibility_datashare_helper.h" 23 #include "accessibility_caption.h" 24 25 namespace OHOS { 26 namespace Accessibility { 27 class AccessibilitySettingProvider : public AccessibilityDatashareHelper { 28 public: 29 static AccessibilitySettingProvider& GetInstance(int32_t systemAbilityId); 30 AccessibilitySettingProvider(); 31 void DeleteInstance(); 32 RetError GetStringValue(const std::string& key, std::string& value); 33 RetError GetIntValue(const std::string& key, int32_t& value); 34 RetError GetLongValue(const std::string& key, int64_t& value); 35 RetError GetBoolValue(const std::string& key, bool& value); 36 RetError GetFloatValue(const std::string& key, float& value); 37 RetError PutStringValue(const std::string& key, const std::string& value, bool needNotify = true); 38 RetError PutIntValue(const std::string& key, int32_t value, bool needNotify = true); 39 RetError PutLongValue(const std::string& key, int64_t value, bool needNotify = true); 40 RetError PutBoolValue(const std::string& key, bool value, bool needNotify = true); 41 bool IsValidKey(const std::string& key); 42 sptr<AccessibilitySettingObserver> CreateObserver(const std::string& key, 43 AccessibilitySettingObserver::UpdateFunc& func); 44 45 RetError RegisterObserver(const std::string& key, AccessibilitySettingObserver::UpdateFunc& func); 46 RetError UnregisterObserver(const std::string& key); 47 private: 48 std::string GetConfigKey(int32_t state); 49 50 protected: 51 ~AccessibilitySettingProvider(); 52 53 private: 54 static AccessibilitySettingProvider* instance_; 55 static std::mutex mutex_; 56 }; 57 } // namespace Accessibility 58 } // namespace OHOS 59 #endif // ACCESSIBILITY_SETTING_PROVIDER_H