Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8063a45b authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Android (Google) Code Review
Browse files

Merge "cameraserver: Wrap calls to IPCThreadState functions to factor in different transports."

parents 6ec3379f 12361936
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ cc_library_shared {
        "device3/Camera3StreamSplitter.cpp",
        "device3/DistortionMapper.cpp",
        "gui/RingBufferConsumer.cpp",
        "utils/CameraThreadState.cpp",
        "utils/CameraTraces.cpp",
        "utils/AutoConditionLock.cpp",
        "utils/TagMonitor.cpp",
@@ -72,6 +73,7 @@ cc_library_shared {
        "libfmq",
        "libgui",
        "libhardware",
        "libhwbinder",
        "libhidlbase",
        "libhidltransport",
        "libjpeg",
+27 −34
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@
#include "api2/CameraDeviceClient.h"
#include "utils/CameraTraces.h"
#include "utils/TagMonitor.h"
#include "utils/CameraThreadState.h"

namespace {
    const char* kPermissionServiceName = "permission";
@@ -325,7 +326,7 @@ void CameraService::onDeviceStatusChanged(const String8& id,
                    hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DISCONNECTED,
                    CaptureResultExtras{});
            // Ensure not in binder RPC so client disconnect PID checks work correctly
            LOG_ALWAYS_FATAL_IF(getCallingPid() != getpid(),
            LOG_ALWAYS_FATAL_IF(CameraThreadState::getCallingPid() != getpid(),
                    "onDeviceStatusChanged must be called from the camera service process!");
            clientToDisconnect->disconnect();
        }
@@ -491,8 +492,8 @@ Status CameraService::getCameraCharacteristics(const String16& cameraId,
                strerror(-res), res);
    }

    int callingPid = getCallingPid();
    int callingUid = getCallingUid();
    int callingPid = CameraThreadState::getCallingPid();
    int callingUid = CameraThreadState::getCallingUid();
    std::vector<int32_t> tagsRemoved;
    // If it's not calling from cameraserver, check the permission.
    if ((callingPid != getpid()) &&
@@ -522,14 +523,6 @@ Status CameraService::getCameraCharacteristics(const String16& cameraId,
    return ret;
}

int CameraService::getCallingPid() {
    return IPCThreadState::self()->getCallingPid();
}

int CameraService::getCallingUid() {
    return IPCThreadState::self()->getCallingUid();
}

String8 CameraService::getFormattedCurrentTime() {
    time_t now = time(nullptr);
    char formattedTime[64];
@@ -754,7 +747,7 @@ int32_t CameraService::mapToInterface(StatusInternal status) {
}

Status CameraService::initializeShimMetadata(int cameraId) {
    int uid = getCallingUid();
    int uid = CameraThreadState::getCallingUid();

    String16 internalPackageName("cameraserver");
    String8 id = String8::format("%d", cameraId);
@@ -803,9 +796,9 @@ Status CameraService::getLegacyParametersLazy(int cameraId,
        }
    }

    int64_t token = IPCThreadState::self()->clearCallingIdentity();
    int64_t token = CameraThreadState::clearCallingIdentity();
    ret = initializeShimMetadata(cameraId);
    IPCThreadState::self()->restoreCallingIdentity(token);
    CameraThreadState::restoreCallingIdentity(token);
    if (!ret.isOk()) {
        // Error already logged by callee
        return ret;
@@ -862,7 +855,7 @@ Status CameraService::validateConnectLocked(const String8& cameraId,
    }
#endif  // __BRILLO__

    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();

    if (!mInitialized) {
        ALOGE("CameraService::connect X (PID %d) rejected (camera HAL module not loaded)",
@@ -896,8 +889,8 @@ Status CameraService::validateConnectLocked(const String8& cameraId,
Status CameraService::validateClientPermissionsLocked(const String8& cameraId,
        const String8& clientName8, int& clientUid, int& clientPid,
        /*out*/int& originalClientPid) const {
    int callingPid = getCallingPid();
    int callingUid = getCallingUid();
    int callingPid = CameraThreadState::getCallingPid();
    int callingUid = CameraThreadState::getCallingUid();

    // Check if we can trust clientUid
    if (clientUid == USE_CALLING_UID) {
@@ -966,7 +959,7 @@ Status CameraService::validateClientPermissionsLocked(const String8& cameraId,

status_t CameraService::checkIfDeviceIsUsable(const String8& cameraId) const {
    auto cameraState = getCameraState(cameraId);
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    if (cameraState == nullptr) {
        ALOGE("CameraService::connect X (PID %d) rejected (invalid camera ID %s)", callingPid,
                cameraId.string());
@@ -1170,7 +1163,7 @@ status_t CameraService::handleEvictionsLocked(const String8& cameraId, int clien
    mServiceLock.unlock();

    // Clear caller identity temporarily so client disconnect PID checks work correctly
    int64_t token = IPCThreadState::self()->clearCallingIdentity();
    int64_t token = CameraThreadState::clearCallingIdentity();

    // Destroy evicted clients
    for (auto& i : evictedClients) {
@@ -1178,7 +1171,7 @@ status_t CameraService::handleEvictionsLocked(const String8& cameraId, int clien
        i->getValue()->disconnect(); // Clients will remove themselves from the active client list
    }

    IPCThreadState::self()->restoreCallingIdentity(token);
    CameraThreadState::restoreCallingIdentity(token);

    for (const auto& i : evictedClients) {
        ALOGV("%s: Waiting for disconnect to complete for client for device %s (PID %" PRId32 ")",
@@ -1231,7 +1224,7 @@ Status CameraService::connect(
            /*shimUpdateOnly*/ false, /*out*/client);

    if(!ret.isOk()) {
        logRejected(id, getCallingPid(), String8(clientPackageName),
        logRejected(id, CameraThreadState::getCallingPid(), String8(clientPackageName),
                ret.toString8());
        return ret;
    }
@@ -1258,7 +1251,7 @@ Status CameraService::connectLegacy(
            /*out*/client);

    if(!ret.isOk()) {
        logRejected(id, getCallingPid(), String8(clientPackageName),
        logRejected(id, CameraThreadState::getCallingPid(), String8(clientPackageName),
                ret.toString8());
        return ret;
    }
@@ -1285,7 +1278,7 @@ Status CameraService::connectDevice(
            clientUid, USE_CALLING_PID, API_2, /*shimUpdateOnly*/ false, /*out*/client);

    if(!ret.isOk()) {
        logRejected(id, getCallingPid(), String8(clientPackageName),
        logRejected(id, CameraThreadState::getCallingPid(), String8(clientPackageName),
                ret.toString8());
        return ret;
    }
@@ -1466,7 +1459,7 @@ Status CameraService::setTorchMode(const String16& cameraId, bool enabled,
    }

    String8 id = String8(cameraId.string());
    int uid = getCallingUid();
    int uid = CameraThreadState::getCallingUid();

    // verify id is valid.
    auto state = getCameraState(id);
@@ -1913,13 +1906,13 @@ void CameraService::doUserSwitch(const std::vector<int32_t>& newUserIds) {
    mServiceLock.unlock();

    // Clear caller identity temporarily so client disconnect PID checks work correctly
    int64_t token = IPCThreadState::self()->clearCallingIdentity();
    int64_t token = CameraThreadState::clearCallingIdentity();

    for (auto& i : evicted) {
        i->disconnect();
    }

    IPCThreadState::self()->restoreCallingIdentity(token);
    CameraThreadState::restoreCallingIdentity(token);

    // Reacquire mServiceLock
    mServiceLock.lock();
@@ -1987,7 +1980,7 @@ void CameraService::logServiceError(const char* msg, int errorCode) {
status_t CameraService::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
        uint32_t flags) {

    const int pid = getCallingPid();
    const int pid = CameraThreadState::getCallingPid();
    const int selfPid = getpid();

    // Permission checks
@@ -2022,7 +2015,7 @@ status_t CameraService::onTransact(uint32_t code, const Parcel& data, Parcel* re
                // permissions to notify the camera service about system events
                if (!checkCallingPermission(
                        String16("android.permission.CAMERA_SEND_SYSTEM_EVENTS"))) {
                    const int uid = getCallingUid();
                    const int uid = CameraThreadState::getCallingUid();
                    ALOGE("Permission Denial: cannot send updates to camera service about system"
                            " events from pid=%d, uid=%d", pid, uid);
                    return PERMISSION_DENIED;
@@ -2119,7 +2112,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
                servicePid),
        mCameraId(api1CameraId)
{
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    LOG1("Client::Client E (pid %d, id %d)", callingPid, mCameraId);

    mRemoteCallback = cameraClient;
@@ -2228,7 +2221,7 @@ status_t CameraService::BasicClient::dump(int, const Vector<String16>&) {
    // No dumping of clients directly over Binder,
    // must go through CameraService::dump
    android_errorWriteWithInfoLog(SN_EVENT_LOG_ID, "26265403",
            IPCThreadState::self()->getCallingUid(), NULL, 0);
            CameraThreadState::getCallingUid(), NULL, 0);
    return OK;
}

@@ -2365,7 +2358,7 @@ void CameraService::BasicClient::block() {

    // Reset the client PID to allow server-initiated disconnect,
    // and to prevent further calls by client.
    mClientPid = getCallingPid();
    mClientPid = CameraThreadState::getCallingPid();
    CaptureResultExtras resultExtras; // a dummy result (invalid)
    notifyError(hardware::camera2::ICameraDeviceCallbacks::ERROR_CAMERA_DISABLED, resultExtras);
    disconnect();
@@ -2726,8 +2719,8 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) {

    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        dprintf(fd, "Permission Denial: can't dump CameraService from pid=%d, uid=%d\n",
                getCallingPid(),
                getCallingUid());
                CameraThreadState::getCallingPid(),
                CameraThreadState::getCallingUid());
        return NO_ERROR;
    }
    bool locked = tryLock(mServiceLock);
@@ -2900,7 +2893,7 @@ void CameraService::handleTorchClientBinderDied(const wp<IBinder> &who) {
      * binder driver
      */
    // PID here is approximate and can be wrong.
    logClientDied(getCallingPid(), String8("Binder died unexpectedly"));
    logClientDied(CameraThreadState::getCallingPid(), String8("Binder died unexpectedly"));

    // check torch client
    handleTorchClientBinderDied(who);
+0 −4
Original line number Diff line number Diff line
@@ -836,10 +836,6 @@ private:
    // Prints the shell command help
    status_t printHelp(int out);

    static int getCallingPid();

    static int getCallingUid();

    /**
     * Get the current system time as a formatted string.
     */
+13 −16
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "api1/client2/CaptureSequencer.h"
#include "api1/client2/CallbackProcessor.h"
#include "api1/client2/ZslProcessor.h"
#include "utils/CameraThreadState.h"

#define ALOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define ALOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
@@ -40,10 +41,6 @@
namespace android {
using namespace camera2;

static int getCallingPid() {
    return IPCThreadState::self()->getCallingPid();
}

// Interface used by CameraService

Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
@@ -398,7 +395,7 @@ binder::Status Camera2Client::disconnect() {

    binder::Status res = binder::Status::ok();
    // Allow both client and the cameraserver to disconnect at all times
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    if (callingPid != mClientPid && callingPid != mServicePid) return res;

    if (mDevice == 0) return res;
@@ -463,14 +460,14 @@ status_t Camera2Client::connect(const sp<hardware::ICameraClient>& client) {
    ALOGV("%s: E", __FUNCTION__);
    Mutex::Autolock icl(mBinderSerializationLock);

    if (mClientPid != 0 && getCallingPid() != mClientPid) {
    if (mClientPid != 0 && CameraThreadState::getCallingPid() != mClientPid) {
        ALOGE("%s: Camera %d: Connection attempt from pid %d; "
                "current locked to pid %d", __FUNCTION__,
                mCameraId, getCallingPid(), mClientPid);
                mCameraId, CameraThreadState::getCallingPid(), mClientPid);
        return BAD_VALUE;
    }

    mClientPid = getCallingPid();
    mClientPid = CameraThreadState::getCallingPid();

    mRemoteCallback = client;
    mSharedCameraCallbacks = client;
@@ -483,16 +480,16 @@ status_t Camera2Client::lock() {
    ALOGV("%s: E", __FUNCTION__);
    Mutex::Autolock icl(mBinderSerializationLock);
    ALOGV("%s: Camera %d: Lock call from pid %d; current client pid %d",
            __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
            __FUNCTION__, mCameraId, CameraThreadState::getCallingPid(), mClientPid);

    if (mClientPid == 0) {
        mClientPid = getCallingPid();
        mClientPid = CameraThreadState::getCallingPid();
        return OK;
    }

    if (mClientPid != getCallingPid()) {
    if (mClientPid != CameraThreadState::getCallingPid()) {
        ALOGE("%s: Camera %d: Lock call from pid %d; currently locked to pid %d",
                __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
                __FUNCTION__, mCameraId, CameraThreadState::getCallingPid(), mClientPid);
        return EBUSY;
    }

@@ -504,9 +501,9 @@ status_t Camera2Client::unlock() {
    ALOGV("%s: E", __FUNCTION__);
    Mutex::Autolock icl(mBinderSerializationLock);
    ALOGV("%s: Camera %d: Unlock call from pid %d; current client pid %d",
            __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
            __FUNCTION__, mCameraId, CameraThreadState::getCallingPid(), mClientPid);

    if (mClientPid == getCallingPid()) {
    if (mClientPid == CameraThreadState::getCallingPid()) {
        SharedParameters::Lock l(mParameters);
        if (l.mParameters.state == Parameters::RECORD ||
                l.mParameters.state == Parameters::VIDEO_SNAPSHOT) {
@@ -520,7 +517,7 @@ status_t Camera2Client::unlock() {
    }

    ALOGE("%s: Camera %d: Unlock call from pid %d; currently locked to pid %d",
            __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
            __FUNCTION__, mCameraId, CameraThreadState::getCallingPid(), mClientPid);
    return EBUSY;
}

@@ -1574,7 +1571,7 @@ String8 Camera2Client::getParameters() const {
    ALOGV("%s: Camera %d", __FUNCTION__, mCameraId);
    Mutex::Autolock icl(mBinderSerializationLock);
    // The camera service can unconditionally get the parameters at all times
    if (getCallingPid() != mServicePid && checkPid(__FUNCTION__) != OK) return String8();
    if (CameraThreadState::getCallingPid() != mServicePid && checkPid(__FUNCTION__) != OK) return String8();

    SharedParameters::ReadLock l(mParameters);

+30 −30
Original line number Diff line number Diff line
@@ -25,16 +25,13 @@
#include "api1/CameraClient.h"
#include "device1/CameraHardwareInterface.h"
#include "CameraService.h"
#include "utils/CameraThreadState.h"

namespace android {

#define LOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define LOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);

static int getCallingPid() {
    return IPCThreadState::self()->getCallingPid();
}

CameraClient::CameraClient(const sp<CameraService>& cameraService,
        const sp<hardware::ICameraClient>& cameraClient,
        const String16& clientPackageName,
@@ -45,7 +42,7 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService,
                String8::format("%d", cameraId), cameraId, cameraFacing, clientPid,
                clientUid, servicePid)
{
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    LOG1("CameraClient::CameraClient E (pid %d, id %d)", callingPid, cameraId);

    mHardware = NULL;
@@ -63,7 +60,7 @@ CameraClient::CameraClient(const sp<CameraService>& cameraService,

status_t CameraClient::initialize(sp<CameraProviderManager> manager,
        const String8& /*monitorTags*/) {
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    status_t res;

    LOG1("CameraClient::initialize E (pid %d, id %d)", callingPid, mCameraId);
@@ -104,7 +101,7 @@ status_t CameraClient::initialize(sp<CameraProviderManager> manager,
// tear down the client
CameraClient::~CameraClient() {
    mDestructionStarted = true;
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    LOG1("CameraClient::~CameraClient E (pid %d, this %p)", callingPid, this);

    disconnect();
@@ -147,7 +144,7 @@ status_t CameraClient::dumpClient(int fd, const Vector<String16>& args) {
// ----------------------------------------------------------------------------

status_t CameraClient::checkPid() const {
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    if (callingPid == mClientPid) return NO_ERROR;

    ALOGW("attempt to use a locked camera from a different process"
@@ -157,7 +154,8 @@ status_t CameraClient::checkPid() const {

status_t CameraClient::checkPidAndHardware() const {
    if (mHardware == 0) {
        ALOGE("attempt to use a camera after disconnect() (pid %d)", getCallingPid());
        ALOGE("attempt to use a camera after disconnect() (pid %d)",
              CameraThreadState::getCallingPid());
        return INVALID_OPERATION;
    }
    status_t result = checkPid();
@@ -166,7 +164,7 @@ status_t CameraClient::checkPidAndHardware() const {
}

status_t CameraClient::lock() {
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    LOG1("lock (pid %d)", callingPid);
    Mutex::Autolock lock(mLock);

@@ -181,7 +179,7 @@ status_t CameraClient::lock() {
}

status_t CameraClient::unlock() {
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    LOG1("unlock (pid %d)", callingPid);
    Mutex::Autolock lock(mLock);

@@ -203,7 +201,7 @@ status_t CameraClient::unlock() {

// connect a new client to the camera
status_t CameraClient::connect(const sp<hardware::ICameraClient>& client) {
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    LOG1("connect E (pid %d)", callingPid);
    Mutex::Autolock lock(mLock);

@@ -239,7 +237,7 @@ static void disconnectWindow(const sp<ANativeWindow>& window) {
}

binder::Status CameraClient::disconnect() {
    int callingPid = getCallingPid();
    int callingPid = CameraThreadState::getCallingPid();
    LOG1("disconnect E (pid %d)", callingPid);
    Mutex::Autolock lock(mLock);

@@ -333,7 +331,7 @@ status_t CameraClient::setPreviewWindow(const sp<IBinder>& binder,
status_t CameraClient::setPreviewTarget(
        const sp<IGraphicBufferProducer>& bufferProducer) {
    LOG1("setPreviewTarget(%p) (pid %d)", bufferProducer.get(),
            getCallingPid());
            CameraThreadState::getCallingPid());

    sp<IBinder> binder;
    sp<ANativeWindow> window;
@@ -350,7 +348,7 @@ status_t CameraClient::setPreviewTarget(
// set the preview callback flag to affect how the received frames from
// preview are handled.
void CameraClient::setPreviewCallbackFlag(int callback_flag) {
    LOG1("setPreviewCallbackFlag(%d) (pid %d)", callback_flag, getCallingPid());
    LOG1("setPreviewCallbackFlag(%d) (pid %d)", callback_flag, CameraThreadState::getCallingPid());
    Mutex::Autolock lock(mLock);
    if (checkPidAndHardware() != NO_ERROR) return;

@@ -371,13 +369,13 @@ status_t CameraClient::setPreviewCallbackTarget(

// start preview mode
status_t CameraClient::startPreview() {
    LOG1("startPreview (pid %d)", getCallingPid());
    LOG1("startPreview (pid %d)", CameraThreadState::getCallingPid());
    return startCameraMode(CAMERA_PREVIEW_MODE);
}

// start recording mode
status_t CameraClient::startRecording() {
    LOG1("startRecording (pid %d)", getCallingPid());
    LOG1("startRecording (pid %d)", CameraThreadState::getCallingPid());
    return startCameraMode(CAMERA_RECORDING_MODE);
}

@@ -460,7 +458,7 @@ status_t CameraClient::startRecordingMode() {

// stop preview mode
void CameraClient::stopPreview() {
    LOG1("stopPreview (pid %d)", getCallingPid());
    LOG1("stopPreview (pid %d)", CameraThreadState::getCallingPid());
    Mutex::Autolock lock(mLock);
    if (checkPidAndHardware() != NO_ERROR) return;

@@ -476,7 +474,7 @@ void CameraClient::stopPreview() {

// stop recording mode
void CameraClient::stopRecording() {
    LOG1("stopRecording (pid %d)", getCallingPid());
    LOG1("stopRecording (pid %d)", CameraThreadState::getCallingPid());
    {
        Mutex::Autolock lock(mLock);
        if (checkPidAndHardware() != NO_ERROR) return;
@@ -502,7 +500,7 @@ void CameraClient::releaseRecordingFrame(const sp<IMemory>& mem) {
    if (checkPidAndHardware() != NO_ERROR) return;
    if (mem == nullptr) {
        android_errorWriteWithInfoLog(CameraService::SN_EVENT_LOG_ID, "26164272",
                IPCThreadState::self()->getCallingUid(), nullptr, 0);
                CameraThreadState::getCallingUid(), nullptr, 0);
        return;
    }

@@ -614,7 +612,7 @@ status_t CameraClient::setVideoBufferMode(int32_t videoBufferMode) {
}

bool CameraClient::previewEnabled() {
    LOG1("previewEnabled (pid %d)", getCallingPid());
    LOG1("previewEnabled (pid %d)", CameraThreadState::getCallingPid());

    Mutex::Autolock lock(mLock);
    if (checkPidAndHardware() != NO_ERROR) return false;
@@ -622,7 +620,7 @@ bool CameraClient::previewEnabled() {
}

bool CameraClient::recordingEnabled() {
    LOG1("recordingEnabled (pid %d)", getCallingPid());
    LOG1("recordingEnabled (pid %d)", CameraThreadState::getCallingPid());

    Mutex::Autolock lock(mLock);
    if (checkPidAndHardware() != NO_ERROR) return false;
@@ -630,7 +628,7 @@ bool CameraClient::recordingEnabled() {
}

status_t CameraClient::autoFocus() {
    LOG1("autoFocus (pid %d)", getCallingPid());
    LOG1("autoFocus (pid %d)", CameraThreadState::getCallingPid());

    Mutex::Autolock lock(mLock);
    status_t result = checkPidAndHardware();
@@ -640,7 +638,7 @@ status_t CameraClient::autoFocus() {
}

status_t CameraClient::cancelAutoFocus() {
    LOG1("cancelAutoFocus (pid %d)", getCallingPid());
    LOG1("cancelAutoFocus (pid %d)", CameraThreadState::getCallingPid());

    Mutex::Autolock lock(mLock);
    status_t result = checkPidAndHardware();
@@ -651,7 +649,7 @@ status_t CameraClient::cancelAutoFocus() {

// take a picture - image is returned in callback
status_t CameraClient::takePicture(int msgType) {
    LOG1("takePicture (pid %d): 0x%x", getCallingPid(), msgType);
    LOG1("takePicture (pid %d): 0x%x", CameraThreadState::getCallingPid(), msgType);

    Mutex::Autolock lock(mLock);
    status_t result = checkPidAndHardware();
@@ -680,7 +678,7 @@ status_t CameraClient::takePicture(int msgType) {

// set preview/capture parameters - key/value pairs
status_t CameraClient::setParameters(const String8& params) {
    LOG1("setParameters (pid %d) (%s)", getCallingPid(), params.string());
    LOG1("setParameters (pid %d) (%s)", CameraThreadState::getCallingPid(), params.string());

    Mutex::Autolock lock(mLock);
    status_t result = checkPidAndHardware();
@@ -695,16 +693,18 @@ status_t CameraClient::setParameters(const String8& params) {
String8 CameraClient::getParameters() const {
    Mutex::Autolock lock(mLock);
    // The camera service can unconditionally get the parameters at all times
    if (getCallingPid() != mServicePid && checkPidAndHardware() != NO_ERROR) return String8();
    if (CameraThreadState::getCallingPid() != mServicePid && checkPidAndHardware() != NO_ERROR) {
        return String8();
    }

    String8 params(mHardware->getParameters().flatten());
    LOG1("getParameters (pid %d) (%s)", getCallingPid(), params.string());
    LOG1("getParameters (pid %d) (%s)", CameraThreadState::getCallingPid(), params.string());
    return params;
}

// enable shutter sound
status_t CameraClient::enableShutterSound(bool enable) {
    LOG1("enableShutterSound (pid %d)", getCallingPid());
    LOG1("enableShutterSound (pid %d)", CameraThreadState::getCallingPid());

    status_t result = checkPidAndHardware();
    if (result != NO_ERROR) return result;
@@ -719,7 +719,7 @@ status_t CameraClient::enableShutterSound(bool enable) {
}

status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
    LOG1("sendCommand (pid %d)", getCallingPid());
    LOG1("sendCommand (pid %d)", CameraThreadState::getCallingPid());
    int orientation;
    Mutex::Autolock lock(mLock);
    status_t result = checkPidAndHardware();
Loading