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

Commit e5a2e67f authored by Jack He's avatar Jack He Committed by android-build-merger
Browse files

HFP: Use objects for shared library interface and callbacks (1/2) am: e43b237f am: c5932756

am: c847af55

Change-Id: I9fe97ef3ba713db66c5f8253f50464df32a831ba
parents 4c71d878 c847af55
Loading
Loading
Loading
Loading
+28 −7
Original line number Diff line number Diff line
@@ -16,13 +16,34 @@
 *
 ******************************************************************************/

#ifndef BTIF_HF_H
#define BTIF_HF_H
#pragma once

#include <stdbool.h>
#include <hardware/bluetooth_headset_interface.h>

// Check whether there is a Hands-Free call in progress.
// Returns true if no call is in progress.
bool btif_hf_is_call_idle(void);
namespace bluetooth {
namespace headset {

#endif /* BTIF_HF_H */
/**
 * Get an instance of the headset interface from the loaded shared library
 *
 * @return an instance of the headset interface
 */
Interface* GetInterface();

/**
 * Check whether there is a Hands-Free call in progress.
 *
 * @return true if no call is in progress.
 */
bool IsCallIdle();

/**
 * Start up or shutdown the service
 *
 * @param b_enable true to enable, false to disable
 * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
 */
bt_status_t ExecuteService(bool b_enable);

}  // namespace headset
}  // namespace bluetooth
+0 −4
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#define BTIF_UTIL_H

#include <hardware/bluetooth.h>
#include <hardware/bt_hf.h>
#include <stdbool.h>
#include <sys/time.h>

@@ -51,10 +50,7 @@ const char* dump_hf_event(uint16_t event);
const char* dump_hf_client_event(uint16_t event);
const char* dump_hh_event(uint16_t event);
const char* dump_hd_event(uint16_t event);
const char* dump_hf_conn_state(uint16_t event);
const char* dump_hf_call_state(bthf_call_state_t call_state);
const char* dump_property_type(bt_property_type_t type);
const char* dump_hf_audio_state(uint16_t event);
const char* dump_adapter_scan_mode(bt_scan_mode_t mode);
const char* dump_thread_evt(bt_cb_thread_evt evt);
const char* dump_av_conn_state(uint16_t event);
+5 −6
Original line number Diff line number Diff line
@@ -33,10 +33,10 @@
#include <unistd.h>

#include <hardware/bluetooth.h>
#include <hardware/bluetooth_headset_interface.h>
#include <hardware/bt_av.h>
#include <hardware/bt_gatt.h>
#include <hardware/bt_hd.h>
#include <hardware/bt_hf.h>
#include <hardware/bt_hf_client.h>
#include <hardware/bt_hh.h>
#include <hardware/bt_hl.h>
@@ -48,12 +48,13 @@

#include "bt_utils.h"
#include "bta/include/bta_hf_client_api.h"
#include "btif/include/btif_debug_btsnoop.h"
#include "btif/include/btif_debug_conn.h"
#include "btif_a2dp.h"
#include "btif_api.h"
#include "btif_config.h"
#include "btif_debug.h"
#include "btif_debug_btsnoop.h"
#include "btif_debug_conn.h"
#include "btif_hf.h"
#include "btif_storage.h"
#include "btsnoop.h"
#include "btsnoop_mem.h"
@@ -82,8 +83,6 @@ bool restricted_mode = false;

/* list all extended interfaces here */

/* handsfree profile */
extern const bthf_interface_t* btif_hf_get_interface();
/* handsfree profile - client */
extern const bthf_client_interface_t* btif_hf_client_get_interface();
/* advanced audio profile */
@@ -333,7 +332,7 @@ static const void* get_profile_interface(const char* profile_id) {

  /* check for supported profile interfaces */
  if (is_profile(profile_id, BT_PROFILE_HANDSFREE_ID))
    return btif_hf_get_interface();
    return bluetooth::headset::GetInterface();

  if (is_profile(profile_id, BT_PROFILE_HANDSFREE_CLIENT_ID))
    return btif_hf_client_get_interface();
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ static void btif_a2dp_recv_ctrl_data(void) {
       * Some headsets such as "Sony MW600", don't allow AVDTP START
       * while in a call, and respond with BAD_STATE.
       */
      if (!btif_hf_is_call_idle()) {
      if (!bluetooth::headset::IsCallIdle()) {
        btif_a2dp_command_ack(A2DP_CTRL_ACK_INCALL_FAILURE);
        break;
      }
+2 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include "btif_config.h"
#include "btif_dm.h"
#include "btif_hd.h"
#include "btif_hf.h"
#include "btif_hh.h"
#include "btif_sdp.h"
#include "btif_storage.h"
@@ -240,7 +241,6 @@ static void btif_stats_add_bond_event(const RawAddress& bd_addr,
/******************************************************************************
 *  Externs
 *****************************************************************************/
extern bt_status_t btif_hf_execute_service(bool b_enable);
extern bt_status_t btif_av_execute_service(bool b_enable);
extern bt_status_t btif_av_sink_execute_service(bool b_enable);
extern bt_status_t btif_hh_execute_service(bool b_enable);
@@ -298,7 +298,7 @@ bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id,
  switch (service_id) {
    case BTA_HFP_SERVICE_ID:
    case BTA_HSP_SERVICE_ID: {
      btif_hf_execute_service(b_enable);
      bluetooth::headset::ExecuteService(b_enable);
    } break;
    case BTA_A2DP_SOURCE_SERVICE_ID: {
      btif_av_execute_service(b_enable);
Loading