diff options
author | Dave Sparks <> | 2009-03-27 19:56:11 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-27 19:56:11 -0700 |
commit | d1d35e0359cc411b04615813ba4ebefbb33d1933 (patch) | |
tree | a1ebb6af385b046d58b36f57e588a344099d745e /media/libmediaplayerservice/MediaRecorderClient.cpp | |
parent | 29a65006e517ae5bb164e973b2d805ebfa834a2e (diff) | |
download | frameworks_av-d1d35e0359cc411b04615813ba4ebefbb33d1933.zip frameworks_av-d1d35e0359cc411b04615813ba4ebefbb33d1933.tar.gz frameworks_av-d1d35e0359cc411b04615813ba4ebefbb33d1933.tar.bz2 |
AI 143396: am: CL 143267 am: CL 143127 Media recorder service requires android.permission.CAMERA to record video
Original author: davidsparks
Merged from: //branches/cupcake/...
Original author: android-build
Merged from: //branches/donutburger/...
Automated import of CL 143396
Diffstat (limited to 'media/libmediaplayerservice/MediaRecorderClient.cpp')
-rw-r--r-- | media/libmediaplayerservice/MediaRecorderClient.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/media/libmediaplayerservice/MediaRecorderClient.cpp b/media/libmediaplayerservice/MediaRecorderClient.cpp index 5d1887d..e0d2947 100644 --- a/media/libmediaplayerservice/MediaRecorderClient.cpp +++ b/media/libmediaplayerservice/MediaRecorderClient.cpp @@ -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"); |