Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d25d960f authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by android-build-merger
Browse files

Merge changes from topic "avrcp_controller_timer" am: f6a27e22

am: 1fde4e12

Change-Id: Ifeb2eab5b34157e0da7f3d7aa1bf7de9c20e2e0e
parents 1462d693 1fde4e12
Loading
Loading
Loading
Loading
+2 −85
Original line number Original line Diff line number Diff line
@@ -272,7 +272,6 @@ static void btif_rc_ctrl_upstreams_rsp_cmd(uint8_t event,
                                           uint8_t label,
                                           uint8_t label,
                                           btif_rc_device_cb_t* p_dev);
                                           btif_rc_device_cb_t* p_dev);
static void rc_ctrl_procedure_complete(btif_rc_device_cb_t* p_dev);
static void rc_ctrl_procedure_complete(btif_rc_device_cb_t* p_dev);
static void rc_stop_play_status_timer(btif_rc_device_cb_t* p_dev);
static void register_for_event_notification(btif_rc_supported_event_t* p_event,
static void register_for_event_notification(btif_rc_supported_event_t* p_event,
                                            btif_rc_device_cb_t* p_dev);
                                            btif_rc_device_cb_t* p_dev);
static void handle_get_capability_response(tBTA_AV_META_MSG* pmeta_msg,
static void handle_get_capability_response(tBTA_AV_META_MSG* pmeta_msg,
@@ -338,7 +337,6 @@ static void btif_rc_upstreams_rsp_evt(uint16_t event,
                                      uint8_t label,
                                      uint8_t label,
                                      btif_rc_device_cb_t* p_dev);
                                      btif_rc_device_cb_t* p_dev);


static void rc_start_play_status_timer(btif_rc_device_cb_t* p_dev);
static bool absolute_volume_disabled(void);
static bool absolute_volume_disabled(void);


/*****************************************************************************
/*****************************************************************************
@@ -688,7 +686,6 @@ void handle_rc_disconnect(tBTA_AV_RC_CLOSE* p_rc_close) {
  memset(&p_dev->rc_app_settings, 0, sizeof(btif_rc_player_app_settings_t));
  memset(&p_dev->rc_app_settings, 0, sizeof(btif_rc_player_app_settings_t));
  p_dev->rc_features_processed = false;
  p_dev->rc_features_processed = false;
  p_dev->rc_procedure_complete = false;
  p_dev->rc_procedure_complete = false;
  rc_stop_play_status_timer(p_dev);
  /* Check and clear the notification event list */
  /* Check and clear the notification event list */
  if (p_dev->rc_supported_event_list != NULL) {
  if (p_dev->rc_supported_event_list != NULL) {
    list_clear(p_dev->rc_supported_event_list);
    list_clear(p_dev->rc_supported_event_list);
@@ -2925,77 +2922,6 @@ static void btif_rc_control_cmd_timer_timeout(void* data) {
                        sizeof(btif_rc_timer_context_t), NULL);
                        sizeof(btif_rc_timer_context_t), NULL);
}
}


/***************************************************************************
 *
 * Function         btif_rc_play_status_timeout_handler
 *
 * Description      RC play status timeout handler (Runs in BTIF context).
 * Returns          None
 *
 **************************************************************************/
static void btif_rc_play_status_timeout_handler(UNUSED_ATTR uint16_t event,
                                                char* p_data) {
  btif_rc_handle_t* rc_handle = (btif_rc_handle_t*)p_data;
  btif_rc_device_cb_t* p_dev = btif_rc_get_device_by_handle(rc_handle->handle);
  if (p_dev == NULL) {
    BTIF_TRACE_ERROR("%s timeout handler but no device found for handle %d",
                     __func__, rc_handle->handle);
    return;
  }
  get_play_status_cmd(p_dev);
  rc_start_play_status_timer(p_dev);
}

/***************************************************************************
 *
 * Function         btif_rc_play_status_timer_timeout
 *
 * Description      RC play status timeout callback.
 *                  This is called from BTU context and switches to BTIF
 *                  context to handle the timeout events
 * Returns          None
 *
 **************************************************************************/
