diff options
author | Dave Sparks <> | 2009-03-27 20:28:22 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-27 20:28:22 -0700 |
commit | b8c055e7cbf3ca2ea2670747c2b482eca8251fb5 (patch) | |
tree | 0af4be3b0762e330b837748624f5c82dc29772f6 /media | |
parent | 5711fadfc48f0e77bc25a91ef36c76acb0d2f55a (diff) | |
download | frameworks_base-b8c055e7cbf3ca2ea2670747c2b482eca8251fb5.zip frameworks_base-b8c055e7cbf3ca2ea2670747c2b482eca8251fb5.tar.gz frameworks_base-b8c055e7cbf3ca2ea2670747c2b482eca8251fb5.tar.bz2 |
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
Diffstat (limited to 'media')
-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"); |