• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #include "TimerTaskHandler.h"
17 
18 #if defined(LITEWEARABLE_SUPPORTED) && LITEWEARABLE_SUPPORTED
19 #include "CallbackManager.h"
20 #endif
21 
22 #include "font/ui_font.h"
23 #include "global.h"
24 #include "json/json.h"
25 #include "task_manager.h"
26 
27 #include "AsyncWorkManager.h"
28 #include "CommandLineInterface.h"
29 #include "JsAppImpl.h"
30 #include "LanguageManagerImpl.h"
31 #include "PreviewerEngineLog.h"
32 #include "SharedDataManager.h"
33 
34 #if defined(LITEWEARABLE_SUPPORTED) && LITEWEARABLE_SUPPORTED
35 #include "VirtualLocation.h"
36 #endif
37 
38 #include "VirtualScreenImpl.h"
39 
40 using namespace OHOS::ACELite;
41 using namespace std;
42 
TaskHandle()43 void TimerTaskHandler::TaskHandle()
44 {
45     OHOS::TaskManager::GetInstance()->TaskHandler();
46     VirtualScreenImpl::CheckBufferSend();
47 }
48 
CheckDevice()49 void TimerTaskHandler::CheckDevice()
50 {
51     SharedDataManager::CheckTick();
52 
53 #if defined(LITEWEARABLE_SUPPORTED) && LITEWEARABLE_SUPPORTED
54     if (VirtualLocation::GetInstance().IsPostionChanged()) {
55         VirtualLocation::GetInstance().ExecCallBack();
56     }
57 #endif
58 
59     AsyncWorkManager::GetInstance().ExecAllAsyncWork();
60 }
61 
62 #if defined(LITEWEARABLE_SUPPORTED) && LITEWEARABLE_SUPPORTED
CheckBarometerChanged(uint32_t value)63 void TimerTaskHandler::CheckBarometerChanged(uint32_t value)
64 {
65     ILOG("CheckBarometerChanged value: %d", value);
66     CallbackManager::GetInstance().ExecuteNumberInfoSuccess(SIMULATOR_JS_ATAPTER_SUBSCRIBE_BAROMETER, "pressure",
67                                                             value);
68 }
69 
CheckStepCountChanged(uint32_t value)70 void TimerTaskHandler::CheckStepCountChanged(uint32_t value)
71 {
72     ILOG("CheckStepCountChanged value: %d", value);
73     CallbackManager::GetInstance().ExecuteNumberInfoSuccess(SIMULATOR_JS_ATAPTER_SUBSCRIBE_STEP_COUNTER, "steps",
74                                                             value);
75 }
76 
CheckHeartRateChanged(uint8_t value)77 void TimerTaskHandler::CheckHeartRateChanged(uint8_t value)
78 {
79     ILOG("CheckHeartRateChanged value: %d", value);
80     CallbackManager::GetInstance().ExecuteNumberInfoSuccess(SIMULATOR_JS_ATAPTER_SUBSCRIBE_HEART_RATE, "heartRate",
81                                                             value);
82 }
83 
CheckOnBodyStateChanged(bool value)84 void TimerTaskHandler::CheckOnBodyStateChanged(bool value)
85 {
86     ILOG("CheckOnBodyStateChanged value: %d", value);
87     CallbackManager::GetInstance().ExecuteBooleanInfoSuccess(SIMULATOR_JS_ATAPTER_SUBSCRIBE_ON_BODY_STATE, "value",
88                                                              value);
89 }
90 #endif
91 
CheckLanguageChanged(std::string language)92 void TimerTaskHandler::CheckLanguageChanged(std::string language)
93 {
94     ILOG("CheckLanguageChanged value: %s", language.c_str());
95     GLOBAL_ConfigLanguage(language.data());
96 }
97 
CheckBrightnessValueChanged(uint8_t value)98 void TimerTaskHandler::CheckBrightnessValueChanged(uint8_t value)
99 {
100     Json::Value result;
101     result["version"] = CommandLineInterface::COMMAND_VERSION;
102     result["property"] = "Brightness";
103     result["result"]["Brightness"] = value;
104     ILOG("CheckBrightnessValueChanged send Brightness: %d", static_cast<uint32_t>(value));
105     CommandLineInterface::SendJsonData(result);
106 }
107 
CheckJsRunning()108 void TimerTaskHandler::CheckJsRunning()
109 {
110     JsAppImpl::GetInstance().SetRunning(true);
111 }
112