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 #ifndef CJ_ACCESSIBILITY_CALLBACK_H 16 #define CJ_ACCESSIBILITY_CALLBACK_H 17 18 #include <vector> 19 #include <mutex> 20 #include <functional> 21 #include "accessibility_state_event.h" 22 #include "accessibility_ability_info.h" 23 #include "accessibility_utils.h" 24 25 namespace OHOS { 26 namespace Accessibility { 27 class cjAccessibilityStateObserver : public AccessibilityStateObserver { 28 public: cjAccessibilityStateObserver()29 cjAccessibilityStateObserver(){}; 30 void SubscribeObserver(std::function<void(bool)> cbFunc); 31 void OnStateChanged(const bool state) override; 32 33 private: 34 std::mutex cbMutex_; 35 std::vector<std::function<void(bool)>> observers_; 36 }; 37 38 static std::shared_ptr<cjAccessibilityStateObserver> cjAccessibilityStateListeners_ = 39 std::make_shared<cjAccessibilityStateObserver>(); 40 static std::shared_ptr<cjAccessibilityStateObserver> cjTouchGuideStateListeners_ = 41 std::make_shared<cjAccessibilityStateObserver>(); 42 } // namespace Accessibility 43 } // namespace OHOS 44 #endif // CJ_ACCESSIBILITY_CALLBACK_H