CarplayLinkcbsImpl.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #include "CarplayLinkCbsImpl.h"
  2. #include "CarplayLink.h"
  3. #ifdef USE_CARPLAY
  4. void CarplayLinkCbsImpl::iap2LinkStatus(int status)
  5. {
  6. (void)status;
  7. }
  8. int CarplayLinkCbsImpl::iap2WriteData(char *buf, int len)
  9. {
  10. (void)buf;
  11. (void)len;
  12. return 0;
  13. }
  14. void CarplayLinkCbsImpl::carplaySessionStart()
  15. {
  16. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  17. }
  18. void CarplayLinkCbsImpl::carplaySessionStop()
  19. {
  20. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  21. }
  22. int CarplayLinkCbsImpl::switchUsbModeCB(UsbMode mode)
  23. {
  24. (void)mode;
  25. return 0;
  26. }
  27. void CarplayLinkCbsImpl::appleTimeUpdateCB(long long time, int zone_offset)
  28. {
  29. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  30. printf("time = %lld, zone_offset = %d\r\n", time, zone_offset);
  31. if(mHandle)
  32. mHandle->setLocalTime(time);
  33. }
  34. void CarplayLinkCbsImpl::appleLanguageUpdateCB(const char *lang)
  35. {
  36. }
  37. void CarplayLinkCbsImpl::NotifyDeviceNameCB(const char *name, int name_len)
  38. {
  39. }
  40. void CarplayLinkCbsImpl::carplayExitCB()
  41. {
  42. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  43. mEntityScreen = 2;
  44. mEntityPhoneCall = -1;
  45. mSpeechMode = 0;
  46. mEntityAudio = 0;
  47. mEntityByTurn = 0;
  48. mHandle->mInterfaceFrame = 0;
  49. if(mHandle)
  50. mHandle->onSdkConnectStatus(CONNECT_STATUS_DISCONNECTED,UnKnown);
  51. }
  52. void CarplayLinkCbsImpl::returnNativeUICB()
  53. {
  54. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  55. if(mHandle){
  56. mHandle->set_background();
  57. mHandle->app_status(APP_BACKGROUND, (void*)true);
  58. }
  59. }
  60. void CarplayLinkCbsImpl::modesChangeCB(CarPlayModeState *modes)
  61. {
  62. if(mHandle){
  63. if(mEntityScreen != modes->screen){
  64. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  65. printf("screen mode = %d\r\n",modes->screen);
  66. if(modes->screen == CarplayEntity_Controller)
  67. mHandle->app_status(APP_FOREGROUND, nullptr);
  68. else if(modes->screen == CarplayEntity_Accessory)
  69. mHandle->app_status(APP_BACKGROUND, (void*)true);
  70. mEntityScreen = modes->screen;
  71. }
  72. if(mEntityPhoneCall != modes->phoneCall){
  73. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  74. printf("phone call mode = %d\r\n",modes->phoneCall);
  75. if(modes->phoneCall == 1)
  76. mHandle->app_status(APP_PHONE_STARTED, nullptr);
  77. else
  78. mHandle->app_status(APP_PHONE_STOPPED, nullptr);
  79. mEntityPhoneCall = modes->phoneCall;
  80. }
  81. if(mSpeechMode != modes->speech.entity){
  82. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  83. printf("speech mode = %d\r\n",modes->speech);
  84. if(modes->speech.entity == 1)
  85. mHandle->app_status(APP_RECOGNITION_STARTED, nullptr);
  86. else
  87. mHandle->app_status(APP_RECOGNITION_STOPPED, nullptr);
  88. mSpeechMode = modes->speech.entity;
  89. }
  90. if(mEntityAudio != modes->mainAudio){
  91. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  92. printf("audio mode = %d\r\n",modes->mainAudio);
  93. if(modes->mainAudio == 1)
  94. mHandle->app_status(APP_MUSIC_STARTED, nullptr);
  95. else
  96. mHandle->app_status(APP_MUSIC_STOPPED, nullptr);
  97. mEntityAudio = modes->mainAudio;
  98. }
  99. if(mEntityByTurn != modes->turnByTurn){
  100. printf("%s:%s:%d\r\n",__FILE__,__func__,__LINE__);
  101. printf("turnByTurn mode = %d\r\n",modes->turnByTurn);
  102. if(modes->turnByTurn == 1)
  103. mHandle->app_status(APP_NAVI_STARTED, nullptr);
  104. else
  105. mHandle->app_status(APP_NAVI_STOPPED, nullptr);
  106. mEntityByTurn = modes->turnByTurn;
  107. }
  108. }
  109. }
  110. void CarplayLinkCbsImpl::disableBluetoothCB()
  111. {
  112. printf("disableBluetoothCB\n");
  113. mHandle->app_status(APP_BT_DISCONNECTED);
  114. }
  115. void CarplayLinkCbsImpl::caplayDuckAudioCB(double inDurationSecs, double inVolume)
  116. {
  117. static DuckInfo info = {0, 0};
  118. info.inDurationSecs = inDurationSecs;
  119. info.volume = inVolume;
  120. mHandle->app_status(APP_VOICE_DUCK, (void*)&info);
  121. printf("caplayDuckAudioCB inDurationSecs = %lf, inVolume = %lf\r\n", inDurationSecs, inVolume);
  122. }
  123. void CarplayLinkCbsImpl::caplayUnduckAudioCB(double inDurationSecs)
  124. {
  125. static double sec = 0;
  126. sec = inDurationSecs;
  127. mHandle->app_status(APP_VOICE_UNDUCK, (void*)&sec);
  128. printf("caplayUnduckAudioCB inDurationSecs = %lf\r\n", inDurationSecs);
  129. }
  130. #endif