Merge changes Ib5745709,I64685e6e

* changes:
  vibrator: example: Fix New Test Failures
  vibrator: example: Fix out-of-scope memory access.
diff --git a/vibrator/1.3/example/Vibrator.cpp b/vibrator/1.3/example/Vibrator.cpp
index eb50187..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));
+    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);
@@ -178,11 +186,11 @@
     static_cast<Vibrator*>(sigval.sival_ptr)->timeout();
 }
 
-const char* Vibrator::effectToName(Effect effect) {
-    return toString(effect).c_str();
+const std::string Vibrator::effectToName(Effect effect) {
+    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 8cf0b1e..64e8e1b 100644
--- a/vibrator/1.3/example/Vibrator.h
+++ b/vibrator/1.3/example/Vibrator.h
@@ -59,9 +59,9 @@
     void timeout();
 
     static void timerCallback(union sigval sigval);
-    static const char* effectToName(Effect effect);
-    static uint32_t effectToMs(Effect effect);
-    static uint8_t strengthToAmplitude(EffectStrength strength);
+    static const std::string effectToName(Effect effect);
+    static uint32_t effectToMs(Effect effect, Status* status);
+    static uint8_t strengthToAmplitude(EffectStrength strength, Status* status);
 
   private:
     bool mEnabled{false};