• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <atomic>
20 #include "setting_observer.h"
21 
22 namespace OHOS {
23 namespace MMI {
24 class TouchpadSettingsObserver {
25 public:
26 static std::shared_ptr<TouchpadSettingsObserver> GetInstance();
27     TouchpadSettingsObserver();
28     ~TouchpadSettingsObserver();
29     bool RegisterTpObserver(const int32_t accountId);
30     bool UnregisterTpObserver(const int32_t accountId);
31     void RegisterUpdateFunc();
32     void SyncTouchpadSettingsData();
33     void SetCommonEventReady();
34     bool GetCommonEventStatus();
35 private:
36     sptr<SettingObserver> RegisterDatashareObserver(const std::string key, SettingObserver::UpdateFunc onUpdate);
37     static std::shared_ptr<TouchpadSettingsObserver> instance_;
38     static std::mutex mutex_;
39     std::mutex lock_;
40     SettingObserver::UpdateFunc updateFunc_ = nullptr;
41     bool hasRegistered_ = false;
42     std::atomic<bool> isCommonEventReady_ {false};
43     int32_t currentAccountId_ = -1;
44     sptr<SettingObserver> volumeSwitchesObserver_ {nullptr};
45     sptr<SettingObserver> brightnessSwitchesObserver_ {nullptr};
46     sptr<SettingObserver> pressureObserver_ {nullptr};
47     sptr<SettingObserver> vibrationObserver_ {nullptr};
48     sptr<SettingObserver> touchpadSwitchesObserver_ {nullptr};
49     sptr<SettingObserver> knuckleSwitchesObserver_ {nullptr};
50     std::string datashareUri_ = "";
51 };
52 #define TOUCHPAD_MGR ::OHOS::MMI::TouchpadSettingsObserver::GetInstance()
53 } // namespace MMI
54 } // namespace OHOS
55 #endif