summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-09-12 00:15:30 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-12 00:15:31 +0000
commit95a181397dad3113b96e3cc7392a5b0f5d742f39 (patch)
treef1d61c6532945eb79d2ccc59c335041c093a9f52 /core
parentede3eeb72c9708df023bdfb369905ededd1ebb06 (diff)
parent357263da0ec2bc2be9d48c1becc3d94288c2f3ed (diff)
downloadframeworks_base-95a181397dad3113b96e3cc7392a5b0f5d742f39.zip
frameworks_base-95a181397dad3113b96e3cc7392a5b0f5d742f39.tar.gz
frameworks_base-95a181397dad3113b96e3cc7392a5b0f5d742f39.tar.bz2
Merge "Add HOTWORD as an AudioSource" into klp-dev
Diffstat (limited to 'core')
-rw-r--r--core/jni/android_media_AudioRecord.cpp11
-rw-r--r--core/res/AndroidManifest.xml8
-rw-r--r--core/res/res/values/strings.xml6
3 files changed, 23 insertions, 2 deletions
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index 0cd6f4a..1c43cc5 100644
--- a/core/jni/android_media_AudioRecord.cpp
+++ b/core/jni/android_media_AudioRecord.cpp
@@ -190,7 +190,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
int frameSize = nbChannels * bytesPerSample;
size_t frameCount = buffSizeInBytes / frameSize;
- if (uint32_t(source) >= AUDIO_SOURCE_CNT) {
+ if ((uint32_t(source) >= AUDIO_SOURCE_CNT) && (uint32_t(source) != AUDIO_SOURCE_HOTWORD)) {
ALOGE("Error creating AudioRecord: unknown source.");
return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
}
@@ -387,6 +387,9 @@ static jint android_media_AudioRecord_readInByteArray(JNIEnv *env, jobject thiz
(jint)recorderBuffSize : sizeInBytes );
env->ReleaseByteArrayElements(javaAudioData, recordBuff, 0);
+ if (readSize < 0) {
+ readSize = AUDIORECORD_ERROR_INVALID_OPERATION;
+ }
return (jint) readSize;
}
@@ -427,8 +430,12 @@ static jint android_media_AudioRecord_readInDirectBuffer(JNIEnv *env, jobject t
}
// read new data from the recorder
- return (jint) lpRecorder->read(nativeFromJavaBuf,
+ ssize_t readSize = lpRecorder->read(nativeFromJavaBuf,
capacity < sizeInBytes ? capacity : sizeInBytes);
+ if (readSize < 0) {
+ readSize = AUDIORECORD_ERROR_INVALID_OPERATION;
+ }
+ return (jint)readSize;
}
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index d4ca5a0..a194240 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -2084,6 +2084,14 @@
android:description="@string/permdesc_captureAudioOutput"
android:protectionLevel="signature|system" />
+ <!-- Allows an application to capture audio for hotword detection.
+ <p>Not for use by third-party applications.</p>
+ @hide -->
+ <permission android:name="android.permission.CAPTURE_AUDIO_HOTWORD"
+ android:label="@string/permlab_captureAudioHotword"
+ android:description="@string/permdesc_captureAudioHotword"
+ android:protectionLevel="signature|system" />
+
<!-- Allows an application to capture video output.
<p>Not for use by third-party applications.</p> -->
<permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT"
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index fa6ecc8..35d0fbd 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1405,6 +1405,12 @@
<string name="permdesc_captureAudioOutput">Allows the app to capture and redirect audio output.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_captureAudioHotword">Hotword detection</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_captureAudioHotword">Allows the app to capture audio for Hotword detection. The capture can
+ happen in the background but does not prevent other audio capture (e.g. Camcorder).</string>
+
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_captureVideoOutput">capture video output</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_captureVideoOutput">Allows the app to capture and redirect video output.</string>