components/bt/host/bluedroid/stack/btm/btm_sec.c
/*******************************************************************************
**
** Function         btm_sec_start_authorization
**
** Description      This function is called to start authorization
**
** Returns          TRUE if started
**
*******************************************************************************/
Function         btm_sec_start_authorization
Description      This function is called to start authorization

Returns          TRUE if started
Function btm_sec_start_authorization Description This function is called to start authorization Returns TRUE if started
static UINT8 btm_sec_start_authorization (tBTM_SEC_DEV_REC *p_dev_rec)
{
    UINT8    result;
    UINT8   *p_service_name = NULL;
    UINT8    service_id;
    if ((p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN)
            || (p_dev_rec->hci_handle == BTM_SEC_INVALID_HANDLE)) {
        if (!btm_cb.api.p_authorize_callback) {
            return (BTM_MODE_UNSUPPORTED);
        }
        if (p_dev_rec->p_cur_service) {
#if BTM_SEC_SERVICE_NAME_LEN > 0
            if (p_dev_rec->is_originator) {
                p_service_name = p_dev_rec->p_cur_service->orig_service_name;
            } else {
                p_service_name = p_dev_rec->p_cur_service->term_service_name;
            }
#endif
            service_id = p_dev_rec->p_cur_service->service_id;
        } else {
            service_id = 0;
        }
        if (p_dev_rec->last_author_service_id == BTM_SEC_NO_LAST_SERVICE_ID
                || p_dev_rec->last_author_service_id != service_id) {
            p_dev_rec->sec_state = BTM_SEC_STATE_AUTHORIZING;
            result = (*btm_cb.api.p_authorize_callback) (p_dev_rec->bd_addr,
                     p_dev_rec->dev_class,
                     p_dev_rec->sec_bd_name,
                     p_service_name,
                     service_id,
                     p_dev_rec->is_originator);
        }
        else {  
            BTM_TRACE_DEBUG ("btm_sec_start_authorization: (Ignoring extra Authorization prompt for service %d)\n", service_id);
            return (BTM_SUCCESS);
        }
        if (result == BTM_SUCCESS) {
            p_dev_rec->sec_flags |= BTM_SEC_AUTHORIZED;
            if (!p_dev_rec->is_originator) {
                p_dev_rec->last_author_service_id = service_id;
            }
            p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
        }
        return (result);
    }
    btm_sec_start_get_name (p_dev_rec);
    return (BTM_CMD_STARTED);
}
static UINT8 btm_sec_start_authorization ( tBTM_SEC_DEV_REC * p_dev_rec ) { UINT8 result ; UINT8 * p_service_name = NULL ; UINT8 service_id ; if ( ( p_dev_rec -> sec_flags & BTM_SEC_NAME_KNOWN ) || ( p_dev_rec -> hci_handle == BTM_SEC_INVALID_HANDLE ) ) { if ( ! btm_cb . api . p_authorize_callback ) { return ( BTM_MODE_UNSUPPORTED ) ; } if ( p_dev_rec -> p_cur_service ) { #if BTM_SEC_SERVICE_NAME_LEN > 0 if ( p_dev_rec -> is_originator ) { p_service_name = p_dev_rec -> p_cur_service -> orig_service_name ; } else { p_service_name = p_dev_rec -> p_cur_service -> term_service_name ; } #endif service_id = p_dev_rec -> p_cur_service -> service_id ; } else { service_id = 0 ; } if ( p_dev_rec -> last_author_service_id == BTM_SEC_NO_LAST_SERVICE_ID || p_dev_rec -> last_author_service_id != service_id ) { p_dev_rec -> sec_state = BTM_SEC_STATE_AUTHORIZING ; result = ( * btm_cb . api . p_authorize_callback ) ( p_dev_rec -> bd_addr , p_dev_rec -> dev_class , p_dev_rec -> sec_bd_name , p_service_name , service_id , p_dev_rec -> is_originator ) ; } else { BTM_TRACE_DEBUG ( " \n " , service_id ) ; return ( BTM_SUCCESS ) ; } if ( result == BTM_SUCCESS ) { p_dev_rec -> sec_flags |= BTM_SEC_AUTHORIZED ; if ( ! p_dev_rec -> is_originator ) { p_dev_rec -> last_author_service_id = service_id ; } p_dev_rec -> sec_state = BTM_SEC_STATE_IDLE ; } return ( result ) ; } btm_sec_start_get_name ( p_dev_rec ) ; return ( BTM_CMD_STARTED ) ; }
Function         btm_sec_start_authorization
Description      This function is called to start authorization
Function btm_sec_start_authorization Description This function is called to start authorization
/* Send authorization request if not already sent during this service connection */ /* Already authorized once for this L2CAP bringup */ /* Save the currently authorized service in case we are asked again by another multiplexer layer */