device/vibrator: Add contextual haptics feature

Add capability for vibrator HAL to detect whether the device is face-up
and adjust/scale haptic alerts to avoid loud and startling buzzing when
there is no case on the device. Added global compile-time disable that
can be set in the environment.

Bug: 198239103
Test: Verified tests and functionality
Change-Id: I6b2355acb7fa5e0323b8eca6327bb19ac42a2c56
Signed-off-by: Chris Paulo <chrispaulo@google.com>
This commit is contained in:
Chris Paulo
2022-11-02 22:21:50 +00:00
committed by TreeHugger Robot
parent 24789fe332
commit 0db068b63c
18 changed files with 730 additions and 56 deletions

View File

@@ -284,6 +284,11 @@ class VibratorTest : public Test {
EXPECT_CALL(*mMockApi, setFFEffect(_, _, _)).Times(times);
EXPECT_CALL(*mMockApi, setFFPlay(_, _, _)).Times(times);
EXPECT_CALL(*mMockApi, setMinOnOffInterval(_)).Times(times);
EXPECT_CALL(*mMockApi, getContextScale()).Times(times);
EXPECT_CALL(*mMockApi, getContextEnable()).Times(times);
EXPECT_CALL(*mMockApi, getContextSettlingTime()).Times(times);
EXPECT_CALL(*mMockApi, getContextCooldownTime()).Times(times);
EXPECT_CALL(*mMockApi, getContextFadeEnable()).Times(times);
EXPECT_CALL(*mMockApi, getHapticAlsaDevice(_, _)).Times(times);
EXPECT_CALL(*mMockApi, setHapticPcmAmp(_, _, _, _)).Times(times);
@@ -363,6 +368,11 @@ TEST_F(VibratorTest, Constructor) {
.WillOnce(DoAll(SetArgPointee<0>(supportedPrimitivesBits), Return(true)));
EXPECT_CALL(*mMockApi, setMinOnOffInterval(MIN_ON_OFF_INTERVAL_US)).WillOnce(Return(true));
EXPECT_CALL(*mMockApi, getContextScale()).WillOnce(Return(0));
EXPECT_CALL(*mMockApi, getContextEnable()).WillOnce(Return(false));
EXPECT_CALL(*mMockApi, getContextSettlingTime()).WillOnce(Return(0));
EXPECT_CALL(*mMockApi, getContextCooldownTime()).WillOnce(Return(0));
EXPECT_CALL(*mMockApi, getContextFadeEnable()).WillOnce(Return(false));
createVibrator(std::move(mockapi), std::move(mockcal), false);
}