Merge "Fix bluetooth AIDL restart fail when open HCI Fail" am: 0e55fec5c3 am: 288283d9c5

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2643490

Change-Id: I2078167e167101fbf5f0c68d5669bcfd4caf1bf8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/bluetooth/aidl/default/BluetoothHci.cpp b/bluetooth/aidl/default/BluetoothHci.cpp
index 18a371d..782122f 100644
--- a/bluetooth/aidl/default/BluetoothHci.cpp
+++ b/bluetooth/aidl/default/BluetoothHci.cpp
@@ -224,6 +224,7 @@
     ALOGI("Unable to open Linux interface, trying default path.");
     mFd = getFdFromDevPath();
     if (mFd < 0) {
+      mState = HalState::READY;
       cb->initializationComplete(Status::UNABLE_TO_OPEN_INTERFACE);
       return ndk::ScopedAStatus::ok();
     }
@@ -281,6 +282,7 @@
   {
     std::lock_guard<std::mutex> guard(mStateMutex);
     if (mState != HalState::ONE_CLIENT) {
+      ASSERT(mState != HalState::INITIALIZING);
       ALOGI("Already closed");
       return ndk::ScopedAStatus::ok();
     }