Loading vibrator/aidl/android/hardware/vibrator/ActivePwle.aidl +26 −2 Original line number Diff line number Diff line Loading @@ -22,26 +22,50 @@ parcelable ActivePwle { * Amplitude ranging from 0.0 (inclusive) to 1.0 (inclusive) * in units of output acceleration amplitude, not voltage amplitude. * * Values should fall within the range of 0.0 (inclusive) to the maximum defined * by the corresponding entries in IVibrator#getBandwidthAmplitudeMap (inclusive). * If startFrequency falls between two entries, the value will not exceed the * largest amplitude of the two bounding frequencies. * * 0.0 represents no output acceleration amplitude * 1.0 represents maximum output acceleration amplitude at resonant frequency * 1.0 represents maximum output acceleration amplitude * across all supported frequencies */ float startAmplitude; /** * Absolute frequency point in the units of hertz * * Values are within the continuous inclusive frequency range defined by * IVibrator#getBandwidthAmplitudeMap, and not limited by the * IVibrator#getFrequencyResolution. */ float startFrequency; /** * Amplitude ranging from 0.0 (inclusive) to 1.0 (inclusive) * in units of output acceleration amplitude, not voltage amplitude. * * Values should fall within the range of 0.0 (inclusive) to the maximum defined * by the corresponding entries in IVibrator#getBandwidthAmplitudeMap (inclusive). * If endFrequency falls between two entries, the value will not exceed the * largest amplitude of the two bounding frequencies. * * 0.0 represents no output acceleration amplitude * 1.0 represents maximum output acceleration amplitude at resonant frequency * 1.0 represents maximum output acceleration amplitude * across all supported frequencies */ float endAmplitude; /** * Absolute frequency point in the units of hertz * * Values are within the continuous inclusive frequency range defined by * IVibrator#getBandwidthAmplitudeMap, and not limited by the * IVibrator#getFrequencyResolution. */ float endFrequency; /** * Total duration from start point to end point in the units of milliseconds */ Loading vibrator/aidl/android/hardware/vibrator/IVibrator.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,10 @@ interface IVibrator { * of getFrequencyResolution(). The value returned by getResonantFrequency() must be * represented in the returned list. * * The amplitude values represent the maximum output acceleration amplitude supported for each * given frequency. Equal amplitude values for different frequencies represent equal output * accelerations. * * @return The maximum output acceleration amplitude for each supported frequency, * starting at getMinimumFrequency() */ Loading vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +32 −46 Original line number Diff line number Diff line Loading @@ -717,27 +717,33 @@ TEST_P(VibratorAidl, GetSupportedBraking) { TEST_P(VibratorAidl, ComposeValidPwle) { if (capabilities & IVibrator::CAP_COMPOSE_PWLE_EFFECTS) { ActivePwle active = composeValidActivePwle(vibrator, capabilities); ActivePwle firstActive = composeValidActivePwle(vibrator, capabilities); std::vector<Braking> supported; ASSERT_TRUE(vibrator->getSupportedBraking(&supported).isOk()); bool isClabSupported = std::find(supported.begin(), supported.end(), Braking::CLAB) != supported.end(); BrakingPwle braking; braking.braking = isClabSupported ? Braking::CLAB : Braking::NONE; braking.duration = 100; BrakingPwle firstBraking; firstBraking.braking = isClabSupported ? Braking::CLAB : Braking::NONE; firstBraking.duration = 100; std::vector<PrimitivePwle> pwleQueue; PrimitivePwle pwle; pwle = active; pwleQueue.emplace_back(std::move(pwle)); pwle = braking; pwleQueue.emplace_back(std::move(pwle)); pwle = active; pwleQueue.emplace_back(std::move(pwle)); ActivePwle secondActive = composeValidActivePwle(vibrator, capabilities); if (capabilities & IVibrator::CAP_FREQUENCY_CONTROL) { float minFrequencyHz = getFrequencyMinimumHz(vibrator, capabilities); float maxFrequencyHz = getFrequencyMaximumHz(vibrator, capabilities); float freqResolutionHz = getFrequencyResolutionHz(vibrator, capabilities); secondActive.startFrequency = minFrequencyHz + (freqResolutionHz / 2.0f); secondActive.endFrequency = maxFrequencyHz - (freqResolutionHz / 3.0f); } BrakingPwle secondBraking; secondBraking.braking = Braking::NONE; secondBraking.duration = 10; auto pwleQueue = std::vector<PrimitivePwle>{firstActive, firstBraking, secondActive, secondBraking}; EXPECT_EQ(Status::EX_NONE, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading Loading @@ -765,14 +771,7 @@ TEST_P(VibratorAidl, ComposeValidPwleWithCallback) { braking.braking = isClabSupported ? Braking::CLAB : Braking::NONE; braking.duration = 100; std::vector<PrimitivePwle> pwleQueue; PrimitivePwle pwle; pwle = active; pwleQueue.emplace_back(std::move(pwle)); pwle = braking; pwleQueue.emplace_back(std::move(pwle)); pwle = active; pwleQueue.emplace_back(std::move(pwle)); auto pwleQueue = std::vector<PrimitivePwle>{active, braking, active}; EXPECT_TRUE(vibrator->composePwle(pwleQueue, callback).isOk()); EXPECT_EQ(completionFuture.wait_for(timeout), std::future_status::ready); Loading @@ -785,7 +784,7 @@ TEST_P(VibratorAidl, ComposePwleSegmentBoundary) { // test empty queue EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); ActivePwle active = composeValidActivePwle(vibrator, capabilities); Loading @@ -801,7 +800,7 @@ TEST_P(VibratorAidl, ComposePwleSegmentBoundary) { EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading @@ -811,25 +810,20 @@ TEST_P(VibratorAidl, ComposePwleAmplitudeParameterBoundary) { active.startAmplitude = getAmplitudeMax() + 1.0; // Amplitude greater than allowed active.endAmplitude = getAmplitudeMax() + 1.0; // Amplitude greater than allowed std::vector<PrimitivePwle> pwleQueueGreater; PrimitivePwle pwle; pwle = active; pwleQueueGreater.emplace_back(std::move(pwle)); auto pwleQueueGreater = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueGreater, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); active.startAmplitude = getAmplitudeMin() - 1.0; // Amplitude less than allowed active.endAmplitude = getAmplitudeMin() - 1.0; // Amplitude less than allowed std::vector<PrimitivePwle> pwleQueueLess; pwle = active; pwleQueueLess.emplace_back(std::move(pwle)); auto pwleQueueLess = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueLess, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading @@ -845,25 +839,20 @@ TEST_P(VibratorAidl, ComposePwleFrequencyParameterBoundary) { freqMaximumHz + freqResolutionHz; // Frequency greater than allowed active.endFrequency = freqMaximumHz + freqResolutionHz; // Frequency greater than allowed std::vector<PrimitivePwle> pwleQueueGreater; PrimitivePwle pwle; pwle = active; pwleQueueGreater.emplace_back(std::move(pwle)); auto pwleQueueGreater = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueGreater, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); active.startFrequency = freqMinimumHz - freqResolutionHz; // Frequency less than allowed active.endFrequency = freqMinimumHz - freqResolutionHz; // Frequency less than allowed std::vector<PrimitivePwle> pwleQueueLess; pwle = active; pwleQueueLess.emplace_back(std::move(pwle)); auto pwleQueueLess = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueLess, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading @@ -875,14 +864,11 @@ TEST_P(VibratorAidl, ComposePwleSegmentDurationBoundary) { vibrator->getPwlePrimitiveDurationMax(&segmentDurationMaxMs); active.duration = segmentDurationMaxMs + 10; // Segment duration greater than allowed std::vector<PrimitivePwle> pwleQueue; PrimitivePwle pwle; pwle = active; pwleQueue.emplace_back(std::move(pwle)); auto pwleQueue = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading Loading
vibrator/aidl/android/hardware/vibrator/ActivePwle.aidl +26 −2 Original line number Diff line number Diff line Loading @@ -22,26 +22,50 @@ parcelable ActivePwle { * Amplitude ranging from 0.0 (inclusive) to 1.0 (inclusive) * in units of output acceleration amplitude, not voltage amplitude. * * Values should fall within the range of 0.0 (inclusive) to the maximum defined * by the corresponding entries in IVibrator#getBandwidthAmplitudeMap (inclusive). * If startFrequency falls between two entries, the value will not exceed the * largest amplitude of the two bounding frequencies. * * 0.0 represents no output acceleration amplitude * 1.0 represents maximum output acceleration amplitude at resonant frequency * 1.0 represents maximum output acceleration amplitude * across all supported frequencies */ float startAmplitude; /** * Absolute frequency point in the units of hertz * * Values are within the continuous inclusive frequency range defined by * IVibrator#getBandwidthAmplitudeMap, and not limited by the * IVibrator#getFrequencyResolution. */ float startFrequency; /** * Amplitude ranging from 0.0 (inclusive) to 1.0 (inclusive) * in units of output acceleration amplitude, not voltage amplitude. * * Values should fall within the range of 0.0 (inclusive) to the maximum defined * by the corresponding entries in IVibrator#getBandwidthAmplitudeMap (inclusive). * If endFrequency falls between two entries, the value will not exceed the * largest amplitude of the two bounding frequencies. * * 0.0 represents no output acceleration amplitude * 1.0 represents maximum output acceleration amplitude at resonant frequency * 1.0 represents maximum output acceleration amplitude * across all supported frequencies */ float endAmplitude; /** * Absolute frequency point in the units of hertz * * Values are within the continuous inclusive frequency range defined by * IVibrator#getBandwidthAmplitudeMap, and not limited by the * IVibrator#getFrequencyResolution. */ float endFrequency; /** * Total duration from start point to end point in the units of milliseconds */ Loading
vibrator/aidl/android/hardware/vibrator/IVibrator.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -305,6 +305,10 @@ interface IVibrator { * of getFrequencyResolution(). The value returned by getResonantFrequency() must be * represented in the returned list. * * The amplitude values represent the maximum output acceleration amplitude supported for each * given frequency. Equal amplitude values for different frequencies represent equal output * accelerations. * * @return The maximum output acceleration amplitude for each supported frequency, * starting at getMinimumFrequency() */ Loading
vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +32 −46 Original line number Diff line number Diff line Loading @@ -717,27 +717,33 @@ TEST_P(VibratorAidl, GetSupportedBraking) { TEST_P(VibratorAidl, ComposeValidPwle) { if (capabilities & IVibrator::CAP_COMPOSE_PWLE_EFFECTS) { ActivePwle active = composeValidActivePwle(vibrator, capabilities); ActivePwle firstActive = composeValidActivePwle(vibrator, capabilities); std::vector<Braking> supported; ASSERT_TRUE(vibrator->getSupportedBraking(&supported).isOk()); bool isClabSupported = std::find(supported.begin(), supported.end(), Braking::CLAB) != supported.end(); BrakingPwle braking; braking.braking = isClabSupported ? Braking::CLAB : Braking::NONE; braking.duration = 100; BrakingPwle firstBraking; firstBraking.braking = isClabSupported ? Braking::CLAB : Braking::NONE; firstBraking.duration = 100; std::vector<PrimitivePwle> pwleQueue; PrimitivePwle pwle; pwle = active; pwleQueue.emplace_back(std::move(pwle)); pwle = braking; pwleQueue.emplace_back(std::move(pwle)); pwle = active; pwleQueue.emplace_back(std::move(pwle)); ActivePwle secondActive = composeValidActivePwle(vibrator, capabilities); if (capabilities & IVibrator::CAP_FREQUENCY_CONTROL) { float minFrequencyHz = getFrequencyMinimumHz(vibrator, capabilities); float maxFrequencyHz = getFrequencyMaximumHz(vibrator, capabilities); float freqResolutionHz = getFrequencyResolutionHz(vibrator, capabilities); secondActive.startFrequency = minFrequencyHz + (freqResolutionHz / 2.0f); secondActive.endFrequency = maxFrequencyHz - (freqResolutionHz / 3.0f); } BrakingPwle secondBraking; secondBraking.braking = Braking::NONE; secondBraking.duration = 10; auto pwleQueue = std::vector<PrimitivePwle>{firstActive, firstBraking, secondActive, secondBraking}; EXPECT_EQ(Status::EX_NONE, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading Loading @@ -765,14 +771,7 @@ TEST_P(VibratorAidl, ComposeValidPwleWithCallback) { braking.braking = isClabSupported ? Braking::CLAB : Braking::NONE; braking.duration = 100; std::vector<PrimitivePwle> pwleQueue; PrimitivePwle pwle; pwle = active; pwleQueue.emplace_back(std::move(pwle)); pwle = braking; pwleQueue.emplace_back(std::move(pwle)); pwle = active; pwleQueue.emplace_back(std::move(pwle)); auto pwleQueue = std::vector<PrimitivePwle>{active, braking, active}; EXPECT_TRUE(vibrator->composePwle(pwleQueue, callback).isOk()); EXPECT_EQ(completionFuture.wait_for(timeout), std::future_status::ready); Loading @@ -785,7 +784,7 @@ TEST_P(VibratorAidl, ComposePwleSegmentBoundary) { // test empty queue EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); ActivePwle active = composeValidActivePwle(vibrator, capabilities); Loading @@ -801,7 +800,7 @@ TEST_P(VibratorAidl, ComposePwleSegmentBoundary) { EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading @@ -811,25 +810,20 @@ TEST_P(VibratorAidl, ComposePwleAmplitudeParameterBoundary) { active.startAmplitude = getAmplitudeMax() + 1.0; // Amplitude greater than allowed active.endAmplitude = getAmplitudeMax() + 1.0; // Amplitude greater than allowed std::vector<PrimitivePwle> pwleQueueGreater; PrimitivePwle pwle; pwle = active; pwleQueueGreater.emplace_back(std::move(pwle)); auto pwleQueueGreater = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueGreater, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); active.startAmplitude = getAmplitudeMin() - 1.0; // Amplitude less than allowed active.endAmplitude = getAmplitudeMin() - 1.0; // Amplitude less than allowed std::vector<PrimitivePwle> pwleQueueLess; pwle = active; pwleQueueLess.emplace_back(std::move(pwle)); auto pwleQueueLess = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueLess, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading @@ -845,25 +839,20 @@ TEST_P(VibratorAidl, ComposePwleFrequencyParameterBoundary) { freqMaximumHz + freqResolutionHz; // Frequency greater than allowed active.endFrequency = freqMaximumHz + freqResolutionHz; // Frequency greater than allowed std::vector<PrimitivePwle> pwleQueueGreater; PrimitivePwle pwle; pwle = active; pwleQueueGreater.emplace_back(std::move(pwle)); auto pwleQueueGreater = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueGreater, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); active.startFrequency = freqMinimumHz - freqResolutionHz; // Frequency less than allowed active.endFrequency = freqMinimumHz - freqResolutionHz; // Frequency less than allowed std::vector<PrimitivePwle> pwleQueueLess; pwle = active; pwleQueueLess.emplace_back(std::move(pwle)); auto pwleQueueLess = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueueLess, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading @@ -875,14 +864,11 @@ TEST_P(VibratorAidl, ComposePwleSegmentDurationBoundary) { vibrator->getPwlePrimitiveDurationMax(&segmentDurationMaxMs); active.duration = segmentDurationMaxMs + 10; // Segment duration greater than allowed std::vector<PrimitivePwle> pwleQueue; PrimitivePwle pwle; pwle = active; pwleQueue.emplace_back(std::move(pwle)); auto pwleQueue = std::vector<PrimitivePwle>{active}; EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT, vibrator->composePwle(pwleQueue, nullptr).exceptionCode()); vibrator->off(); EXPECT_TRUE(vibrator->off().isOk()); } } Loading