vibrator: example: Fix New Test Failures

Bug: 129091875
Test: VTS
Change-Id: Ib57457095c8ff30aff45a5909f2408d144980976
Signed-off-by: Harpreet "Eli" Sangha <eliptus@google.com>
diff --git a/vibrator/1.3/example/Vibrator.cpp b/vibrator/1.3/example/Vibrator.cpp
index 2137789..0cb37e6 100644
--- a/vibrator/1.3/example/Vibrator.cpp
+++ b/vibrator/1.3/example/Vibrator.cpp
@@ -100,14 +100,22 @@
 Return<void> Vibrator::perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
     uint8_t amplitude;
     uint32_t ms;
-    Status status;
+    Status status = Status::OK;
 
     ALOGI("Perform: Effect %s\n", effectToName(effect).c_str());
 
-    amplitude = strengthToAmplitude(strength);
+    amplitude = strengthToAmplitude(strength, &status);
+    if (status != Status::OK) {
+        _hidl_cb(status, 0);
+        return Void();
+    }
     setAmplitude(amplitude);
 
-    ms = effectToMs(effect);
+    ms = effectToMs(effect, &status);
+    if (status != Status::OK) {
+        _hidl_cb(status, 0);
+        return Void();
+    }
     status = activate(ms);
 
     _hidl_cb(status, ms);
@@ -182,7 +190,7 @@
     return toString(effect);
 }
 
-uint32_t Vibrator::effectToMs(Effect effect) {
+uint32_t Vibrator::effectToMs(Effect effect, Status* status) {
     switch (effect) {
         case Effect::CLICK:
             return 10;
@@ -228,9 +236,11 @@
         case Effect::RINGTONE_15:
             return 30000;
     }
+    *status = Status::UNSUPPORTED_OPERATION;
+    return 0;
 }
 
-uint8_t Vibrator::strengthToAmplitude(EffectStrength strength) {
+uint8_t Vibrator::strengthToAmplitude(EffectStrength strength, Status* status) {
     switch (strength) {
         case EffectStrength::LIGHT:
             return 128;
@@ -239,6 +249,8 @@
         case EffectStrength::STRONG:
             return 255;
     }
+    *status = Status::UNSUPPORTED_OPERATION;
+    return 0;
 }
 
 }  // namespace implementation
diff --git a/vibrator/1.3/example/Vibrator.h b/vibrator/1.3/example/Vibrator.h
index c118061..64e8e1b 100644
--- a/vibrator/1.3/example/Vibrator.h
+++ b/vibrator/1.3/example/Vibrator.h
@@ -60,8 +60,8 @@
 
     static void timerCallback(union sigval sigval);
     static const std::string effectToName(Effect effect);
-    static uint32_t effectToMs(Effect effect);
-    static uint8_t strengthToAmplitude(EffectStrength strength);
+    static uint32_t effectToMs(Effect effect, Status* status);
+    static uint8_t strengthToAmplitude(EffectStrength strength, Status* status);
 
   private:
     bool mEnabled{false};