vibrator: Dynamically support different HW stage device

Since EVT and DVT devices were applied different target G values,
we have to add a workaround to support this condition.

Bug: 157610908
Bug: 157714236
Bug: 154788092
Test: manual check logs
Signed-off-by: chasewu <chasewu@google.com>
Change-Id: I5d534d44a6f765250f16a13cc7bb9ccecc120f99
This commit is contained in:
chasewu
2020-06-03 14:21:47 +08:00
committed by Cyan_Hsieh
parent a42dffa999
commit 9f4c9b3752
4 changed files with 22 additions and 2 deletions

View File

@@ -194,6 +194,10 @@ class HwCal : public Vibrator::HwCal, private HwCalBase {
bool getTriggerEffectSupport(uint32_t *value) override {
return getProperty("lptrigger", value, DEFAULT_LP_TRIGGER_SUPPORT);
}
bool getDevHwVer(std::string *value) override {
*value = ::android::base::GetProperty("ro.revision", "DVT");
return true;
}
void debug(int fd) override { HwCalBase::debug(fd); }
};

View File

@@ -59,8 +59,8 @@ static constexpr char WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ[] = "3 0";
static constexpr char WAVEFORM_HEAVY_CLICK_EFFECT_SEQ[] = "4 0";
// UT team design those target G values
static std::array<float, 5> EFFECT_TARGET_G = {0.15, 0.27, 0.32, 0.48, 0.62};
static std::array<float, 3> STEADY_TARGET_G = {1.2, 1.145, 0.4};
static std::array<float, 5> EFFECT_TARGET_G = {0.275, 0.63, 0.68, 0.97, 1.12};
static std::array<float, 3> STEADY_TARGET_G = {1.9, 1.145, 0.73};
struct SensorContext {
ASensorEventQueue *queue;
@@ -311,11 +311,24 @@ Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal)
float tempVolLevel = 0.0f, tempAmpMax = 0.0f;
uint32_t longFreqencyShift = 0, shortVoltageMax = 0, longVoltageMax = 0,
shape = 0;
std::string devHwVersion;
mHwCal->getLongFrequencyShift(&longFreqencyShift);
mHwCal->getShortVoltageMax(&shortVoltageMax);
mHwCal->getLongVoltageMax(&longVoltageMax);
// TODO: This is a workaround for b/157610908
mHwCal->getDevHwVer(&devHwVersion);
if (devHwVersion.compare("EVT")) {
EFFECT_TARGET_G = {0.15, 0.27, 0.35, 0.54, 0.65};
STEADY_TARGET_G = {1.2, 1.145, 0.4};
ALOGW("Device HW version: %s, this is an EVT device",
devHwVersion.c_str());
} else {
ALOGW("Device HW version: %s, no need to change the target G values",
devHwVersion.c_str());
}
hasEffectCoeffs = mHwCal->getEffectCoeffs(&effectCoeffs);
hasExternalEffectG = mHwCal->getEffectTargetG(&externalEffectTargetG);
for (i = 0; i < 5; i++) {

View File

@@ -126,6 +126,8 @@ class Vibrator : public BnVibrator {
virtual bool getSteadyShape(uint32_t *value) = 0;
// Obtains the trigger effect support
virtual bool getTriggerEffectSupport(uint32_t *value) = 0;
// Obtains device hardware version
virtual bool getDevHwVer(std::string *value) = 0;
// Emit diagnostic information to the given file.
virtual void debug(int fd) = 0;
};

View File

@@ -61,6 +61,7 @@ class MockCal : public ::aidl::android::hardware::vibrator::Vibrator::HwCal {
MOCK_METHOD1(getEffectShape, bool(uint32_t *value));
MOCK_METHOD1(getSteadyShape, bool(uint32_t *value));
MOCK_METHOD1(getTriggerEffectSupport, bool(uint32_t *value));
MOCK_METHOD1(getDevHwVer, bool(std::string &value));
MOCK_METHOD1(debug, void(int fd));
~MockCal() override { destructor(); };