AI 143267: am: CL 143127 Media recorder service requires android.permission.CAMERA to record video
Original author: davidsparks Merged from: //branches/cupcake/... Automated import of CL 143267
This commit is contained in:
committed by
The Android Open Source Project
parent
5711fadfc4
commit
b8c055e7cb
@@ -30,11 +30,24 @@
|
||||
#include <utils/MemoryHeapBase.h>
|
||||
#include <utils/MemoryBase.h>
|
||||
#include <media/PVMediaRecorder.h>
|
||||
#include <utils/String16.h>
|
||||
|
||||
#include "MediaRecorderClient.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
const char* cameraPermission = "android.permission.CAMERA";
|
||||
|
||||
static bool checkPermission(const char* permissionString) {
|
||||
#ifndef HAVE_ANDROID_OS
|
||||
return true;
|
||||
#endif
|
||||
if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
|
||||
bool ok = checkCallingPermission(String16(permissionString));
|
||||
if (!ok) LOGE("Request requires %s", permissionString);
|
||||
return ok;
|
||||
}
|
||||
|
||||
status_t MediaRecorderClient::setCamera(const sp<ICamera>& camera)
|
||||
{
|
||||
LOGV("setCamera");
|
||||
@@ -60,6 +73,9 @@ status_t MediaRecorderClient::setPreviewSurface(const sp<ISurface>& surface)
|
||||
status_t MediaRecorderClient::setVideoSource(int vs)
|
||||
{
|
||||
LOGV("setVideoSource(%d)", vs);
|
||||
if (!checkPermission(cameraPermission)) {
|
||||
return PERMISSION_DENIED;
|
||||
}
|
||||
Mutex::Autolock lock(mLock);
|
||||
if (mRecorder == NULL) {
|
||||
LOGE("recorder is not initialized");
|
||||
|
||||
Reference in New Issue
Block a user