audio: Change mDeathHandler from a member into a local variable am: 17b3201259
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2819040 Change-Id: Ief673d71a1e9202af7d3c387b1a7a2a054f7e626 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
6fcb2f8d81
1 changed files with 19 additions and 14 deletions
|
@ -42,20 +42,9 @@ class AudioHalBinderServiceUtil {
|
|||
|
||||
ndk::SpAIBinder restartService(
|
||||
std::chrono::milliseconds timeoutMs = std::chrono::milliseconds(3000)) {
|
||||
mDeathHandler.reset(new AidlDeathRecipient(mBinder));
|
||||
if (STATUS_OK != mDeathHandler->linkToDeath()) {
|
||||
LOG(ERROR) << "linkToDeath failed";
|
||||
return nullptr;
|
||||
if (!stopService(timeoutMs)) {
|
||||
return {};
|
||||
}
|
||||
if (!android::base::SetProperty("sys.audio.restart.hal", "1")) {
|
||||
LOG(ERROR) << "SetProperty failed";
|
||||
return nullptr;
|
||||
}
|
||||
if (!mDeathHandler->waitForFired(timeoutMs)) {
|
||||
LOG(ERROR) << "Timeout wait for death";
|
||||
return nullptr;
|
||||
}
|
||||
mDeathHandler.reset();
|
||||
return connectToService(mServiceName);
|
||||
}
|
||||
|
||||
|
@ -93,7 +82,23 @@ class AudioHalBinderServiceUtil {
|
|||
}
|
||||
};
|
||||
|
||||
bool stopService(std::chrono::milliseconds timeoutMs) {
|
||||
AidlDeathRecipient deathHandler(mBinder);
|
||||
if (STATUS_OK != deathHandler.linkToDeath()) {
|
||||
LOG(ERROR) << "linkToDeath failed";
|
||||
return false;
|
||||
}
|
||||
if (!android::base::SetProperty("sys.audio.restart.hal", "1")) {
|
||||
LOG(ERROR) << "SetProperty failed";
|
||||
return false;
|
||||
}
|
||||
if (!deathHandler.waitForFired(timeoutMs)) {
|
||||
LOG(ERROR) << "Timeout wait for death";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string mServiceName;
|
||||
ndk::SpAIBinder mBinder;
|
||||
std::unique_ptr<AidlDeathRecipient> mDeathHandler;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue