vibrator: example: Fix out-of-scope memory access.

Bug: 129091875
Test: VTS
Change-Id: I64685e6e8982db1a33c8322e1df7d266fa367eaf
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 eb50187..2137789 100644
--- a/vibrator/1.3/example/Vibrator.cpp
+++ b/vibrator/1.3/example/Vibrator.cpp
@@ -102,7 +102,7 @@
     uint32_t ms;
     Status status;
 
-    ALOGI("Perform: Effect %s\n", effectToName(effect));
+    ALOGI("Perform: Effect %s\n", effectToName(effect).c_str());
 
     amplitude = strengthToAmplitude(strength);
     setAmplitude(amplitude);
@@ -178,8 +178,8 @@
     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) {
diff --git a/vibrator/1.3/example/Vibrator.h b/vibrator/1.3/example/Vibrator.h
index 8cf0b1e..c118061 100644
--- a/vibrator/1.3/example/Vibrator.h
+++ b/vibrator/1.3/example/Vibrator.h
@@ -59,7 +59,7 @@
     void timeout();
 
     static void timerCallback(union sigval sigval);
-    static const char* effectToName(Effect effect);
+    static const std::string effectToName(Effect effect);
     static uint32_t effectToMs(Effect effect);
     static uint8_t strengthToAmplitude(EffectStrength strength);