static void btif_rc_play_status_timer_timeout(void* data) {
  btif_rc_handle_t rc_handle;
  rc_handle.handle = PTR_TO_UINT(data);
  BTIF_TRACE_DEBUG("%s called with handle: %d", __func__, rc_handle);
  btif_transfer_context(btif_rc_play_status_timeout_handler, 0,
                        (char*)(&rc_handle), sizeof(btif_rc_handle_t), NULL);
}

/***************************************************************************
 *
 * Function         rc_start_play_status_timer
 *
 * Description      Helper function to start the timer to fetch play status.
 * Returns          None
 *
 **************************************************************************/
static void rc_start_play_status_timer(btif_rc_device_cb_t* p_dev) {
  /* Start the Play status timer only if it is not started */
  if (!alarm_is_scheduled(p_dev->rc_play_status_timer)) {
    if (p_dev->rc_play_status_timer == NULL) {
      p_dev->rc_play_status_timer = alarm_new("p_dev->rc_play_status_timer");
    }
    alarm_set_on_mloop(
        p_dev->rc_play_status_timer, BTIF_TIMEOUT_RC_INTERIM_RSP_MS,
        btif_rc_play_status_timer_timeout, UINT_TO_PTR(p_dev->rc_handle));
  }
}

/***************************************************************************
 *
 * Function         rc_stop_play_status_timer
 *
 * Description      Helper function to stop the play status timer.
 * Returns          None
 *
 **************************************************************************/
void rc_stop_play_status_timer(btif_rc_device_cb_t* p_dev) {
  alarm_cancel(p_dev->rc_play_status_timer);
}

/***************************************************************************
/***************************************************************************
 *
 *
 * Function         register_for_event_notification
 * Function         register_for_event_notification
@@ -3210,14 +3136,7 @@ static void handle_notification_response(tBTA_AV_META_MSG* pmeta_msg,
    BTIF_TRACE_DEBUG("%s: Interim response: 0x%2X ", __func__, p_rsp->event_id);
    BTIF_TRACE_DEBUG("%s: Interim response: 0x%2X ", __func__, p_rsp->event_id);
    switch (p_rsp->event_id) {
    switch (p_rsp->event_id) {
      case AVRC_EVT_PLAY_STATUS_CHANGE:
      case AVRC_EVT_PLAY_STATUS_CHANGE:
        /* Start timer to get play status periodically
        get_play_status_cmd(p_dev);
         * if the play state is playing.
         */
        if (p_rsp->param.play_status == AVRC_PLAYSTATE_PLAYING ||
            p_rsp->param.play_status == AVRC_PLAYSTATE_REV_SEEK ||
            p_rsp->param.play_status == AVRC_PLAYSTATE_FWD_SEEK) {
          rc_start_play_status_timer(p_dev);
        }
        do_in_jni_thread(
        do_in_jni_thread(
            FROM_HERE,
            FROM_HERE,
            base::Bind(bt_rc_ctrl_callbacks->play_status_changed_cb,
            base::Bind(bt_rc_ctrl_callbacks->play_status_changed_cb,
@@ -3234,6 +3153,7 @@ static void handle_notification_response(tBTA_AV_META_MSG* pmeta_msg,
           * Attributes will be fetched after the AVRCP procedure
           * Attributes will be fetched after the AVRCP procedure
           */
           */
          BE_STREAM_TO_UINT64(p_dev->rc_playing_uid, p_data);
          BE_STREAM_TO_UINT64(p_dev->rc_playing_uid, p_data);
          get_play_status_cmd(p_dev);
        }
        }
        break;
        break;


@@ -3321,11 +3241,8 @@ static void handle_notification_response(tBTA_AV_META_MSG* pmeta_msg,
         * if the play state is playing.
         * if the play state is playing.
         */
         */
        if (p_rsp->param.play_status == AVRC_PLAYSTATE_PLAYING) {
        if (p_rsp->param.play_status == AVRC_PLAYSTATE_PLAYING) {
          rc_start_play_status_timer(p_dev);
          get_element_attribute_cmd(AVRC_MAX_NUM_MEDIA_ATTR_ID, attr_list,
          get_element_attribute_cmd(AVRC_MAX_NUM_MEDIA_ATTR_ID, attr_list,
                                    p_dev);
                                    p_dev);
        } else {
          rc_stop_play_status_timer(p_dev);
        }
        }
        do_in_jni_thread(
        do_in_jni_thread(
            FROM_HERE,
            FROM_HERE,