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 TOUCHPAD_SETTINGS_HANDLER_H 16 #define TOUCHPAD_SETTINGS_HANDLER_H 17 18 #include <dlfcn.h> 19 #include "setting_observer.h" 20 21 namespace OHOS { 22 namespace MMI { 23 class TouchpadSettingsObserver { 24 public: 25 static std::shared_ptr<TouchpadSettingsObserver> GetInstance(); 26 TouchpadSettingsObserver(); 27 ~TouchpadSettingsObserver(); 28 bool RegisterTpObserver(const int32_t accountId); 29 bool UnregisterTpObserver(const int32_t accountId); 30 void RegisterUpdateFunc(); 31 void SyncTouchpadSettingsData(); 32 private: 33 static std::shared_ptr<TouchpadSettingsObserver> instance_; 34 static std::mutex mutex_; 35 std::mutex lock_; 36 SettingObserver::UpdateFunc updateFunc_ = nullptr; 37 bool hasRegistered_ = false; 38 int32_t currentAccountId_ = -1; 39 sptr<SettingObserver> pressureObserver_ {nullptr}; 40 sptr<SettingObserver> vibrationObserver_ {nullptr}; 41 sptr<SettingObserver> touchpadSwitchesObserver_ {nullptr}; 42 sptr<SettingObserver> knuckleSwitchesObserver_ {nullptr}; 43 std::string datashareUri_ = ""; 44 }; 45 #define TOUCHPAD_MGR ::OHOS::MMI::TouchpadSettingsObserver::GetInstance() 46 } // namespace MMI 47 } // namespace OHOS 48 #endif