From 856f2d1302b0bc7b3b3006cdbb0006489d2e0a38 Mon Sep 17 00:00:00 2001
From: Myles Watson <mylesgw@google.com>
Date: Mon, 12 Sep 2016 14:39:58 -0700
Subject: [PATCH] Remove LPM code from the stack

Power management is handled in hardware/interfaces/bluetooth/.

Test: mma -j32
Change-Id: Ie172ca37059768a2cfa0d4b84f34b54624b1fa49
---
 system/btif/include/btif_common.h |  3 ---
 system/btif/src/btif_core.cc      |  7 ------
 system/hci/BUILD.gn               |  1 -
 system/include/bt_target.h        | 10 --------
 system/main/bte_main.cc           | 41 -------------------------------
 system/stack/btu/btu_hcif.cc      |  8 ------
 system/stack/btu/btu_task.cc      | 30 ----------------------
 system/stack/include/btu.h        |  8 ------
 system/stack/include/hcimsgs.h    |  1 -
 system/stack/l2cap/l2c_link.cc    |  5 ----
 10 files changed, 114 deletions(-)

diff --git a/system/btif/include/btif_common.h b/system/btif/include/btif_common.h
index 0fbcfb018f3..59b3e90dd93 100644
--- a/system/btif/include/btif_common.h
+++ b/system/btif/include/btif_common.h
@@ -221,9 +221,6 @@ void bte_main_boot_entry(void);
 void bte_main_enable(void);
 void bte_main_disable(void);
 void bte_main_cleanup(void);
-#if (HCILP_INCLUDED == TRUE)
-void bte_main_enable_lpm(bool enable);
-#endif
 void bte_main_postload_cfg(void);
 
 bt_status_t btif_transfer_context(tBTIF_CBACK* p_cback, uint16_t event,
diff --git a/system/btif/src/btif_core.cc b/system/btif/src/btif_core.cc
index 2b04c3e5e50..b967ba209dc 100644
--- a/system/btif/src/btif_core.cc
+++ b/system/btif/src/btif_core.cc
@@ -408,9 +408,6 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status) {
   }
 
   bte_main_postload_cfg();
