Update ActivePwle description for amplitude values

Update description to clarify that the value 1 should map to the maximum
output acceleration supported by the device at any frequency, not exclusively
to the one at resonant frequency.

Also add information linking the  ActivePwle input parameters of composePwle
to the output values returned by getBandwidthAmplitudeMap, and update
the bandwidth description as well.

Change-Id: Id6e02c5d323aec57db7e7127e219a9705d0289a3
Fix: 199753151
Test: VtsHalVibratorTargetTest
diff --git a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp
index 553d7f0..53f8c0e 100644
--- a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp
+++ b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp
@@ -717,27 +717,33 @@
 
 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 @@
     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 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 @@
 
         EXPECT_EQ(Status::EX_ILLEGAL_ARGUMENT,
                   vibrator->composePwle(pwleQueue, nullptr).exceptionCode());
-        vibrator->off();
+        EXPECT_TRUE(vibrator->off().isOk());
     }
 }
 
@@ -811,25 +810,20 @@
         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 @@
             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 @@
         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());
     }
 }