startLogic.cc 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. #pragma once
  2. #include "uart/ProtocolSender.h"
  3. #include "uart/UartContext.h"
  4. #include "core/utilities.h"
  5. #include "edge/call_log.h"
  6. #include "net/tcp_client.h"
  7. #include "net/tcp_model.h"
  8. #include "server/http_server.h"
  9. #include "base/strings.hpp"
  10. #include "utils/GpioHelper.h"
  11. #include "utils/TimeHelper.h"
  12. #include "utils/BrightnessHelper.h"
  13. #include <time.h>
  14. #include <thread>
  15. #include <list>
  16. #include <string>
  17. #include <unistd.h>
  18. #include <sys/reboot.h>
  19. #include "service/BusinessConfig.h"
  20. static bool sosTimerRegistered = true;
  21. static bool isSleepTimerRegistered = false; // 是否开启息屏定时任务
  22. static bool isSleep = false; // 是否在息屏
  23. static bool isNursing = false; // 用于启动时判断是否处于护理状态
  24. static bool isNetreset = false;
  25. static int netresetInt = 0;
  26. static string callTid = "";
  27. static bool isConnectHandle = false;
  28. static bool isConnectSos = false;
  29. static bool isConnectHandle1 = false;
  30. static bool isConnectHandle2 = false;
  31. static bool isConnectHandle3 = false;
  32. static bool isConnectHandle4 = false;
  33. static bool isTriggerHandle = false;
  34. static bool isTriggerSos = false;
  35. static bool isTriggerHandle1 = false;
  36. static bool isTriggerHandle2 = false;
  37. static bool isTriggerHandle3 = false;
  38. static bool isTriggerHandle4 = false;
  39. #define FUNCTION_TIMER_HANDLE 3 // 增援的定时器id
  40. #define SOS_CLICK_TIME_HANDLE 4 // sos的定时器id
  41. #define SOS_LAMP_TIME_HANDLE 5 // sos的门灯定时器id
  42. #define EVENT_TIME_HANDLE 8 // 事件定时器
  43. #define SLEEP_STRAT_TIME_HANDLE 9 // 息屏
  44. #define SYS_RESTART_TIME_HANDLE 10 // 重启
  45. #define PROMPT_TIME_HANDLE 11 // 提示语
  46. #define HANDLE_TRIGGER_TIME_HANDLE 15
  47. #define SOS_TRIGGER_TIME_HANDLE 16
  48. #define HANDLE1_TRIGGER_TIME_HANDLE 17
  49. #define HANDLE2_TRIGGER_TIME_HANDLE 18
  50. #define HANDLE3_TRIGGER_TIME_HANDLE 19
  51. #define HANDLE4_TRIGGER_TIME_HANDLE 20
  52. #define HTTP_SERVER_PORT 80
  53. srv::HttpServer httpServer;
  54. std::list<string> sosDataList;
  55. namespace {
  56. std::string uilogic[] = {
  57. "testActivity",
  58. "ui3Activity"
  59. };
  60. void CloseUi();
  61. int feed_dogs = 0;
  62. void PrintCallLog() {
  63. CallLogEntries entries;
  64. int ret = GetCallLog(&entries);
  65. LOGD("GetCallRecord %d", ret);
  66. for (auto r : entries) {
  67. LOGD("id=%d, uri=%s, contact=%s,duration=%d,created_at=%d",
  68. r.id, r.uri.c_str(), r.contact.c_str(), r.duration, r.created_at);
  69. }
  70. }
  71. void OnCallStateChanged(voip::Telephone* telephone, int call_id, voip::State state) {
  72. LOGD("call state = %d", state);
  73. if (state == voip::STATE_CALL_INCOMING
  74. || state == voip::STATE_CALL_CALLING
  75. || state == voip::STATE_CALL_CONFIRMED) {
  76. voip::CallInfo info = GetTelephone()->GetCallInfo();
  77. LOGD("info.id == %d", info.id);
  78. LOGD("info.remote_uri == %s", info.remote_uri.c_str());
  79. LOGD("info.remote_contact == %s", info.remote_contact.c_str());
  80. string sipId = info.remote_uri.substr(info.remote_uri.find(":") + 1, info.remote_uri.find("@") - info.remote_uri.find(":") - 1);
  81. LOGD("sipId == %s", sipId.c_str());
  82. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  83. EASYUICONTEXT->openActivity("callActivity");
  84. }
  85. else {
  86. if (sipId != "0000000000") {
  87. const char* currentAppName = EASYUICONTEXT->currentAppName();
  88. string _currentAppName = currentAppName;
  89. if (_currentAppName != "callActivity") {
  90. telephone->Hangup();
  91. LOGD("=================> 不在通话界面,直接挂断!");
  92. return;
  93. }
  94. }
  95. }
  96. if (state == voip::STATE_CALL_INCOMING) {
  97. if (telephone->GetCallCount() > 1) {
  98. LOGD("call count > 1, return");
  99. telephone->Hangup(call_id, voip::SIP_STATUS_CODE_BUSY_HERE);
  100. return;
  101. }
  102. //提前显示视频
  103. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  104. telephone->Answer(call_id, voip::SIP_STATUS_CODE_PROGRESS);
  105. telephone->Answer();
  106. } else {
  107. acceptSIP();
  108. }
  109. }
  110. }
  111. if (state == voip::STATE_CALL_DISCONNECTED) {
  112. LOGD("通话挂断");
  113. if (telephone->GetCallCount() > 1) {
  114. LOGD("call count > 1, return");
  115. return;
  116. }
  117. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP"){
  118. //EASYUICONTEXT->goHome();
  119. EASYUICONTEXT->goBack();
  120. }
  121. //保存通话记录
  122. voip::CallInfo info = telephone->GetCallInfo(call_id);
  123. CallLogEntry entry;
  124. entry.uri = info.remote_uri;
  125. entry.contact = info.remote_contact;
  126. entry.duration = info.duration/1000;
  127. if (0 != PutCallLog(entry)) {
  128. LOGE("保存通话记录失败");
  129. }
  130. int n = GetCallLogCount();
  131. if (n > CALL_LOG_COUNT_MAX) {
  132. //超过最大通话记录条数,删除旧记录
  133. if (0 != DeleteOldCallLog(n - CALL_LOG_COUNT_MAX)) {
  134. LOGE("删除失败");
  135. }
  136. }
  137. const char* currentAppName = EASYUICONTEXT->currentAppName();
  138. string _currentAppName = currentAppName;
  139. if (_currentAppName == "callActivity") {
  140. callActivityFinish(HANDOFF);
  141. return;
  142. }
  143. //PrintCallLog();
  144. }
  145. }
  146. void CloseUi() {
  147. for(int i = 0; i < 2; i++){
  148. EASYUICONTEXT->closeActivity(uilogic[i].c_str());
  149. }
  150. }
  151. void setBrightness(){
  152. int dayLight = StoragePreferences::getInt(STORE_DAY_LIGHT,100);
  153. int nightLight = StoragePreferences::getInt(STORE_NIGHT_LIGHT,10);
  154. if (checkIsDay()){
  155. BRIGHTNESSHELPER->setBrightness(dayLight);
  156. } else {
  157. BRIGHTNESSHELPER->setBrightness(nightLight);
  158. }
  159. }
  160. }
  161. std::list<string> getSosDataList() {
  162. return sosDataList;
  163. }
  164. void cleanSosDataList() {
  165. sosDataList.clear();
  166. }
  167. void systemRestart() {
  168. if (!isNetreset) {
  169. isNetreset = true;
  170. lightControl("CALLLED", "000F");
  171. mActivityPtr->registerUserTimer(SYS_RESTART_TIME_HANDLE, 1000);
  172. }
  173. }
  174. // 门灯还原
  175. void lightControl(std::string typeStr, std::string lightColorStr) {
  176. // 类型是门灯,并且还原成白色灯
  177. std::string heartStr;
  178. if (typeStr == "DOORLED" && lightColorStr == "000F") {
  179. //护理状态,需要还原成护理灯
  180. if (StoragePreferences::getBool(STORE_NURSING_TYPE, false)) {
  181. std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
  182. if (color != "" && color.size() == 3) {
  183. heartStr = "DOORLED," + color + "F";
  184. } else {
  185. heartStr = "DOORLED,010F";
  186. }
  187. }
  188. else {
  189. // 还原成无灯光的状态
  190. heartStr = "DOORLED,000F";
  191. }
  192. } else {
  193. heartStr = typeStr + "," + lightColorStr;
  194. }
  195. LOGD("=====> the heartStr == %s", heartStr.c_str());
  196. const char* sendMsg = heartStr.c_str();
  197. sendProtocolTo(UART_TTYS2, (byte*)(sendMsg), strlen(sendMsg));
  198. }
  199. // 接收tcp消息
  200. void handleMsg(byte* inBytes){
  201. LOGD("TCP received: %s", inBytes);
  202. const char* cstr = reinterpret_cast<const char*>(inBytes);
  203. string str = cstr;
  204. if (str == "1"){
  205. LOGD("get a heart beat");
  206. return;
  207. }
  208. TcpModel tcpModel;
  209. tcpModel = getTcpModel(inBytes);
  210. LOGD("tcp model: %s, %s", tcpModel.type.c_str(), tcpModel.action.c_str());
  211. if (tcpModel.type == TcpType::OTHER) {
  212. LOGD("trans tcp json failed");
  213. } else if (tcpModel.type == TcpType::TIME) {
  214. if (tcpModel.action == TimeAction::SYNC) {
  215. string serverTime = "";
  216. if (tcpModel.data != ""){
  217. serverTime = tcpModel.data;
  218. } else {
  219. serverTime = tcpModel.json["time"].asString();
  220. }
  221. LOGD("sync time : %s", serverTime.c_str());
  222. time_t timet = stoi(serverTime);
  223. struct tm *t = gmtime(&timet);
  224. char pDate[25];
  225. sprintf(pDate,"%d-%02d-%02d %02d:%02d:%02d",
  226. 1900 + t->tm_year, 1+ t->tm_mon, t->tm_mday,
  227. t->tm_hour + 8,t->tm_min,t->tm_sec);
  228. LOGD("transfered time : %s", pDate);
  229. TimeHelper::setDateTime(pDate);
  230. dataRefresh();
  231. if (isNursing) {
  232. setNursingEnd();
  233. }
  234. }
  235. } else if (tcpModel.type == TcpType::REINFORCE){
  236. if (tcpModel.action == ReinforceAction::RESPONSED){
  237. //回调
  238. TcpCallback callback = TcpCacheManager::instance()->getFunc(tcpModel.tid);
  239. if (callback.tid != "0"){
  240. callback.onSuccess(tcpModel.json);
  241. }
  242. const char* currentAppName = EASYUICONTEXT->currentAppName();
  243. string _currentAppName = currentAppName;
  244. if (_currentAppName != "functionActivity") {
  245. Intent* intent = new Intent();
  246. intent->putExtra(functionWindows, "helpResonse");
  247. EASYUICONTEXT->openActivity("functionActivity", intent);
  248. } else {
  249. toFunctionActivity("");
  250. }
  251. }
  252. } else if (tcpModel.type == TcpType::DEVICE){
  253. if (tcpModel.action == DeviceAction::APP_UPDATE){ //软件升级
  254. if (isSleep) {
  255. isSleep = false;
  256. BRIGHTNESSHELPER->screenOn();
  257. }
  258. Intent* intent = new Intent();
  259. intent->putExtra(appUpdate, "true");
  260. EASYUICONTEXT->openActivity("updateActivity", intent);
  261. }
  262. else if (tcpModel.action == DeviceAction::RESTART) { // 重启设备
  263. const char* req = "-1";
  264. TcpClient::instance()->sendMsg(req);
  265. lightControl("CALLLED", "000F");
  266. sync();
  267. reboot(RB_AUTOBOOT);
  268. }
  269. else if (tcpModel.action == DeviceAction::REBOOT) {
  270. const char* req = "-1";
  271. TcpClient::instance()->sendMsg(req);
  272. lightControl("CALLLED", "000F");
  273. //重启
  274. sync();
  275. reboot(RB_AUTOBOOT);
  276. }
  277. else if (tcpModel.action == DeviceAction::DEVICE_REFRESH) { // 设备刷新
  278. dataRefresh();
  279. }
  280. else if (tcpModel.action == DeviceAction::SYSTEM_SETTING) { // 修改科室设置
  281. getPartSetting();
  282. }
  283. else if (tcpModel.action == DeviceAction::SERVER_CHANGE) {
  284. StoragePreferences::putString(STORE_GATEWAY, tcpModel.json["server_ip"].asCString());
  285. StoragePreferences::putString(STORE_HTTP_PORT, tcpModel.json["server_port"].asCString());
  286. const char* req = "-1";
  287. TcpClient::instance()->sendMsg(req);
  288. lightControl("CALLLED", "000F");
  289. //重启
  290. sync();
  291. reboot(RB_AUTOBOOT);
  292. }
  293. } else if (tcpModel.type == TcpType::DATA){
  294. if (tcpModel.action == DataAction::REFRESH){ // 刷新数据
  295. dataRefresh();
  296. }
  297. } else if (tcpModel.type == TcpType::VOICE){
  298. if (tcpModel.action == VoiceAction::FAILED){
  299. const char* currentAppName = EASYUICONTEXT->currentAppName();
  300. string _currentAppName = currentAppName;
  301. if (_currentAppName == "callActivity") {
  302. callActivityFinish(CallFinishType::FAILED);
  303. }
  304. } else if (tcpModel.action == VoiceAction::SUCCESS){
  305. CallingStatus::instance()->setTcpModel(tcpModel); // 只有呼叫成功才闪红灯
  306. lightControl("DOORLED", "200F");
  307. } else if (tcpModel.action == VoiceAction::ACCEPT){
  308. if (CallingStatus::instance()->busy()){
  309. CallingStatus::instance()->setTcpModel(tcpModel);
  310. std::string toSipId = tcpModel.json["toSipId"].asString();
  311. callActivityFinish(CallFinishType::ACCEPT);
  312. //接听
  313. buildSIP(toSipId);
  314. }
  315. // 进行门灯还原
  316. lightControl("DOORLED", "000F");
  317. } else if (tcpModel.action == VoiceAction::REJECT){
  318. if (CallingStatus::instance()->busy()){
  319. callActivityFinish(CallFinishType::REJECT);
  320. // 进行门灯还原
  321. lightControl("DOORLED", "000F");
  322. }
  323. } else if (tcpModel.action == VoiceAction::CANCEL){
  324. if (CallingStatus::instance()->busy()){
  325. callActivityFinish(CallFinishType::CANCEL);
  326. }
  327. } else if (tcpModel.action == VoiceAction::CALLING){
  328. //对方忙线
  329. callActivityFinish(CallFinishType::BUSY);
  330. } else if (tcpModel.action == VoiceAction::CALL){
  331. //我方忙线判断
  332. if (CallingStatus::instance()->busy()){
  333. sendVoiceTcp(VoiceAction::CALLING, tcpModel, tcpModel.from_id);
  334. } else {
  335. CallingStatus::instance()->setTcpModel(tcpModel);
  336. //来电话了
  337. Intent* intent = new Intent();
  338. intent->putExtra(isOutgoing, "false");
  339. EASYUICONTEXT->openActivity("callActivity", intent);
  340. }
  341. } else if (tcpModel.action == VoiceAction::HANDOFF){
  342. //判断 是否同一个对话
  343. long iId = CallingStatus::instance()->getInteractionId();
  344. if (iId > 0 && CallingStatus::instance()->busy()){
  345. long inId = tcpModel.json["id"].asInt();
  346. if (iId == inId && CallingStatus::instance()->busy()){
  347. callActivityFinish(CallFinishType::HANDOFF);
  348. }
  349. }
  350. }
  351. }
  352. else if (tcpModel.type == TcpType::SOS) {
  353. if (tcpModel.action == SosAction::CANCEL) {
  354. // SOS还原成无灯光的状态
  355. lightControl("ULED", "0F");
  356. // 进行门灯还原
  357. lightControl("DOORLED", "000F");
  358. mActivityPtr->unregisterUserTimer(SOS_LAMP_TIME_HANDLE);
  359. }
  360. }
  361. else if (tcpModel.type == TcpType::SIDE) {
  362. if (tcpModel.action == SideAction::NURSING) {
  363. StoragePreferences::putString(STORE_NURSING_INTERACTION_ID, tcpModel.json["id"].asString());
  364. // 收到nursing,需要把通话给挂断了
  365. voip::CallInfo info = GetTelephone()->GetCallInfo();
  366. LOGD("info state = %d",info.state);
  367. if (info.state == voip::STATE_CALL_CALLING
  368. || info.state == voip::STATE_CALL_CALLING
  369. || info.state == voip::STATE_CALL_CONFIRMED){
  370. TcpModel storeModel = CallingStatus::instance()->getTcpModel();
  371. //只回传iId
  372. storeModel.data = storeModel.json["id"].asString();
  373. sendVoiceTcp(VoiceAction::HANDOFF, storeModel, storeModel.from_id);
  374. GetTelephone()->Hangup(info.id, voip::SIP_STATUS_CODE_DECLINE);
  375. GetTelephone()->Hangup();
  376. EASYUICONTEXT->goBack();
  377. }
  378. std::string color = StoragePreferences::getString(STORE_NURSING_COLOR_RGB, "010");
  379. if (color != "" && color.size() == 3) {
  380. color = color + "F";
  381. } else {
  382. color = "010F";
  383. }
  384. lightControl("DOORLED", color);
  385. }
  386. else if (tcpModel.action == SideAction::NURSING_END) {
  387. // 收到nursing_end
  388. lightControl("DOORLED", "000F");
  389. }
  390. else if (tcpModel.action == SideAction::CALL) {
  391. // 收到CALL,需要亮红灯
  392. lightControl("DOORLED", "200F");
  393. }
  394. else if (tcpModel.action == SideAction::ACCEPT) {
  395. // 进行门灯还原
  396. lightControl("DOORLED", "000F");
  397. if (isHandleId(tcpModel.to_id) && CallingStatus::instance()->busy()) {
  398. CallingStatus::instance()->setTcpModel(tcpModel);
  399. std::string toSipId = tcpModel.json["toSipId"].asString();
  400. callActivityFinish(CallFinishType::ACCEPT);
  401. //接听
  402. buildSIP(toSipId);
  403. }
  404. }
  405. else if (tcpModel.action == SideAction::CANCEL) {
  406. // 进行门灯还原
  407. lightControl("DOORLED", "000F");
  408. if (isHandleId(tcpModel.to_id) && CallingStatus::instance()->busy()) {
  409. callActivityFinish(CallFinishType::CANCEL);
  410. }
  411. }
  412. else if (tcpModel.action == SideAction::SOS_CALL) {
  413. // 收到SOS_CALL,需要亮红灯
  414. // 门灯亮红灯
  415. lightControl("DOORLED", "200F");
  416. lightControl("CALLLED", "100F");
  417. sosTimerRegistered = false;
  418. mActivityPtr->registerUserTimer(SOS_CLICK_TIME_HANDLE, 10000); // 10秒后才能触发
  419. mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000); // 2分钟后才能触发
  420. if (tcpModel.json.isMember("id")) {
  421. sosDataList.push_back(tcpModel.json["id"].asString());
  422. }
  423. }
  424. else if (tcpModel.action == SideAction::SOS_CANCEL) {
  425. // 进行门灯还原
  426. lightControl("DOORLED", "000F");
  427. statusLight();
  428. }
  429. }
  430. else if (tcpModel.type == TcpType::CALLBACK) {
  431. if (tcpModel.action == CallbackAction::ACK) {
  432. LOGD("CALLBACK ACK !!!!");
  433. //回调
  434. TcpCallback callback = TcpCacheManager::instance()->getFunc(tcpModel.tid);
  435. if (callback.tid != "0"){
  436. callback.onSuccess(tcpModel.json);
  437. }
  438. }
  439. else if (tcpModel.action == CallbackAction::SUCCESS) {
  440. //回调
  441. TcpCallback callback = TcpCacheManager::instance()->getFunc(tcpModel.tid);
  442. if (callback.tid != "0"){
  443. callback.onSuccess(tcpModel.json);
  444. }
  445. }
  446. else if (tcpModel.action == CallbackAction::FAILED) {
  447. //回调
  448. TcpCallback callback = TcpCacheManager::instance()->getFunc(tcpModel.tid);
  449. if (callback.tid != "0"){
  450. callback.onFalied(tcpModel.json);
  451. }
  452. if (tcpModel.tid == callTid){
  453. callActivityFinish(CallFinishType::FAILED);
  454. }
  455. }
  456. }
  457. else if (tcpModel.type == TcpType::POSITION) {
  458. if (tcpModel.action == PositionAction::POSITION_START) {
  459. setPosistionItId(tcpModel.json["id"].asInt());
  460. }
  461. }
  462. else if (tcpModel.type == TcpType::ROOMCHECK) {
  463. if (tcpModel.action == RoomCheckAction::START) {
  464. setRoomCheckItId(tcpModel.json["id"].asInt());
  465. }
  466. }
  467. else if (tcpModel.type == TcpType::SCREEN_TIP) {
  468. if (tcpModel.action == ScreenTipAction::START) {
  469. setPromptTimeItId(tcpModel.json["id"].asInt());
  470. }
  471. }
  472. else if (tcpModel.type == TcpType::AUTH) {
  473. if (tcpModel.action == AuthAction::LOGIN) {
  474. // 需要判断fromId跟自己是不是一样的,一样的就代表是自己发送出去,不一样的就代表员工已经登录到其他设备去了
  475. if (tcpModel.from_id == StoragePreferences::getInt(STORE_DEVICE_ID, 0)) {
  476. LOGD("id ===> %d", tcpModel.json["id"].asInt());
  477. setAuthItId(tcpModel.json["id"].asInt());
  478. }
  479. else {
  480. navibarNfcLogout();
  481. // logoutMedicalCare();
  482. // const char* currentAppName = EASYUICONTEXT->currentAppName();
  483. // string _currentAppName = currentAppName;
  484. // if (_currentAppName == "medicalCareActivity") {
  485. // goHome();
  486. // }
  487. }
  488. }
  489. }
  490. else if (tcpModel.type == TcpType::BLUE_CODE) {
  491. if (tcpModel.action == BlueCodeAction::SUCCESS) {
  492. int id = tcpModel.json["id"].asInt();
  493. LOGD("blue code id ===> %d", id);
  494. setBlueCodeId(id, tcpModel.tid);
  495. }
  496. }
  497. }
  498. bool getSleepTimerRegistered() {
  499. return isSleepTimerRegistered;
  500. }
  501. // 触发定时任务
  502. void setSleepTimerRegistered(bool result) {
  503. LOGD("isSleepTimerRegistered = %d", isSleepTimerRegistered);
  504. LOGD("result = %d", result);
  505. if (mActivityPtr == NULL) {
  506. return;
  507. }
  508. if (result != isSleepTimerRegistered) { // 与定时任务不同时,才进行处理
  509. if (isSleepTimerRegistered) { // 与定时任务开关进行判断,如果定时任务开启,那就要关闭
  510. isSleepTimerRegistered = result;
  511. mActivityPtr->unregisterUserTimer(SLEEP_STRAT_TIME_HANDLE); // 关闭定时器
  512. if (isSleep) {
  513. isSleep = false;
  514. BRIGHTNESSHELPER->screenOn();
  515. }
  516. LOGD("关闭息屏");
  517. } else { // 如果定时任务关着,那就要打开
  518. isSleepTimerRegistered = result;
  519. int sleepTime = StoragePreferences::getInt(STORE_SLEEP_TIME, 3);
  520. if (sleepTime > 0) {
  521. mActivityPtr->registerUserTimer(SLEEP_STRAT_TIME_HANDLE, sleepTime * 60 * 1000);
  522. LOGD("开启息屏");
  523. }
  524. }
  525. }
  526. }
  527. void scrrenOn() {
  528. isSleep = false;
  529. BRIGHTNESSHELPER->screenOn();
  530. }
  531. void setCallTid(std::string tid) {
  532. callTid = tid;
  533. }
  534. void handleHCall(int id) {
  535. int handleId = getHandleId(id);
  536. if (handleId != 0) {
  537. const char* currentAppName = EASYUICONTEXT->currentAppName();
  538. string _currentAppName = currentAppName;
  539. if (_currentAppName == "callActivity") {
  540. LOGD("已经在呼叫界面");
  541. return;
  542. }
  543. string handleIdStr = to_string(handleId);
  544. Intent* intent = new Intent();
  545. intent->putExtra(isOutgoing, "handleHCall");
  546. intent->putExtra(handleCallId, handleIdStr);
  547. EASYUICONTEXT->openActivity("callActivity", intent);
  548. }
  549. else {
  550. string errorMsg = LANGUAGEMANAGER->getValue("HandleError") +
  551. StoragePreferences::getString(STORE_MAC_ADDR, "0.0.0.0") + ":h" + to_string(id) + " \n" +
  552. LANGUAGEMANAGER->getValue("NotAdd");
  553. Intent* intent = new Intent();
  554. intent->putExtra(functionWindows, "warn");
  555. intent->putExtra(warnText, errorMsg);
  556. EASYUICONTEXT->openActivity("functionActivity", intent);
  557. }
  558. }
  559. void sosCall(string sosMsg) {
  560. if (sosTimerRegistered) {
  561. LOGD("TCP -> SOS_CALL");
  562. sendSosCall(sosMsg);
  563. // SOS亮红灯
  564. lightControl("ULED", "1F");
  565. // 门灯亮红灯
  566. lightControl("DOORLED", "200F");
  567. lightControl("CALLLED", "100F");
  568. sosTimerRegistered = false;
  569. mActivityPtr->registerUserTimer(SOS_CLICK_TIME_HANDLE, 10000); // 10秒后才能触发
  570. mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000); // 2分钟后才能触发
  571. }
  572. }
  573. //================================= IO 口操作
  574. //紧急按钮灯,明/灭
  575. void setSOS_A5(bool light){
  576. int result = -1;
  577. int slight = light?0:1;
  578. result = GpioHelper::output("A5", slight);
  579. if (result==0){
  580. LOGD("set A5 SOS light %d. success",light);
  581. } else {
  582. LOGD("set A5 SOS light %d. failed",light);
  583. }
  584. }
  585. //A6,A7,A8 RGB灯控制
  586. void setRGB_A678(bool R, bool G, bool B){
  587. int rR = -1, rG = -1, rB = -1;
  588. int sR = R?0:1, sG = G?0:1, sB = B?0:1;
  589. rR = GpioHelper::output("A6", sR);
  590. rG = GpioHelper::output("A7", sG);
  591. rB = GpioHelper::output("A8", sB);
  592. const char *strLog = "set %s light %d. %d";
  593. LOGD(strLog,"A6 R",R, rR);
  594. LOGD(strLog,"A7 G",G, rG);
  595. LOGD(strLog,"A8 B",B, rB);
  596. }
  597. //手柄按钮
  598. class A1GpioListener : public IGpioListener{
  599. public:
  600. bool onGpioEdge(const char *pPin) override {
  601. int state = GpioHelper::input("A1");
  602. LOGD("IGpioListener GPIO IS A1=%d", state);
  603. if (state==0){
  604. voip::CallInfo info = GetTelephone()->GetCallInfo();
  605. //拨打 或 挂断
  606. if (CallingStatus::instance()->busy()){
  607. callActivityFinish(CallFinishType::A1CLICK);
  608. } else {
  609. Intent* intent = new Intent();
  610. intent->putExtra(isOutgoing, "true");
  611. EASYUICONTEXT->openActivity("callActivity", intent);
  612. }
  613. }
  614. return true;
  615. }
  616. void onGpioError(const char *pPin, int error) override {
  617. LOGD("IGpioListener ERROR GPIO IS %s, %d", pPin, error);
  618. }
  619. };
  620. //7寸面板,呼出
  621. class A2GpioListener : public IGpioListener{
  622. public:
  623. bool onGpioEdge(const char *pPin) override {
  624. int state = GpioHelper::input("A2");
  625. LOGD("IGpioListener GPIO IS A2=%d", state);
  626. if (state==0){
  627. //拨打 或 接听
  628. }
  629. return true;
  630. }
  631. void onGpioError(const char *pPin, int error) override {
  632. LOGD("IGpioListener ERROR GPIO IS %s, %d", pPin, error);
  633. }
  634. };
  635. //7寸面板,挂断
  636. class A3GpioListener : public IGpioListener{
  637. public:
  638. bool onGpioEdge(const char *pPin) override {
  639. int state = GpioHelper::input("A3");
  640. LOGD("IGpioListener GPIO IS A3=%d", state);
  641. if (state==0){
  642. //挂断
  643. }
  644. return true;
  645. }
  646. void onGpioError(const char *pPin, int error) override {
  647. LOGD("IGpioListener ERROR GPIO IS %s, %d", pPin, error);
  648. }
  649. };
  650. //紧急按钮
  651. class A4GpioListener : public IGpioListener{
  652. public:
  653. bool onGpioEdge(const char *pPin) override {
  654. int state = GpioHelper::input("A4");
  655. LOGD("IGpioListener GPIO IS A4=%d", state);
  656. if (state==0){
  657. //发出
  658. setSOS_A5(true);
  659. }
  660. return true;
  661. }
  662. void onGpioError(const char *pPin, int error) override {
  663. LOGD("IGpioListener ERROR GPIO IS %s, %d", pPin, error);
  664. }
  665. };
  666. /**
  667. * 注册定时器
  668. * 填充数组用于注册定时器
  669. * 注意:id不能重复
  670. */
  671. static S_ACTIVITY_TIMEER REGISTER_ACTIVITY_TIMER_TAB[] = {
  672. {1, 5000},
  673. {2, 30*1000}
  674. };
  675. /**
  676. * 当界面构造时触发
  677. */
  678. static void onUI_init(){
  679. EASYUICONTEXT->updateLocalesCode(StoragePreferences::getString(STORE_LANG, defaultLang).c_str());
  680. //IO监测
  681. IGpioListener *iGpioListenerA1 = new A1GpioListener();
  682. GpioHelper::registerGpioListener("A1", iGpioListenerA1, E_GPIO_EDGE_TYPE_FALLING);
  683. IGpioListener *iGpioListenerA2 = new A2GpioListener();
  684. GpioHelper::registerGpioListener("A2", iGpioListenerA1, E_GPIO_EDGE_TYPE_FALLING);
  685. IGpioListener *iGpioListenerA3 = new A3GpioListener();
  686. GpioHelper::registerGpioListener("A3", iGpioListenerA1, E_GPIO_EDGE_TYPE_FALLING);
  687. IGpioListener *iGpioListenerA4 = new A4GpioListener();
  688. GpioHelper::registerGpioListener("A4", iGpioListenerA1, E_GPIO_EDGE_TYPE_FALLING);
  689. //TCP启动
  690. TcpClient::instance()->startTcp();
  691. //监听SIP信令
  692. GetTelephone()->AddCallStateListener(OnCallStateChanged);
  693. //开启网页
  694. httpServer.RunAsync(HTTP_SERVER_PORT);
  695. // 启动的时候更改为tcp模式
  696. StoragePreferences::putString(STORE_SIGNAL_TYPE, "TCP");
  697. if (StoragePreferences::getBool(STORE_NURSING_TYPE, false)) {
  698. LOGD("===============> 关闭护理状态");
  699. StoragePreferences::putBool(STORE_NURSING_TYPE, false);
  700. isNursing = true;
  701. }
  702. //请求版本号
  703. // if(UartContext::Uart3IsOpen()) {
  704. // string heartStr = "ASK,VNF-0";
  705. // const char* sendMsg = heartStr.c_str();
  706. // sendProtocolTo(UART_TTYS3, (byte*)(sendMsg), strlen(sendMsg));
  707. // }
  708. #if 0
  709. std::thread backend([](){
  710. while (true) {
  711. if (feed_dogs > 0) {
  712. --feed_dogs;
  713. LOGD("feed");
  714. int ret = GpioHelper::output("GPIO_2", 1); //拉高
  715. if (ret != 0) {
  716. LOGE("GPIO操作失败");
  717. }
  718. usleep(1000 * 20);
  719. ret = GpioHelper::output("GPIO_2", 0); //拉低
  720. if (ret != 0) {
  721. LOGE("GPIO操作失败");
  722. }
  723. }
  724. usleep(1000 * 1000);
  725. }
  726. });
  727. backend.detach();
  728. #endif
  729. }
  730. /**
  731. * 当切换到该界面时触发
  732. */
  733. static void onUI_intent(const Intent *intentPtr) {
  734. if (intentPtr != NULL) {
  735. //TODO
  736. }
  737. }
  738. /*
  739. * 当界面显示时触发
  740. */
  741. static void onUI_show() {
  742. StoragePreferences::putString(STORE_SIGNAL_TYPE, "TCP");
  743. //进入主界面
  744. EASYUICONTEXT->openActivity("mainActivity");
  745. }
  746. /*
  747. * 当界面隐藏时触发
  748. */
  749. static void onUI_hide() {
  750. }
  751. /*
  752. * 当界面完全退出时触发
  753. */
  754. static void onUI_quit() {
  755. }
  756. /**
  757. * 串口数据回调接口
  758. */
  759. static void onProtocolDataUpdate(const SProtocolData &data) {
  760. LOGD("cmd = %s", data.cmd.c_str());
  761. if (data.state!=""){
  762. LOGD("state = %s",data.state.c_str());
  763. }
  764. // if (data.msg != ""){
  765. // LOGD("msg = %s", data.msg.c_str());
  766. // }
  767. if(UartContext::Uart2IsOpen()) { // 如果是true,表示串口打开了
  768. string heartStr;
  769. // 面板拨号
  770. if (data.cmd == "KEY5") {
  771. if (data.state == "0") {
  772. if (isSleep) {
  773. scrrenOn();
  774. if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
  775. return;
  776. }
  777. }
  778. const char* currentAppName = EASYUICONTEXT->currentAppName();
  779. string _currentAppName = currentAppName;
  780. if (_currentAppName == "sipTestActivity") {
  781. setCheckbox("KEY5");
  782. return;
  783. }
  784. else {
  785. voip::CallInfo info = GetTelephone()->GetCallInfo();
  786. //拨打 或 挂断
  787. if (CallingStatus::instance()->busy()){
  788. callActivityFinish(CallFinishType::A1CLICK);
  789. } else {
  790. Intent* intent = new Intent();
  791. intent->putExtra(isOutgoing, "true");
  792. EASYUICONTEXT->openActivity("callActivity", intent);
  793. }
  794. }
  795. }
  796. }
  797. else if (data.cmd == "KEY6") {
  798. if (data.state == "0") {
  799. if (isSleep) {
  800. scrrenOn();
  801. if (!StoragePreferences::getInt(STORE_SCREEN_LIGHT, 0)) {
  802. return;
  803. }
  804. }
  805. const char* currentAppName = EASYUICONTEXT->currentAppName();
  806. string _currentAppName = currentAppName;
  807. if (_currentAppName == "sipTestActivity") {
  808. setCheckbox("KEY6");
  809. return;
  810. }
  811. isTriggerHandle = true;
  812. mActivityPtr->registerUserTimer(HANDLE_TRIGGER_TIME_HANDLE, 5 * 1000);
  813. }
  814. else if (data.state == "1") {
  815. if (isTriggerHandle) {
  816. isTriggerHandle = false;
  817. isConnectHandle = true;
  818. voip::CallInfo info = GetTelephone()->GetCallInfo();
  819. //拨打 或 挂断
  820. if (CallingStatus::instance()->busy()){
  821. callActivityFinish(CallFinishType::KEY6_CLICK);
  822. } else {
  823. Intent* intent = new Intent();
  824. intent->putExtra(isOutgoing, "true");
  825. EASYUICONTEXT->openActivity("callActivity", intent);
  826. }
  827. }
  828. }
  829. else if (data.state == "3") {
  830. LOGD("手柄在线");
  831. isConnectHandle = true;
  832. }
  833. else if (data.state == "4") {
  834. if (!isConnectHandle || StoragePreferences::getInt(STORE_DEVICE_ID, 0) == 0) {
  835. return;
  836. }
  837. sendDataRemindOhter(getFrameFullName() + " " + LANGUAGEMANAGER->getValue("HandleDisconnected"));
  838. }
  839. }
  840. else if (data.cmd == "KEY7") {
  841. if (data.state == "0") {
  842. scrrenOn();
  843. const char* currentAppName = EASYUICONTEXT->currentAppName();
  844. string _currentAppName = currentAppName;
  845. if (_currentAppName == "sipTestActivity") {
  846. setCheckbox("KEY7");
  847. return;
  848. }
  849. else {
  850. if (sosTimerRegistered) {
  851. isTriggerSos = true;
  852. mActivityPtr->registerUserTimer(SOS_TRIGGER_TIME_HANDLE, 5 * 1000);
  853. }
  854. }
  855. }
  856. else if (data.state == "1") {
  857. if (isTriggerSos) {
  858. isConnectSos = true;
  859. sendSosCall("");
  860. // SOS亮红灯
  861. lightControl("ULED", "1F");
  862. // 门灯亮红灯
  863. lightControl("DOORLED", "200F");
  864. lightControl("CALLLED", "100F");
  865. mActivityPtr->registerUserTimer(SOS_CLICK_TIME_HANDLE, 10000); // 10秒后才能触发
  866. mActivityPtr->registerUserTimer(SOS_LAMP_TIME_HANDLE, 120000); // 2分钟后才能触发
  867. }
  868. }
  869. else if (data.state == "3") {
  870. LOGD("SOS按钮在线");
  871. isConnectSos = true;
  872. }
  873. else if (data.state == "4") {
  874. if (!isConnectSos || StoragePreferences::getInt(STORE_DEVICE_ID, 0) == 0) {
  875. return;
  876. }
  877. sendDataRemindOhter(getFrameFullName() + " " + LANGUAGEMANAGER->getValue("SosDisconnected"));
  878. }
  879. }
  880. else if (data.cmd == "KEY<") {
  881. if (isSleep) {
  882. scrrenOn();
  883. }
  884. // lightControl("DOORLED", "100F");
  885. }
  886. else if (data.cmd == "KEY>") { // key>是面板挂断按钮
  887. if (data.state == "0") {
  888. if (StoragePreferences::getString(STORE_SIGNAL_TYPE, SIGNAL_TYPE) == "SIP") {
  889. setCheckbox("KEY>");
  890. return;
  891. }
  892. if (isSleep) {
  893. scrrenOn();
  894. }
  895. else {
  896. voip::CallInfo info = GetTelephone()->GetCallInfo();
  897. //拨打 或 挂断
  898. if (CallingStatus::instance()->busy()){
  899. callActivityFinish(CallFinishType::A1CLICK);
  900. lightControl("DOORLED", "000F");
  901. }
  902. }
  903. }
  904. }
  905. else if (data.cmd == "KEY;") {
  906. if (isSleep) {
  907. scrrenOn();
  908. }
  909. // lightControl("DOORLED", "111F");
  910. }
  911. else if (data.cmd == "HANDKEY00") {
  912. if (data.state == "0") {
  913. if (isSleep) {
  914. scrrenOn();
  915. }
  916. isTriggerHandle1 = true;
  917. mActivityPtr->registerUserTimer(HANDLE1_TRIGGER_TIME_HANDLE, 5 * 1000);
  918. }
  919. else if (data.state == "1") {
  920. if (isTriggerHandle1) {
  921. isTriggerHandle1 = false;
  922. isConnectHandle1 = true;
  923. handleHCall(1);
  924. }
  925. }
  926. else if (data.state == "3") {
  927. LOGD("手柄1在线");
  928. isConnectHandle1 = true;
  929. }
  930. else if (data.state == "4") {
  931. if (!isConnectHandle1 || StoragePreferences::getInt(STORE_DEVICE_ID, 0) == 0) {
  932. return;
  933. }
  934. sendDataRemindOhter(getFrameFullName() + " " + LANGUAGEMANAGER->getValue("Handle1Disconnected"));
  935. }
  936. }
  937. else if (data.cmd == "HANDKEY10") {
  938. if (data.state == "0") {
  939. if (isSleep) {
  940. scrrenOn();
  941. }
  942. isTriggerHandle2 = true;
  943. mActivityPtr->registerUserTimer(HANDLE2_TRIGGER_TIME_HANDLE, 5 * 1000);
  944. }
  945. else if (data.state == "1") {
  946. if (isTriggerHandle2) {
  947. isTriggerHandle2 = false;
  948. isConnectHandle2 = true;
  949. handleHCall(2);
  950. }
  951. }
  952. else if (data.state == "3") {
  953. LOGD("手柄2在线");
  954. isConnectHandle2 = true;
  955. }
  956. else if (data.state == "4" || StoragePreferences::getInt(STORE_DEVICE_ID, 0) == 0) {
  957. if (!isConnectHandle2) {
  958. return;
  959. }
  960. sendDataRemindOhter(getFrameFullName() + " " + LANGUAGEMANAGER->getValue("Handle2Disconnected"));
  961. }
  962. }
  963. else if (data.cmd == "HANDKEY20") {
  964. if (data.state == "0") {
  965. if (isSleep) {
  966. scrrenOn();
  967. }
  968. isTriggerHandle3 = true;
  969. mActivityPtr->registerUserTimer(HANDLE3_TRIGGER_TIME_HANDLE, 5 * 1000);
  970. }
  971. else if (data.state == "1") {
  972. if (isTriggerHandle3) {
  973. isTriggerHandle3 = false;
  974. isConnectHandle3 = true;
  975. handleHCall(3);
  976. }
  977. }
  978. else if (data.state == "3") {
  979. LOGD("手柄3在线");
  980. isConnectHandle3 = true;
  981. }
  982. else if (data.state == "4" || StoragePreferences::getInt(STORE_DEVICE_ID, 0) == 0) {
  983. if (!isConnectHandle3) {
  984. return;
  985. }
  986. sendDataRemindOhter(getFrameFullName() + " " + LANGUAGEMANAGER->getValue("Handle3Disconnected"));
  987. }
  988. }
  989. else if (data.cmd == "HANDKEY30") {
  990. if (data.state == "0") {
  991. if (isSleep) {
  992. scrrenOn();
  993. }
  994. isTriggerHandle4 = true;
  995. mActivityPtr->registerUserTimer(HANDLE4_TRIGGER_TIME_HANDLE, 5 * 1000);
  996. }
  997. else if (data.state == "1") {
  998. if (isTriggerHandle4) {
  999. isTriggerHandle4 = false;
  1000. isConnectHandle4 = true;
  1001. handleHCall(4);
  1002. }
  1003. }
  1004. else if (data.state == "3") {
  1005. LOGD("手柄4在线");
  1006. isConnectHandle4 = true;
  1007. }
  1008. else if (data.state == "4" || StoragePreferences::getInt(STORE_DEVICE_ID, 0) == 0) {
  1009. if (!isConnectHandle4) {
  1010. return;
  1011. }
  1012. sendDataRemindOhter(getFrameFullName() + " " + LANGUAGEMANAGER->getValue("Handle4Disconnected"));
  1013. }
  1014. }
  1015. else {
  1016. if (isSleep) {
  1017. scrrenOn();
  1018. }
  1019. lightControl("DOORLED", "000F");
  1020. }
  1021. }
  1022. }
  1023. /**
  1024. * 定时器触发函数
  1025. * 不建议在此函数中写耗时操作,否则将影响UI刷新
  1026. * 参数: id
  1027. * 当前所触发定时器的id,与注册时的id相同
  1028. * 返回值: true
  1029. * 继续运行当前定时器
  1030. * false
  1031. * 停止运行当前定时器
  1032. */
  1033. static bool onUI_Timer(int id){
  1034. switch (id) {
  1035. case 1:
  1036. {
  1037. //定时器跑在UI线程,这里将喂狗标记加1
  1038. //++feed_dogs;
  1039. //不用心跳
  1040. // if(UartContext::Uart3IsOpen()) {
  1041. // string heartStr = "HEART,1E";
  1042. // const char* sendMsg = heartStr.c_str();
  1043. // sendProtocolTo(UART_TTYS3, (byte*)(sendMsg), strlen(sendMsg));
  1044. // }
  1045. }
  1046. break;
  1047. case 2: //TCP心跳
  1048. {
  1049. const char* req = "0";
  1050. TcpClient::instance()->sendMsg(req);
  1051. }
  1052. break;
  1053. case SOS_CLICK_TIME_HANDLE: {
  1054. sosTimerRegistered = true;
  1055. return false;
  1056. }
  1057. break;
  1058. case SOS_LAMP_TIME_HANDLE: {
  1059. // SOS还原成无灯光的状态
  1060. lightControl("ULED", "0F");
  1061. // 进行门灯还原
  1062. lightControl("DOORLED", "000F");
  1063. statusLight();
  1064. return false;
  1065. }
  1066. break;
  1067. case SLEEP_STRAT_TIME_HANDLE: { // 息屏
  1068. if (isSleepTimerRegistered) {
  1069. isSleep = true;
  1070. BRIGHTNESSHELPER->screenOff();
  1071. } else { // 如果是false的话,就需要关闭定时器
  1072. isSleep = false;
  1073. BRIGHTNESSHELPER->screenOn();
  1074. }
  1075. }
  1076. break;
  1077. case SYS_RESTART_TIME_HANDLE:
  1078. netresetInt += 1;
  1079. lightControl("NETRESET", "1F");
  1080. if (netresetInt == 5) {
  1081. LOGD("网卡重启无效,程序内部重启");
  1082. //重启
  1083. sync();
  1084. reboot(RB_AUTOBOOT);
  1085. }
  1086. break;
  1087. case HANDLE_TRIGGER_TIME_HANDLE: {
  1088. isTriggerHandle = false;
  1089. return false;
  1090. }
  1091. break;
  1092. case SOS_TRIGGER_TIME_HANDLE: {
  1093. isTriggerSos = false;
  1094. return false;
  1095. }
  1096. break;
  1097. case HANDLE1_TRIGGER_TIME_HANDLE: {
  1098. isTriggerHandle1 = false;
  1099. return false;
  1100. }
  1101. break;
  1102. case HANDLE2_TRIGGER_TIME_HANDLE: {
  1103. isTriggerHandle2 = false;
  1104. return false;
  1105. }
  1106. break;
  1107. case HANDLE3_TRIGGER_TIME_HANDLE: {
  1108. isTriggerHandle3 = false;
  1109. return false;
  1110. }
  1111. break;
  1112. case HANDLE4_TRIGGER_TIME_HANDLE: {
  1113. isTriggerHandle4 = false;
  1114. return false;
  1115. }
  1116. break;
  1117. default:
  1118. break;
  1119. }
  1120. return true;
  1121. }
  1122. /**
  1123. * 有新的触摸事件时触发
  1124. * 参数:ev
  1125. * 新的触摸事件
  1126. * 返回值:true
  1127. * 表示该触摸事件在此被拦截,系统不再将此触摸事件传递到控件上
  1128. * false
  1129. * 触摸事件将继续传递到控件上
  1130. */
  1131. static bool onstartActivityTouchEvent(const MotionEvent &ev) {
  1132. switch (ev.mActionStatus) {
  1133. case MotionEvent::E_ACTION_DOWN://触摸按下
  1134. //LOGD("时刻 = %ld 坐标 x = %d, y = %d", ev.mEventTime, ev.mX, ev.mY);
  1135. break;
  1136. case MotionEvent::E_ACTION_MOVE://触摸滑动
  1137. break;
  1138. case MotionEvent::E_ACTION_UP: //触摸抬起
  1139. break;
  1140. default:
  1141. break;
  1142. }
  1143. return false;
  1144. }