Fix bluetooth AIDL restart fail when open HCI Fail

[Description]
If aidl open HCI fail at the first time, the aidl state
can not change to enable for the next time to initialize.

[Root Cause]
Bluetooth AIDL State is always equal to INITIALIZING after
open hci fail at the first time.

[Solution]
When open HCI fail at the first time, initialize the mstate to ready

Bug: 285517442
Test: pass
(cherry picked from https://android-review.googlesource.com/q/commit:6ebe25132221a389a3df8b0b197a9efff7a211f2)
Merged-In: I19756d6602ba931242d0f95942db55c505a210bb
Change-Id: I19756d6602ba931242d0f95942db55c505a210bb
This commit is contained in:
yanggang.yang
2023-05-31 13:59:04 +08:00
committed by Cherrypicker Worker
parent ad6f2cf6f9
commit d1cb6df2b6

View File

@@ -221,6 +221,7 @@ ndk::ScopedAStatus BluetoothHci::initialize(
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();
}
@@ -278,6 +279,7 @@ ndk::ScopedAStatus BluetoothHci::close() {
{
std::lock_guard<std::mutex> guard(mStateMutex);
if (mState != HalState::ONE_CLIENT) {
ASSERT(mState != HalState::INITIALIZING);
ALOGI("Already closed");
return ndk::ScopedAStatus::ok();
}