AI 149136: Restore RECORD_AUDIO permission check to MediaRecorder.
When we moved the media recorder to the media server process, we lost the permission check that was done at the process boundary in the AudioRecord binder interface because the AudioRecord object is created in the same process. This change adds a permission check in the MediaRecorderClient:setAudioSource() method. BUG=1868334 Automated import of CL 149136
This commit is contained in:
committed by
The Android Open Source Project
parent
7b7225c8fd
commit
4d8adefd35
@@ -37,6 +37,7 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
const char* cameraPermission = "android.permission.CAMERA";
|
const char* cameraPermission = "android.permission.CAMERA";
|
||||||
|
const char* recordAudioPermission = "android.permission.RECORD_AUDIO";
|
||||||
|
|
||||||
static bool checkPermission(const char* permissionString) {
|
static bool checkPermission(const char* permissionString) {
|
||||||
#ifndef HAVE_ANDROID_OS
|
#ifndef HAVE_ANDROID_OS
|
||||||
@@ -86,6 +87,9 @@ status_t MediaRecorderClient::setVideoSource(int vs)
|
|||||||
status_t MediaRecorderClient::setAudioSource(int as)
|
status_t MediaRecorderClient::setAudioSource(int as)
|
||||||
{
|
{
|
||||||
LOGV("setAudioSource(%d)", as);
|
LOGV("setAudioSource(%d)", as);
|
||||||
|
if (!checkPermission(recordAudioPermission)) {
|
||||||
|
return PERMISSION_DENIED;
|
||||||
|
}
|
||||||
Mutex::Autolock lock(mLock);
|
Mutex::Autolock lock(mLock);
|
||||||
if (mRecorder == NULL) {
|
if (mRecorder == NULL) {
|
||||||
LOGE("recorder is not initialized");
|
LOGE("recorder is not initialized");
|
||||||
|
|||||||
Reference in New Issue
Block a user