startLogic.cc 33 KB

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