OSDN Git Service

Send OnModeChange non success event to shim
authorHansong Zhang <hsz@google.com>
Fri, 29 Jan 2021 01:11:09 +0000 (17:11 -0800)
committerHansong Zhang <hsz@google.com>
Mon, 1 Feb 2021 02:19:01 +0000 (02:19 +0000)
Otherwise SCO_Remove could be blocked.

Tag: #gd-refactor
Bug: 141555841
Bug: 178172118
Test: cert/run
Change-Id: I59abd9035f27367929aabbbba65d4db9b59e819d

gd/hci/acl_manager/classic_acl_connection.cc
gd/hci/acl_manager/classic_impl.h
gd/hci/acl_manager/connection_management_callbacks.h
gd/hci/acl_manager_test.cc
gd/hci/facade/acl_manager_facade.cc
gd/l2cap/classic/internal/link.cc
gd/l2cap/classic/internal/link.h
main/shim/acl.cc

index 46ff34b..a8f46aa 100644 (file)
@@ -64,8 +64,8 @@ class AclConnectionTracker : public ConnectionManagementCallbacks {
   void OnReadClockOffsetComplete(uint16_t clock_offset) override {
     SAVE_OR_CALL(OnReadClockOffsetComplete, clock_offset)
   }
-  void OnModeChange(Mode current_mode, uint16_t interval) override {
-    SAVE_OR_CALL(OnModeChange, current_mode, interval)
+  void OnModeChange(ErrorCode status, Mode current_mode, uint16_t interval) override {
+    SAVE_OR_CALL(OnModeChange, status, current_mode, interval)
   }
   void OnSniffSubrating(
       uint16_t maximum_transmit_latency,
index 8a36e75..e411607 100644 (file)
@@ -413,7 +413,6 @@ struct classic_impl : public security::ISecurityManagerListener {
     if (status != ErrorCode::SUCCESS) {
       std::string error_code = ErrorCodeText(status);
       LOG_ERROR("Received on_mode_change on handle 0x0%04hx with error code %s", handle, error_code.c_str());
-      return;
     }
     auto callbacks = get_callbacks(handle);
     if (callbacks == nullptr) {
@@ -423,7 +422,7 @@ struct classic_impl : public security::ISecurityManagerListener {
     }
     Mode current_mode = mode_change_view.GetCurrentMode();
     uint16_t interval = mode_change_view.GetInterval();
-    callbacks->OnModeChange(current_mode, interval);
+    callbacks->OnModeChange(status, current_mode, interval);
   }
 
   void on_sniff_subrating(EventView packet) {
index 1886592..56a6842 100644 (file)
@@ -38,7 +38,7 @@ class ConnectionManagementCallbacks {
   // Invoked when controller sends Read Clock Offset Complete event with Success error code
   virtual void OnReadClockOffsetComplete(uint16_t clock_offset) = 0;
   // Invoked when controller sends Mode Change event with Success error code
-  virtual void OnModeChange(Mode current_mode, uint16_t interval) = 0;
+  virtual void OnModeChange(ErrorCode status, Mode current_mode, uint16_t interval) = 0;
   // Invoked when controller sends Sniff Subrating event with Success error code
   virtual void OnSniffSubrating(
       uint16_t maximum_transmit_latency,
index 1159192..cd81ac1 100644 (file)
@@ -483,7 +483,7 @@ class AclManagerWithConnectionTest : public AclManagerTest {
     MOCK_METHOD1(OnEncryptionChange, void(EncryptionEnabled enabled));
     MOCK_METHOD0(OnChangeConnectionLinkKeyComplete, void());
     MOCK_METHOD1(OnReadClockOffsetComplete, void(uint16_t clock_offse));
-    MOCK_METHOD2(OnModeChange, void(Mode current_mode, uint16_t interval));
+    MOCK_METHOD3(OnModeChange, void(ErrorCode status, Mode current_mode, uint16_t interval));
     MOCK_METHOD4(
         OnSniffSubrating,
         void(
@@ -949,7 +949,7 @@ TEST_F(AclManagerWithConnectionTest, send_hold_mode) {
   ASSERT_EQ(command_view.GetHoldModeMaxInterval(), 0x0500);
   ASSERT_EQ(command_view.GetHoldModeMinInterval(), 0x0020);
 
-  EXPECT_CALL(mock_connection_management_callbacks_, OnModeChange(Mode::HOLD, 0x0020));
+  EXPECT_CALL(mock_connection_management_callbacks_, OnModeChange(ErrorCode::SUCCESS, Mode::HOLD, 0x0020));
   test_hci_layer_->IncomingEvent(ModeChangeBuilder::Create(ErrorCode::SUCCESS, handle_, Mode::HOLD, 0x0020));
 }
 
@@ -964,7 +964,7 @@ TEST_F(AclManagerWithConnectionTest, send_sniff_mode) {
   ASSERT_EQ(command_view.GetSniffAttempt(), 0x0040);
   ASSERT_EQ(command_view.GetSniffTimeout(), 0x0014);
 
-  EXPECT_CALL(mock_connection_management_callbacks_, OnModeChange(Mode::SNIFF, 0x0028));
+  EXPECT_CALL(mock_connection_management_callbacks_, OnModeChange(ErrorCode::SUCCESS, Mode::SNIFF, 0x0028));
   test_hci_layer_->IncomingEvent(ModeChangeBuilder::Create(ErrorCode::SUCCESS, handle_, Mode::SNIFF, 0x0028));
 }
 
@@ -975,7 +975,7 @@ TEST_F(AclManagerWithConnectionTest, send_exit_sniff_mode) {
   auto command_view = ExitSniffModeView::Create(packet);
   ASSERT_TRUE(command_view.IsValid());
 
-  EXPECT_CALL(mock_connection_management_callbacks_, OnModeChange(Mode::ACTIVE, 0x00));
+  EXPECT_CALL(mock_connection_management_callbacks_, OnModeChange(ErrorCode::SUCCESS, Mode::ACTIVE, 0x00));
   test_hci_layer_->IncomingEvent(ModeChangeBuilder::Create(ErrorCode::SUCCESS, handle_, Mode::ACTIVE, 0x00));
 }
 
index 843aac8..a9aaa9f 100644 (file)
@@ -411,7 +411,7 @@ class AclManagerFacadeService : public AclManagerFacade::Service, public Connect
       LOG_INFO("OnReadClockOffsetComplete clock_offset:%d", clock_offset);
     };
 
-    void OnModeChange(Mode current_mode, uint16_t interval) override {
+    void OnModeChange(ErrorCode status, Mode current_mode, uint16_t interval) override {
       LOG_INFO("OnModeChange Mode:%d, interval:%d", (uint8_t)current_mode, interval);
     };
 
index c3f0f78..ea2619a 100644 (file)
@@ -340,7 +340,7 @@ void Link::OnReadClockOffsetComplete(uint16_t clock_offset) {
   link_manager_->OnReadClockOffset(GetDevice().GetAddress(), clock_offset);
 }
 
-void Link::OnModeChange(hci::Mode current_mode, uint16_t interval) {
+void Link::OnModeChange(hci::ErrorCode status, hci::Mode current_mode, uint16_t interval) {
   link_manager_->OnModeChange(GetDevice().GetAddress(), current_mode, interval);
 }
 
index c8c9514..af69bb0 100644 (file)
@@ -155,7 +155,7 @@ class Link : public l2cap::internal::ILink, public hci::acl_manager::ConnectionM
   void OnEncryptionChange(hci::EncryptionEnabled enabled) override;
   void OnChangeConnectionLinkKeyComplete() override;
   void OnReadClockOffsetComplete(uint16_t clock_offset) override;
-  void OnModeChange(hci::Mode current_mode, uint16_t interval) override;
+  void OnModeChange(hci::ErrorCode status, hci::Mode current_mode, uint16_t interval) override;
   void OnSniffSubrating(
       uint16_t maximum_transmit_latency,
       uint16_t maximum_receive_latency,
index 034e26d..c77786a 100644 (file)
@@ -345,10 +345,10 @@ class ClassicShimAclConnection
     LOG_INFO("UNIMPLEMENTED");
   }
 
-  void OnModeChange(hci::Mode current_mode, uint16_t interval) override {
-    TRY_POSTING_ON_MAIN(interface_.on_mode_change,
-                        ToLegacyHciErrorCode(hci::ErrorCode::SUCCESS), handle_,
-                        ToLegacyHciMode(current_mode), interval);
+  void OnModeChange(hci::ErrorCode status, hci::Mode current_mode,
+                    uint16_t interval) override {
+    TRY_POSTING_ON_MAIN(interface_.on_mode_change, ToLegacyHciErrorCode(status),
+                        handle_, ToLegacyHciMode(current_mode), interval);
   }
 
   void OnSniffSubrating(uint16_t maximum_transmit_latency,