Version 1.9.5
- Fix occasional 100 ms stall in HIDL code. - Perform recovery when read operations fail in VFS. - Fix issue where a failed open() call in VFS locked the stack in ENABLING state. - Fix VFS behavior when enable()/disable() called while already in desired state.
This commit is contained in:
		@@ -21,7 +21,7 @@
 | 
			
		||||
 | 
			
		||||
#define LIBANT_STACK_MAJOR "1"
 | 
			
		||||
#define LIBANT_STACK_MINOR "9"
 | 
			
		||||
#define LIBANT_STACK_INCRE "4"
 | 
			
		||||
#define LIBANT_STACK_INCRE "5"
 | 
			
		||||
 | 
			
		||||
#endif // __ANT_VERSION_H
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -227,13 +227,9 @@ ANTStatus ant_tx_write(ANT_U8 *pucTxMessage,ANT_U8 ucMessageLength)
 | 
			
		||||
ANTStatus ant_rx_check()
 | 
			
		||||
{
 | 
			
		||||
   ALOGV("%s: start", __func__);
 | 
			
		||||
   if (ant_hci.rx_processing)
 | 
			
		||||
   {
 | 
			
		||||
      return ANT_STATUS_SUCCESS;
 | 
			
		||||
   }
 | 
			
		||||
   Lock lock(ant_hci.data_mtx);
 | 
			
		||||
   while (ant_hci.rx_processing == 0)
 | 
			
		||||
   {
 | 
			
		||||
      std::unique_lock< std::mutex> lock(ant_hci.data_mtx);
 | 
			
		||||
      ant_hci.data_cond.wait_for(lock,std::chrono::milliseconds(POLL_TIMEOUT_MS));
 | 
			
		||||
      if (ant_hci.state != ANT_RADIO_ENABLED)
 | 
			
		||||
      {
 | 
			
		||||
 
 | 
			
		||||
@@ -174,16 +174,20 @@ ANTStatus ant_deinit(void)
 | 
			
		||||
//  Psuedocode:
 | 
			
		||||
/*
 | 
			
		||||
LOCK enable_LOCK
 | 
			
		||||
    State callback: STATE = ENABLING
 | 
			
		||||
    ant enable
 | 
			
		||||
    IF ant_enable success
 | 
			
		||||
        State callback: STATE = ENABLED
 | 
			
		||||
        RESULT = SUCCESS
 | 
			
		||||
    ELSE
 | 
			
		||||
        ant disable
 | 
			
		||||
        State callback: STATE = Current state
 | 
			
		||||
        RESULT = FAILURE
 | 
			
		||||
    ENDIF
 | 
			
		||||
   IF current_state != ENABLED
 | 
			
		||||
      State callback: STATE = ENABLING
 | 
			
		||||
      ant enable
 | 
			
		||||
      IF ant_enable success
 | 
			
		||||
         State callback: STATE = ENABLED
 | 
			
		||||
         RESULT = SUCCESS
 | 
			
		||||
      ELSE
 | 
			
		||||
         ant disable
 | 
			
		||||
         State callback: STATE = Current state
 | 
			
		||||
         RESULT = FAILURE
 | 
			
		||||
      ENDIF
 | 
			
		||||
   ELSE
 | 
			
		||||
      RESULT = SUCCESS
 | 
			
		||||
   ENDIF
 | 
			
		||||
UNLOCK
 | 
			
		||||
*/
 | 
			
		||||
////////////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -201,23 +205,28 @@ ANTStatus ant_enable_radio(void)
 | 
			
		||||
   }
 | 
			
		||||
   ANT_DEBUG_V("got stEnabledStatusLock in %s", __FUNCTION__);
 | 
			
		||||
 | 
			
		||||
   if (g_fnStateCallback) {
 | 
			
		||||
      g_fnStateCallback(RADIO_STATUS_ENABLING);
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   if (ant_enable() < 0) {
 | 
			
		||||
      ANT_ERROR("ant enable failed: %s", strerror(errno));
 | 
			
		||||
 | 
			
		||||
      ant_disable();
 | 
			
		||||
 | 
			
		||||
   if (ant_radio_enabled_status() != RADIO_STATUS_ENABLED) {
 | 
			
		||||
      if (g_fnStateCallback) {
 | 
			
		||||
         g_fnStateCallback(ant_radio_enabled_status());
 | 
			
		||||
         g_fnStateCallback(RADIO_STATUS_ENABLING);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (ant_enable() < 0) {
 | 
			
		||||
         ANT_ERROR("ant enable failed: %s", strerror(errno));
 | 
			
		||||
 | 
			
		||||
         ant_disable();
 | 
			
		||||
 | 
			
		||||
         if (g_fnStateCallback) {
 | 
			
		||||
            g_fnStateCallback(ant_radio_enabled_status());
 | 
			
		||||
         }
 | 
			
		||||
      } else {
 | 
			
		||||
         if (g_fnStateCallback) {
 | 
			
		||||
            g_fnStateCallback(RADIO_STATUS_ENABLED);
 | 
			
		||||
         }
 | 
			
		||||
 | 
			
		||||
         result_status = ANT_STATUS_SUCCESS;
 | 
			
		||||
      }
 | 
			
		||||
   } else {
 | 
			
		||||
      if (g_fnStateCallback) {
 | 
			
		||||
         g_fnStateCallback(RADIO_STATUS_ENABLED);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      ANT_DEBUG_D("Ignoring redundant enable call.");
 | 
			
		||||
      result_status = ANT_STATUS_SUCCESS;
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
@@ -340,10 +349,12 @@ out:
 | 
			
		||||
//  Psuedocode:
 | 
			
		||||
/*
 | 
			
		||||
LOCK enable_LOCK
 | 
			
		||||
    State callback: STATE = DISABLING
 | 
			
		||||
    ant disable
 | 
			
		||||
    State callback: STATE = Current state
 | 
			
		||||
    RESULT = SUCCESS
 | 
			
		||||
   IF current_state != DISABLED
 | 
			
		||||
      State callback: STATE = DISABLING
 | 
			
		||||
      ant disable
 | 
			
		||||
      State callback: STATE = Current state
 | 
			
		||||
   ENDIF
 | 
			
		||||
   RESULT = SUCCESS
 | 
			
		||||
UNLOCK
 | 
			
		||||
*/
 | 
			
		||||
////////////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -361,14 +372,18 @@ ANTStatus ant_disable_radio(void)
 | 
			
		||||
   }
 | 
			
		||||
   ANT_DEBUG_V("got stEnabledStatusLock in %s", __FUNCTION__);
 | 
			
		||||
 | 
			
		||||
   if (g_fnStateCallback) {
 | 
			
		||||
      g_fnStateCallback(RADIO_STATUS_DISABLING);
 | 
			
		||||
   }
 | 
			
		||||
   if (ant_radio_enabled_status() != RADIO_STATUS_DISABLED) {
 | 
			
		||||
      if (g_fnStateCallback) {
 | 
			
		||||
         g_fnStateCallback(RADIO_STATUS_DISABLING);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
   ant_disable();
 | 
			
		||||
      ant_disable();
 | 
			
		||||
 | 
			
		||||
   if (g_fnStateCallback) {
 | 
			
		||||
      g_fnStateCallback(ant_radio_enabled_status());
 | 
			
		||||
      if (g_fnStateCallback) {
 | 
			
		||||
         g_fnStateCallback(ant_radio_enabled_status());
 | 
			
		||||
      }
 | 
			
		||||
   } else {
 | 
			
		||||
      ANT_DEBUG_D("Ignoring redundant disable call.");
 | 
			
		||||
   }
 | 
			
		||||
 | 
			
		||||
   ret = ANT_STATUS_SUCCESS;
 | 
			
		||||
@@ -934,6 +949,9 @@ int ant_enable(void)
 | 
			
		||||
   iRet = 0;
 | 
			
		||||
 | 
			
		||||
out:
 | 
			
		||||
   if (stRxThreadInfo.stRxThread == 0) {
 | 
			
		||||
      stRxThreadInfo.ucRunThread = 0;
 | 
			
		||||
   }
 | 
			
		||||
   ANT_FUNC_END();
 | 
			
		||||
   return iRet;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -162,7 +162,8 @@ void *fnRxThread(void *ant_rx_thread_info)
 | 
			
		||||
            } else if (areAllFlagsSet(astPollFd[eChannel].revents, EVENT_CHIP_SHUTDOWN)) {
 | 
			
		||||
               /* chip reported it was unexpectedly disabled */
 | 
			
		||||
               ANT_DEBUG_D(
 | 
			
		||||
                     "poll hang-up from %s. exiting rx thread", stRxThreadInfo->astChannels[eChannel].pcDevicePath);
 | 
			
		||||
                     "poll hang-up from %s. Attempting recovery.",
 | 
			
		||||
                     stRxThreadInfo->astChannels[eChannel].pcDevicePath);
 | 
			
		||||
 | 
			
		||||
               doReset(stRxThreadInfo);
 | 
			
		||||
               goto out;
 | 
			
		||||
@@ -174,8 +175,9 @@ void *fnRxThread(void *ant_rx_thread_info)
 | 
			
		||||
               stRxThreadInfo->bWaitingForKeepaliveResponse = ANT_FALSE;
 | 
			
		||||
 | 
			
		||||
               if (readChannelMsg(eChannel, &stRxThreadInfo->astChannels[eChannel]) < 0) {
 | 
			
		||||
                  // set flag to exit out of Rx Loop
 | 
			
		||||
                  stRxThreadInfo->ucRunThread = 0;
 | 
			
		||||
                  ANT_ERROR("Read of data failed. Attempting recovery.");
 | 
			
		||||
                  doReset(stRxThreadInfo);
 | 
			
		||||
                  goto out;
 | 
			
		||||
               }
 | 
			
		||||
            } else if (areAllFlagsSet(astPollFd[eChannel].revents, POLLNVAL)) {
 | 
			
		||||
               ANT_ERROR("poll was called on invalid file descriptor %s. Attempting recovery.",
 | 
			
		||||
@@ -360,7 +362,7 @@ int readChannelMsg(ant_channel_type eChannel, ant_channel_info_t *pstChnlInfo)
 | 
			
		||||
 | 
			
		||||
   if (iRxLenRead < 0) {
 | 
			
		||||
      if (errno == ENODEV) {
 | 
			
		||||
         ANT_ERROR("%s not enabled, exiting rx thread",
 | 
			
		||||
         ANT_ERROR("%s not enabled",
 | 
			
		||||
               pstChnlInfo->pcDevicePath);
 | 
			
		||||
 | 
			
		||||
         goto out;
 | 
			
		||||
@@ -370,7 +372,7 @@ int readChannelMsg(ant_channel_type eChannel, ant_channel_info_t *pstChnlInfo)
 | 
			
		||||
 | 
			
		||||
         goto out;
 | 
			
		||||
      } else {
 | 
			
		||||
         ANT_ERROR("%s read thread exiting, unhandled error: %s",
 | 
			
		||||
         ANT_ERROR("%s: unhandled error: %s",
 | 
			
		||||
               pstChnlInfo->pcDevicePath, strerror(errno));
 | 
			
		||||
 | 
			
		||||
         goto out;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user