• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 VIBRATOR_THREAD_H
17 #define VIBRATOR_THREAD_H
18 
19 #include <condition_variable>
20 #include <cstdint>
21 #include <thread>
22 
23 #include "thread_ex.h"
24 #include "vibrator_infos.h"
25 #include "vibrator_hdi_connection.h"
26 
27 namespace OHOS {
28 namespace Sensors {
29 class VibratorThread : public Thread {
30 public:
31     void UpdateVibratorEffect(VibrateInfo vibrateInfo);
32     VibrateInfo GetCurrentVibrateInfo();
33     void NotifyExit();
34 
35 protected:
36     virtual bool Run();
37 
38 private:
39     void SetReadyStatus(bool status);
40     VibrateInfo currentVibration_;
41     std::condition_variable cv_;
42     std::mutex currentVibrationMutex_;
43     std::mutex readyMutex_;
44     std::mutex vibrateMutex_;
45     bool ready_ = false;
46 };
47 #define VibratorDevice VibratorHdiConnection::GetInstance()
48 }  // namespace Sensors
49 }  // namespace OHOS
50 #endif  // VIBRATOR_THREAD_H