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

Commit a8e4ef57 authored by Myles Watson's avatar Myles Watson
Browse files

Sleep before crashing when the HIDL HAL dies

The HAL crashing is an unrecoverable failure. Sometimes, the system
kills the HAL as part of a system shutdown, in which case Bluetooth
will also be killed. Sleeping for one second after being notified that
the HAL died is a way to make sure we don't report deaths that are a
result of the system killing the HAL out from under the Bluetooth
stack.

Bug: 294022818
Test: mma -j32
Test: Kill the hal, then Bluetooth with different timings
Change-Id: I9c17f4637639852965fdb529687a43ab26fde776
parent 43752429
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -61,9 +61,11 @@ namespace {
class HciDeathRecipient : public ::android::hardware::hidl_death_recipient {
class HciDeathRecipient : public ::android::hardware::hidl_death_recipient {
 public:
 public:
  virtual void serviceDied(uint64_t /*cookie*/, const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
  virtual void serviceDied(uint64_t /*cookie*/, const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
    LOG_ERROR("Bluetooth HAL service died. Calling exit(0);");
    LOG_ERROR("The Bluetooth HAL service died. Dumping logs and crashing in 1 second.");
    common::StopWatch::DumpStopWatchLog();
    common::StopWatch::DumpStopWatchLog();
    exit(0);
    // At shutdown, sometimes the HAL service gets killed before Bluetooth.
    std::this_thread::sleep_for(std::chrono::seconds(1));
    LOG_ALWAYS_FATAL("The Bluetooth HAL died.");
  }
  }
};
};