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

Commit e3a3ec52 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7040294 from ecd77588 to sc-release

Change-Id: Id16901bb02e8075a5462bf5bca56e06681700a3f
parents 2aab1f24 ecd77588
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ cc_library_shared {
        "android/bluetooth/IBluetoothCallback.aidl",
        "android/bluetooth/IBluetoothProfileServiceConnection.aidl",
        "android/bluetooth/IBluetoothHeadset.aidl",
        "android/bluetooth/IBluetoothHeadsetPhone.aidl",
        "android/bluetooth/IBluetoothHearingAid.aidl",
        "android/bluetooth/IBluetoothHidHost.aidl",
        "android/bluetooth/IBluetoothPan.aidl",
@@ -93,7 +92,6 @@ filegroup {
        "android/bluetooth/IBluetoothCallback.aidl",
        "android/bluetooth/IBluetoothProfileServiceConnection.aidl",
        "android/bluetooth/IBluetoothHeadset.aidl",
        "android/bluetooth/IBluetoothHeadsetPhone.aidl",
        "android/bluetooth/IBluetoothHearingAid.aidl",
        "android/bluetooth/IBluetoothHidHost.aidl",
        "android/bluetooth/IBluetoothLeAudio.aidl",
+0 −39
Original line number Diff line number Diff line
/*
 * Copyright 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.bluetooth;

/**
 * API for Bluetooth Headset Phone Service in phone app
 *
 * {@hide}
 */
interface IBluetoothHeadsetPhone {
  // Internal functions, not be made public
  boolean answerCall();
  boolean hangupCall();
  boolean sendDtmf(int dtmf);
  boolean processChld(int chld);
  String getNetworkOperator();
  String getSubscriberNumber();
  boolean listCurrentCalls();
  boolean queryPhoneState();

  // Internal for phone app to call
  void updateBtHandsfreeAfterRadioTechnologyChange();
  void cdmaSwapSecondCallState();
  void cdmaSetSecondCallState(boolean state);
}
+6 −5
Original line number Diff line number Diff line
@@ -534,14 +534,15 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] = {
 * lowest latency */
tBTA_DM_SSR_SPEC bta_dm_ssr_spec[] = {
    /*max_lat, min_rmt_to, min_loc_to*/
    {0, 0, 0}, /* BTA_DM_PM_SSR0 - do not use SSR */
    {0, 0, 0, "no_ssr"}, /* BTA_DM_PM_SSR0 - do not use SSR */
    /* BTA_DM_PM_SSR1 - HH, can NOT share entry with any other profile, seting
       default max latency and min remote timeout as 0, and always read
       individual device preference from HH module */
    {0, 0, 2},
    {1200, 2, 2},     /* BTA_DM_PM_SSR2 - others (as long as sniff is allowed)*/
    {360, 160, 1600}, /* BTA_DM_PM_SSR3 - HD */
    {1200, 65534, 65534} /* BTA_DM_PM_SSR4 - A2DP streaming */
    {0, 0, 2, "hid_host"},
    {1200, 2, 2, "sniff_capable"},  /* BTA_DM_PM_SSR2 - others (as long as sniff
                                       is allowed)*/
    {360, 160, 1600, "hid_device"}, /* BTA_DM_PM_SSR3 - HD */
    {1200, 65534, 65534, "a2dp"}    /* BTA_DM_PM_SSR4 - A2DP streaming */
};

tBTA_DM_SSR_SPEC* p_bta_dm_ssr_spec = &bta_dm_ssr_spec[0];
+18 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#ifndef BTA_DM_INT_H
#define BTA_DM_INT_H

#include <base/strings/stringprintf.h>
#include <memory>
#include "bt_target.h"
#include "bta/sys/bta_sys.h"
@@ -167,11 +168,27 @@ typedef enum : uint8_t {
  BTA_DM_DI_INT_SNIFF = 0x02, /* set this bit if call BTM_SetPowerMode(sniff) &
                                 enter sniff mode */
  BTA_DM_DI_ACP_SNIFF = 0x04, /* set this bit if peer init sniff */
  BTA_DM_DI_UNUSED = 0x08,
  BTA_DM_DI_USE_SSR = 0x10, /* set this bit if ssr is supported for this link */
  BTA_DM_DI_AV_ACTIVE = 0x20, /* set this bit if AV is active for this link */
} tBTA_DM_DEV_INFO_BITMASK;
typedef uint8_t tBTA_DM_DEV_INFO;

inline std::string device_info_text(tBTA_DM_DEV_INFO info) {
  const char* const device_info_text[] = {
      ":set_sniff", ":int_sniff", ":acp_sniff",
      ":unused",    ":use_ssr",   ":av_active",
  };

  std::string s = base::StringPrintf("0x%02x", info);
  if (info == BTA_DM_DI_NONE) return s + std::string(":none");
  for (size_t i = 0; i < sizeof(device_info_text) / sizeof(device_info_text[0]);
       i++) {
    if (info & (1u << i)) s += std::string(device_info_text[i]);
  }
  return s;
}

/* set power mode request type */
#define BTA_DM_PM_RESTART 1
#define BTA_DM_PM_NEW_REQ 2
@@ -379,6 +396,7 @@ typedef struct {
  uint16_t max_lat;
  uint16_t min_rmt_to;
  uint16_t min_loc_to;
  const char* name{nullptr};
} tBTA_DM_SSR_SPEC;

typedef struct {
+56 −30
Original line number Diff line number Diff line
@@ -336,10 +336,9 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
  tBTA_DM_PEER_DEVICE* p_dev;
  tBTA_DM_PM_REQ pm_req = BTA_DM_PM_NEW_REQ;

  APPL_TRACE_DEBUG("bta_dm_pm_cback: st(%d), id(%d), app(%d)", status, id,
                   app_id);

  p_dev = bta_dm_find_peer_device(peer_addr);
  LOG_DEBUG("Power management callback status:%s[%hhu] id:%s[%d], app:%hhu",
            bta_sys_conn_status_text(status).c_str(), status,
            BtaIdSysText(id).c_str(), id, app_id);

  /* find if there is an power mode entry for the service */
  for (i = 1; i <= p_bta_dm_pm_cfg[0].app_id; i++) {
@@ -350,10 +349,21 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
  }

  /* if no entries are there for the app_id and subsystem in p_bta_dm_pm_spec*/
  if (i > p_bta_dm_pm_cfg[0].app_id) return;
  if (i > p_bta_dm_pm_cfg[0].app_id) {
    LOG_DEBUG("Ignoring power management callback as no service entries exist");
    return;
  }

  LOG_DEBUG("Stopped all timers for service to device:%s id:%hhu",
            PRIVATE_ADDRESS(peer_addr), id);
  bta_dm_pm_stop_timer_by_srvc_id(peer_addr, id);
/*p_dev = bta_dm_find_peer_device(peer_addr);*/

  p_dev = bta_dm_find_peer_device(peer_addr);
  if (p_dev) {
    LOG_DEBUG("Device info:%s", device_info_text(p_dev->info).c_str());
  } else {
    LOG_ERROR("Unable to find peer device...yet soldiering on...");
  }

  /* set SSR parameters on SYS CONN OPEN */
  int index = BTA_DM_PM_SSR0;
@@ -441,11 +451,7 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, uint8_t id,
    p_dev->pm_mode_failed = 0;
  }

  if (p_bta_dm_ssr_spec[index].max_lat
#if (BTA_HH_INCLUDED == TRUE)
      || index == BTA_DM_PM_SSR_HH
#endif
      ) {
  if (p_bta_dm_ssr_spec[index].max_lat || index == BTA_DM_PM_SSR_HH) {
    bta_dm_pm_ssr(peer_addr, index);
  } else {
    const controller_t* controller = controller_get_interface();
@@ -709,6 +715,9 @@ static void bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE* p_peer_dev, uint8_t index) {
            p_peer_dev->info);

  uint8_t* p_rem_feat = BTM_ReadRemoteFeatures(p_peer_dev->peer_bdaddr);
  LOG_DEBUG("Current power mode:%s[0x%x] peer_info:%s",
            power_mode_status_text(mode).c_str(), mode,
            device_info_text(p_peer_dev->info).c_str());

  const controller_t* controller = controller_get_interface();
  if (mode != BTM_PM_MD_SNIFF ||
@@ -760,6 +769,8 @@ static void bta_dm_pm_ssr(const RawAddress& peer_addr, int ssr) {
  int ssr_index = ssr;
  tBTA_DM_SSR_SPEC* p_spec = &p_bta_dm_ssr_spec[ssr_index];

  LOG_DEBUG("Request to put link to device:%s into power_mode:%s",
            PRIVATE_ADDRESS(peer_addr), p_spec->name);
  /* go through the connected services */
  for (int i = 0; i < bta_dm_conn_srvcs.count; i++) {
    const tBTA_DM_SRVCS& service = bta_dm_conn_srvcs.conn_srvc[i];
@@ -773,9 +784,10 @@ static void bta_dm_pm_ssr(const RawAddress& peer_addr, int ssr) {
      current_ssr_index = p_bta_dm_pm_spec[config.spec_idx].ssr;
      if ((config.id == service.id) && ((config.app_id == BTA_ALL_APP_ID) ||
                                        (config.app_id == service.app_id))) {
        LOG_INFO("Found connected service:%s app_id:%d peer:%s",
        LOG_INFO("Found connected service:%s app_id:%d peer:%s spec_name:%s",
                 BtaIdSysText(service.id).c_str(), service.app_id,
                 PRIVATE_ADDRESS(peer_addr));
                 PRIVATE_ADDRESS(peer_addr),
                 p_bta_dm_ssr_spec[current_ssr_index].name);
        break;
      }
    }
@@ -793,16 +805,17 @@ static void bta_dm_pm_ssr(const RawAddress& peer_addr, int ssr) {
#endif
    if (p_spec_cur->max_lat < p_spec->max_lat ||
        (ssr_index == BTA_DM_PM_SSR0 && current_ssr_index != BTA_DM_PM_SSR0)) {
      LOG_DEBUG(
          "Changing sniff subrating specification for %s from %s[%d] ==> "
          "%s[%d]",
          PRIVATE_ADDRESS(peer_addr), p_spec->name, ssr_index, p_spec_cur->name,
          current_ssr_index);
      ssr_index = current_ssr_index;
      p_spec = &p_bta_dm_ssr_spec[ssr_index];
    }
  }

  if (p_spec->max_lat) {
    LOG_DEBUG(
        "Max latency is non zero max_lat:0x%04x min_loc_to:0x%04x "
        "min_rmt_to:0x%04x",
        p_spec->max_lat, p_spec->min_loc_to, p_spec->min_rmt_to);
    /* Avoid SSR reset on device which has SCO connected */
    if (bta_dm_pm_is_sco_active()) {
      int idx = bta_dm_get_sco_index();
@@ -815,37 +828,50 @@ static void bta_dm_pm_ssr(const RawAddress& peer_addr, int ssr) {
    }

    LOG_DEBUG(
        "Setting sniff subrating for device:%s max_lat:0x%04x "
        "min_loc_to:0x%04x min_rmt_to:0x%04x",
        PRIVATE_ADDRESS(peer_addr), p_spec->max_lat, p_spec->min_loc_to,
        p_spec->min_rmt_to);

        "Setting sniff subrating for device:%s spec_name:%s max_latency(s):%.2f"
        " min_local_timeout(s):%.2f min_remote_timeout(s):%.2f",
        PRIVATE_ADDRESS(peer_addr), p_spec->name,
        ticks_to_seconds(p_spec->max_lat), ticks_to_seconds(p_spec->min_loc_to),
        ticks_to_seconds(p_spec->min_rmt_to));
    /* set the SSR parameters. */
    BTM_SetSsrParams(peer_addr, p_spec->max_lat, p_spec->min_rmt_to,
                     p_spec->min_loc_to);
  }
}

/*******************************************************************************
 *
 * Function         bta_dm_pm_active
 *
 * Description      Brings connection to active mode
 *
 *
 * Returns          void
 *
 ******************************************************************************/
void bta_dm_pm_active(const RawAddress& peer_addr) {
  tBTM_PM_PWR_MD pm;

  memset((void*)&pm, 0, sizeof(pm));
  tBTM_PM_PWR_MD pm{
      .mode = BTM_PM_MD_ACTIVE,
  };

  /* switch to active mode */
  pm.mode = BTM_PM_MD_ACTIVE;
  tBTM_STATUS status = BTM_SetPowerMode(bta_dm_cb.pm_id, peer_addr, &pm);
  if (status != BTM_CMD_STORED && status != BTM_CMD_STARTED) {
    LOG_WARN("Unable to set active mode for device:%s",
  switch (status) {
    case BTM_CMD_STORED:
      LOG_DEBUG("Active power mode stored for execution later for remote:%s",
                PRIVATE_ADDRESS(peer_addr));
      break;
    case BTM_CMD_STARTED:
      LOG_DEBUG("Active power mode started for remote:%s",
                PRIVATE_ADDRESS(peer_addr));
      break;
    case BTM_SUCCESS:
      LOG_INFO("Active power mode already set for device:%s",
               PRIVATE_ADDRESS(peer_addr));
      break;
    default:
      LOG_WARN("Unable to set active power mode for device:%s status:%s",
               PRIVATE_ADDRESS(peer_addr), btm_status_text(status).c_str());
      break;
  }
}

Loading