-#if (HCILP_INCLUDED == TRUE)
-  bte_main_enable_lpm(true);
-#endif
 
   /* callback to HAL */
   if (status == BTA_SUCCESS) {
@@ -484,10 +481,6 @@ bt_status_t btif_disable_bluetooth(void) {
 void btif_disable_bluetooth_evt(void) {
   BTIF_TRACE_DEBUG("%s", __func__);
 
-#if (HCILP_INCLUDED == TRUE)
-  bte_main_enable_lpm(false);
-#endif
-
   bte_main_disable();
 
   /* callback to HAL */
diff --git a/system/hci/BUILD.gn b/system/hci/BUILD.gn
index 5ce5834d06a..3a0fe782e2d 100644
--- a/system/hci/BUILD.gn
+++ b/system/hci/BUILD.gn
@@ -28,7 +28,6 @@ static_library("hci") {
     "src/hci_layer.cc",
     "src/hci_packet_factory.cc",
     "src/hci_packet_parser.cc",
-    "src/low_power_manager.cc",
     "src/packet_fragmenter.cc",
     "src/vendor.cc",
   ]
diff --git a/system/include/bt_target.h b/system/include/bt_target.h
index eef12f67314..71d29ae366b 100644
--- a/system/include/bt_target.h
+++ b/system/include/bt_target.h
@@ -1457,16 +1457,6 @@ single PDU.
 #define MCA_FCR_OPT_MPS_SIZE 1000
 #endif
 
-/******************************************************************************
- *
- * Sleep Mode (Low Power Mode)
- *
- *****************************************************************************/
-
-#ifndef HCILP_INCLUDED
-#define HCILP_INCLUDED TRUE
-#endif
-
 /******************************************************************************
  *
  * BTA
diff --git a/system/main/bte_main.cc b/system/main/bte_main.cc
index 99dfeda29f3..35ded9d1e73 100644
--- a/system/main/bte_main.cc
+++ b/system/main/bte_main.cc
@@ -188,47 +188,6 @@ void bte_main_postload_cfg(void) {
   // TODO(eisenbach): [HIDL] DEPRECATE?
 }
 
-#if (HCILP_INCLUDED == TRUE)
-/******************************************************************************
- *
- * Function         bte_main_enable_lpm
- *
- * Description      BTE MAIN API - Enable/Disable low power mode operation
- *
- * Returns          None
- *
- *****************************************************************************/
-void bte_main_enable_lpm(bool enable) {
-  // TODO(eisenbach): [HIDL] DEPRECATE?
-}
-
-/******************************************************************************
- *
- * Function         bte_main_lpm_allow_bt_device_sleep
- *
- * Description      BTE MAIN API - Allow the BT controller to go to sleep
- *
- * Returns          None
- *
- *****************************************************************************/
-void bte_main_lpm_allow_bt_device_sleep() {
-  // TODO(eisenbach): [HIDL] DEPRECATE?
-}
-
-/******************************************************************************
- *
- * Function         bte_main_lpm_wake_bt_device
- *
- * Description      BTE MAIN API - Wake BT controller up if it is in sleep mode
- *
- * Returns          None
- *
- *****************************************************************************/
-void bte_main_lpm_wake_bt_device() {
-  // TODO(eisenbach): [HIDL] DEPRECATE?
-}
-#endif  // HCILP_INCLUDED
-
 /******************************************************************************
  *
  * Function         bte_main_hci_send
diff --git a/system/stack/btu/btu_hcif.cc b/system/stack/btu/btu_hcif.cc
index afffd1bbeb8..2db830db549 100644
--- a/system/stack/btu/btu_hcif.cc
+++ b/system/stack/btu/btu_hcif.cc
@@ -376,10 +376,6 @@ void btu_hcif_send_cmd(UNUSED_ATTR uint8_t controller_id, BT_HDR* p_buf) {
   hci_layer_get_interface()->transmit_command(
       p_buf, btu_hcif_command_complete_evt, btu_hcif_command_status_evt,
       vsc_callback);
-
-#if (HCILP_INCLUDED == TRUE)
-  btu_check_bt_sleep();
-#endif
 }
 
 using hci_cmd_cb = base::Callback<void(uint8_t* /* return_parameters */,
@@ -505,10 +501,6 @@ void btu_hcif_send_cmd_with_cb(const tracked_objects::Location& posted_from,
   hci_layer_get_interface()->transmit_command(
       p, btu_hcif_command_complete_evt_with_cb,
       btu_hcif_command_status_evt_with_cb, (void*)cb_wrapper);
-
-#if (HCILP_INCLUDED == TRUE)
-  btu_check_bt_sleep();
-#endif
 }
 
 /*******************************************************************************
diff --git a/system/stack/btu/btu_task.cc b/system/stack/btu/btu_task.cc
index acfbfcd622f..8152d3e39c1 100644
--- a/system/stack/btu/btu_task.cc
+++ b/system/stack/btu/btu_task.cc
@@ -112,11 +112,6 @@ static void btu_hci_msg_process(BT_HDR* p_msg) {
     case BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK:  // TODO(zachoverflow): remove
                                                   // this
       ((post_to_task_hack_t*)(&p_msg->data[0]))->callback(p_msg);
-#if (HCILP_INCLUDED == TRUE)
-      /* If the host receives events which it doesn't responsd to, */
-      /* it should start an idle timer to enter sleep mode.        */
-      btu_check_bt_sleep();
-#endif
       break;
     case BT_EVT_TO_BTU_HCI_ACL:
       /* All Acl Data goes to L2CAP */
@@ -137,12 +132,6 @@ static void btu_hci_msg_process(BT_HDR* p_msg) {
     case BT_EVT_TO_BTU_HCI_EVT:
       btu_hcif_process_event((uint8_t)(p_msg->event & BT_SUB_EVT_MASK), p_msg);
       osi_free(p_msg);
-
-#if (HCILP_INCLUDED == TRUE)
-      /* If host receives events which it doesn't response to, */
-      /* host should start idle timer to enter sleep mode.     */
-      btu_check_bt_sleep();
-#endif
       break;
 
     case BT_EVT_TO_BTU_HCI_CMD:
@@ -205,22 +194,3 @@ void btu_task_shut_down(UNUSED_ATTR void* context) {
   bta_sys_free();
   btu_free_core();
 }
-
-#if (HCILP_INCLUDED == TRUE)
-/*******************************************************************************
- *
- * Function         btu_check_bt_sleep
- *
- * Description      This function is called to check if controller can go to
- *                  sleep.
- *
- * Returns          void
- *
- ******************************************************************************/
-void btu_check_bt_sleep(void) {
-  // TODO(zachoverflow) take pending commands into account?
-  if (l2cb.controller_xmit_window == l2cb.num_lm_acl_bufs) {
-    bte_main_lpm_allow_bt_device_sleep();
-  }
-}
-#endif
diff --git a/system/stack/include/btu.h b/system/stack/include/btu.h
index d545a30a86f..aef87813856 100644
--- a/system/stack/include/btu.h
+++ b/system/stack/include/btu.h
@@ -56,14 +56,6 @@ extern uint8_t btu_trace_level;
 
 extern const BD_ADDR BT_BD_ANY;
 
-/* Functions provided by btu_task.cc
- ***********************************
-*/
-
-#if (HCILP_INCLUDED == TRUE)
-extern void btu_check_bt_sleep(void);
-#endif
-
 /* Functions provided by btu_hcif.cc
  ***********************************
 */
diff --git a/system/stack/include/hcimsgs.h b/system/stack/include/hcimsgs.h
index 766c9781375..6c75d3a3137 100644
--- a/system/stack/include/hcimsgs.h
+++ b/system/stack/include/hcimsgs.h
@@ -24,7 +24,6 @@
 #include "hcidefs.h"
 
 void bte_main_hci_send(BT_HDR* p_msg, uint16_t event);
-void bte_main_lpm_allow_bt_device_sleep(void);
 
 /* Message by message.... */
 
diff --git a/system/stack/l2cap/l2c_link.cc b/system/stack/l2cap/l2c_link.cc
index 1ebc6f9d13b..7110cff26af 100644
--- a/system/stack/l2cap/l2c_link.cc
+++ b/system/stack/l2cap/l2c_link.cc
@@ -1286,11 +1286,6 @@ void l2c_link_process_num_completed_pkts(uint8_t* p) {
     }
 #endif
   }
-
-#if (HCILP_INCLUDED == TRUE)
-  /* only full stack can enable sleep mode */
-  btu_check_bt_sleep();
-#endif
 }
 
 /*******************************************************************************
-- 
GitLab