Merge "Update ActivePwle description for amplitude values" into stage-aosp-master am: 1f81aeea7b am: 8d9b5150ea am: b1205f9cd0

Original change: https://googleplex-android-review.googlesource.com/c/platform/hardware/interfaces/+/15827549

Change-Id: I20eafee2740681cc2c3d2cba103174b7030adac4
This commit is contained in:
TreeHugger Robot
2021-09-21 20:20:57 +00:00
committed by Automerger Merge Worker
3 changed files with 62 additions and 48 deletions

View File

@@ -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
*/

View File

@@ -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()
*/

View File

@@ -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());
}
}
@@ -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);
@@ -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);
@@ -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());
}
}
@@ -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());
}
}
@@ -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());
}
}
@@ -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());
}
}