Merge "vibrator: handle aidl HAL dying" am: e29882bdfa
am: d6ae1794f1
Change-Id: Ib0973a525b78af7ec13d684923b82c6b95979fc9
This commit is contained in:
@@ -154,21 +154,29 @@ class VibratorShim : public V1_4::IVibrator {
|
||||
|
||||
sp<aidl::IVibratorCallback> cb = callback ? new CallbackShim(callback) : nullptr;
|
||||
int timeoutMs = 0;
|
||||
V1_0::Status status = toHidlStatus(
|
||||
Return<V1_0::Status> status = toHidlStatus(
|
||||
mVib->perform(static_cast<aidl::Effect>(effect),
|
||||
static_cast<aidl::EffectStrength>(strength), cb, &timeoutMs));
|
||||
_hidl_cb(status, timeoutMs);
|
||||
return android::hardware::Status::ok();
|
||||
|
||||
if (status.isOk()) {
|
||||
_hidl_cb(status, timeoutMs);
|
||||
return android::hardware::Status::ok();
|
||||
} else {
|
||||
return android::hardware::details::StatusOf<V1_0::Status, void>(status);
|
||||
}
|
||||
}
|
||||
private:
|
||||
sp<aidl::IVibrator> mVib;
|
||||
|
||||
V1_0::Status toHidlStatus(const android::binder::Status& status) {
|
||||
Return<V1_0::Status> toHidlStatus(const android::binder::Status& status) {
|
||||
switch(status.exceptionCode()) {
|
||||
using android::hardware::Status;
|
||||
case Status::EX_NONE: return V1_0::Status::OK;
|
||||
case Status::EX_ILLEGAL_ARGUMENT: return V1_0::Status::BAD_VALUE;
|
||||
case Status::EX_UNSUPPORTED_OPERATION: return V1_0::Status::UNSUPPORTED_OPERATION;
|
||||
case Status::EX_TRANSACTION_FAILED: {
|
||||
return Status::fromStatusT(status.transactionError());
|
||||
}
|
||||
}
|
||||
return V1_0::Status::UNKNOWN_ERROR;
|
||||
}
|
||||
@@ -247,8 +255,14 @@ class HalWrapper {
|
||||
}
|
||||
|
||||
ALOGE("Failed to issue command to vibrator HAL. Retrying.");
|
||||
|
||||
// Restoring connection to the HAL.
|
||||
mHal = I::tryGetService();
|
||||
sp<aidl::IVibrator> aidlVib = checkVintfService<aidl::IVibrator>();
|
||||
if (aidlVib) {
|
||||
mHal = new VibratorShim(aidlVib);
|
||||
} else {
|
||||
mHal = I::tryGetService();
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user