Merge "vibrator: handle aidl HAL dying"
This commit is contained in:
@@ -154,21 +154,29 @@ class VibratorShim : public V1_4::IVibrator {
|
|||||||
|
|
||||||
sp<aidl::IVibratorCallback> cb = callback ? new CallbackShim(callback) : nullptr;
|
sp<aidl::IVibratorCallback> cb = callback ? new CallbackShim(callback) : nullptr;
|
||||||
int timeoutMs = 0;
|
int timeoutMs = 0;
|
||||||
V1_0::Status status = toHidlStatus(
|
Return<V1_0::Status> status = toHidlStatus(
|
||||||
mVib->perform(static_cast<aidl::Effect>(effect),
|
mVib->perform(static_cast<aidl::Effect>(effect),
|
||||||
static_cast<aidl::EffectStrength>(strength), cb, &timeoutMs));
|
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:
|
private:
|
||||||
sp<aidl::IVibrator> mVib;
|
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()) {
|
switch(status.exceptionCode()) {
|
||||||
using android::hardware::Status;
|
using android::hardware::Status;
|
||||||
case Status::EX_NONE: return V1_0::Status::OK;
|
case Status::EX_NONE: return V1_0::Status::OK;
|
||||||
case Status::EX_ILLEGAL_ARGUMENT: return V1_0::Status::BAD_VALUE;
|
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_UNSUPPORTED_OPERATION: return V1_0::Status::UNSUPPORTED_OPERATION;
|
||||||
|
case Status::EX_TRANSACTION_FAILED: {
|
||||||
|
return Status::fromStatusT(status.transactionError());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return V1_0::Status::UNKNOWN_ERROR;
|
return V1_0::Status::UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
@@ -247,8 +255,14 @@ class HalWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ALOGE("Failed to issue command to vibrator HAL. Retrying.");
|
ALOGE("Failed to issue command to vibrator HAL. Retrying.");
|
||||||
|
|
||||||
// Restoring connection to the HAL.
|
// 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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user