Add wakelock to audio HAL. Bug 2218158.

Applications are supposed to hold a wakelock. However, since 1.0,
the audio driver and/or HAL has held a partial wakelock. That means
that many apps will be broken if we don't hold a wakelock while
audio is playing. This patch holds a wakelock while the audio
driver is open and releases it when it goes to standby mode.
diff --git a/libaudio-qsd8k/AudioHardware.cpp b/libaudio-qsd8k/AudioHardware.cpp
index 30e1428..2b3790a 100644
--- a/libaudio-qsd8k/AudioHardware.cpp
+++ b/libaudio-qsd8k/AudioHardware.cpp
@@ -20,6 +20,7 @@
 #define LOG_TAG "AudioHardwareQSD"
 #include <utils/Log.h>
 #include <utils/String8.h>
+#include <hardware_legacy/power.h>
 
 #include <stdio.h>
 #include <unistd.h>
@@ -80,6 +81,10 @@
 const uint32_t AudioHardware::inputSamplingRates[] = {
         8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
 };
+
+// ID string for audio wakelock
+static const char kOutputWakelockStr[] = "AudioHardwareQSD";
+
 // ----------------------------------------------------------------------------
 
 AudioHardware::AudioHardware() :
@@ -963,6 +968,8 @@
             LOGE("Cannot start pcm playback");
             goto Error;
         }
+        LOGV("acquire wakelock");
+        acquire_wake_lock(PARTIAL_WAKE_LOCK, kOutputWakelockStr);
         mStandby = false;
     }
 
@@ -997,6 +1004,8 @@
     if (!mStandby && mFd >= 0) {
         ::close(mFd);
         mFd = -1;
+        LOGV("release wakelock");
+        release_wake_lock(kOutputWakelockStr);
     }
     mStandby = true;
     LOGI("AudioHardware pcm playback is going to standby.");