Loading services/camera/libcameraservice/CameraService.cpp +97 −69 Original line number Diff line number Diff line Loading @@ -140,14 +140,29 @@ void CameraService::onFirstRef() BnCameraService::onFirstRef(); camera_module_t *rawModule; if (hw_get_module(CAMERA_HARDWARE_MODULE_ID, (const hw_module_t **)&rawModule) < 0) { ALOGE("Could not load camera HAL module"); int err = hw_get_module(CAMERA_HARDWARE_MODULE_ID, (const hw_module_t **)&rawModule); if (err < 0) { ALOGE("Could not load camera HAL module: %d (%s)", err, strerror(-err)); logServiceError("Could not load camera HAL module", err); mNumberOfCameras = 0; return; } else { mModule = new CameraModule(rawModule); ALOGI("Loaded \"%s\" camera module", mModule->getModuleName()); err = mModule->init(); if (err != OK) { ALOGE("Could not initialize camera HAL module: %d (%s)", err, strerror(-err)); logServiceError("Could not initialize camera HAL module", err); mNumberOfCameras = 0; delete mModule; mModule = nullptr; return; } mNumberOfCameras = mModule->getNumberOfCameras(); mFlashlight = new CameraFlashlight(*mModule, *this); Loading Loading @@ -210,7 +225,6 @@ void CameraService::onFirstRef() CameraDeviceFactory::registerService(this); } } CameraService::~CameraService() { if (mModule) { Loading Loading @@ -1553,6 +1567,11 @@ void CameraService::logClientDied(int clientPid, const char* reason) { logEvent(String8::format("DIED client(s) with PID %d, reason: (%s)", clientPid, reason)); } void CameraService::logServiceError(const char* msg, int errorCode) { String8 curTime = getFormattedCurrentTime(); logEvent(String8::format("SERVICE ERROR: %s : %d (%s)", msg, errorCode, strerror(errorCode))); } status_t CameraService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { Loading Loading @@ -1995,6 +2014,10 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) { if (!mModule) { result = String8::format("No camera module available!\n"); write(fd, result.string(), result.size()); // Dump event log for error information dumpEventLog(fd); if (locked) mServiceLock.unlock(); return NO_ERROR; } Loading @@ -2020,20 +2043,7 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) { desc->dump(fd, /*verbosity*/2, /*indentation*/4); } result = String8("Prior client events (most recent at top):\n"); { Mutex::Autolock l(mLogLock); for (const auto& msg : mEventLog) { result.appendFormat("%s\n", msg.string()); } if (mEventLog.size() == DEFAULT_EVENT_LOG_LENGTH) { result.append("...\n"); } } write(fd, result.string(), result.size()); dumpEventLog(fd); bool stateLocked = tryLock(mCameraStatesLock); if (!stateLocked) { Loading Loading @@ -2141,6 +2151,24 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) { return NO_ERROR; } void CameraService::dumpEventLog(int fd) { String8 result = String8("\nPrior client events (most recent at top):\n"); Mutex::Autolock l(mLogLock); for (const auto& msg : mEventLog) { result.appendFormat(" %s\n", msg.string()); } if (mEventLog.size() == DEFAULT_EVENT_LOG_LENGTH) { result.append(" ...\n"); } else if (mEventLog.size() == 0) { result.append(" [no events yet]\n"); } result.append("\n"); write(fd, result.string(), result.size()); } void CameraService::handleTorchClientBinderDied(const wp<IBinder> &who) { Mutex::Autolock al(mTorchClientMapMutex); for (size_t i = 0; i < mTorchClientMap.size(); i++) { Loading services/camera/libcameraservice/CameraService.h +10 −0 Original line number Diff line number Diff line Loading @@ -590,6 +590,16 @@ private: */ void logClientDied(int clientPid, const char* reason); /** * Add a event log message that a serious service-level error has occured */ void logServiceError(const char* msg, int errorCode); /** * Dump the event log to an FD */ void dumpEventLog(int fd); int mNumberOfCameras; // sounds Loading services/camera/libcameraservice/common/CameraModule.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -57,6 +57,14 @@ CameraModule::CameraModule(camera_module_t *module) { mCameraInfoMap.setCapacity(getNumberOfCameras()); } int CameraModule::init() { if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_4 && mModule->init != NULL) { return mModule->init(); } return OK; } int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { Mutex::Autolock lock(mCameraInfoLock); if (cameraId < 0) { Loading Loading @@ -98,7 +106,7 @@ int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { assert(index != NAME_NOT_FOUND); // return the cached camera info *info = mCameraInfoMap[index]; return 0; return OK; } int CameraModule::open(const char* id, struct hw_device_t** device) { Loading Loading @@ -166,4 +174,3 @@ void* CameraModule::getDso() { } }; // namespace android services/camera/libcameraservice/common/CameraModule.h +4 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ class CameraModule { public: CameraModule(camera_module_t *module); // Must be called after construction // Returns OK on success, NO_INIT on failure int init(); int getCameraInfo(int cameraId, struct camera_info *info); int getNumberOfCameras(void); int open(const char* id, struct hw_device_t** device); Loading Loading @@ -63,4 +67,3 @@ private: } // namespace android #endif Loading
services/camera/libcameraservice/CameraService.cpp +97 −69 Original line number Diff line number Diff line Loading @@ -140,14 +140,29 @@ void CameraService::onFirstRef() BnCameraService::onFirstRef(); camera_module_t *rawModule; if (hw_get_module(CAMERA_HARDWARE_MODULE_ID, (const hw_module_t **)&rawModule) < 0) { ALOGE("Could not load camera HAL module"); int err = hw_get_module(CAMERA_HARDWARE_MODULE_ID, (const hw_module_t **)&rawModule); if (err < 0) { ALOGE("Could not load camera HAL module: %d (%s)", err, strerror(-err)); logServiceError("Could not load camera HAL module", err); mNumberOfCameras = 0; return; } else { mModule = new CameraModule(rawModule); ALOGI("Loaded \"%s\" camera module", mModule->getModuleName()); err = mModule->init(); if (err != OK) { ALOGE("Could not initialize camera HAL module: %d (%s)", err, strerror(-err)); logServiceError("Could not initialize camera HAL module", err); mNumberOfCameras = 0; delete mModule; mModule = nullptr; return; } mNumberOfCameras = mModule->getNumberOfCameras(); mFlashlight = new CameraFlashlight(*mModule, *this); Loading Loading @@ -210,7 +225,6 @@ void CameraService::onFirstRef() CameraDeviceFactory::registerService(this); } } CameraService::~CameraService() { if (mModule) { Loading Loading @@ -1553,6 +1567,11 @@ void CameraService::logClientDied(int clientPid, const char* reason) { logEvent(String8::format("DIED client(s) with PID %d, reason: (%s)", clientPid, reason)); } void CameraService::logServiceError(const char* msg, int errorCode) { String8 curTime = getFormattedCurrentTime(); logEvent(String8::format("SERVICE ERROR: %s : %d (%s)", msg, errorCode, strerror(errorCode))); } status_t CameraService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { Loading Loading @@ -1995,6 +2014,10 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) { if (!mModule) { result = String8::format("No camera module available!\n"); write(fd, result.string(), result.size()); // Dump event log for error information dumpEventLog(fd); if (locked) mServiceLock.unlock(); return NO_ERROR; } Loading @@ -2020,20 +2043,7 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) { desc->dump(fd, /*verbosity*/2, /*indentation*/4); } result = String8("Prior client events (most recent at top):\n"); { Mutex::Autolock l(mLogLock); for (const auto& msg : mEventLog) { result.appendFormat("%s\n", msg.string()); } if (mEventLog.size() == DEFAULT_EVENT_LOG_LENGTH) { result.append("...\n"); } } write(fd, result.string(), result.size()); dumpEventLog(fd); bool stateLocked = tryLock(mCameraStatesLock); if (!stateLocked) { Loading Loading @@ -2141,6 +2151,24 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) { return NO_ERROR; } void CameraService::dumpEventLog(int fd) { String8 result = String8("\nPrior client events (most recent at top):\n"); Mutex::Autolock l(mLogLock); for (const auto& msg : mEventLog) { result.appendFormat(" %s\n", msg.string()); } if (mEventLog.size() == DEFAULT_EVENT_LOG_LENGTH) { result.append(" ...\n"); } else if (mEventLog.size() == 0) { result.append(" [no events yet]\n"); } result.append("\n"); write(fd, result.string(), result.size()); } void CameraService::handleTorchClientBinderDied(const wp<IBinder> &who) { Mutex::Autolock al(mTorchClientMapMutex); for (size_t i = 0; i < mTorchClientMap.size(); i++) { Loading
services/camera/libcameraservice/CameraService.h +10 −0 Original line number Diff line number Diff line Loading @@ -590,6 +590,16 @@ private: */ void logClientDied(int clientPid, const char* reason); /** * Add a event log message that a serious service-level error has occured */ void logServiceError(const char* msg, int errorCode); /** * Dump the event log to an FD */ void dumpEventLog(int fd); int mNumberOfCameras; // sounds Loading
services/camera/libcameraservice/common/CameraModule.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -57,6 +57,14 @@ CameraModule::CameraModule(camera_module_t *module) { mCameraInfoMap.setCapacity(getNumberOfCameras()); } int CameraModule::init() { if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_4 && mModule->init != NULL) { return mModule->init(); } return OK; } int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { Mutex::Autolock lock(mCameraInfoLock); if (cameraId < 0) { Loading Loading @@ -98,7 +106,7 @@ int CameraModule::getCameraInfo(int cameraId, struct camera_info *info) { assert(index != NAME_NOT_FOUND); // return the cached camera info *info = mCameraInfoMap[index]; return 0; return OK; } int CameraModule::open(const char* id, struct hw_device_t** device) { Loading Loading @@ -166,4 +174,3 @@ void* CameraModule::getDso() { } }; // namespace android
services/camera/libcameraservice/common/CameraModule.h +4 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,10 @@ class CameraModule { public: CameraModule(camera_module_t *module); // Must be called after construction // Returns OK on success, NO_INIT on failure int init(); int getCameraInfo(int cameraId, struct camera_info *info); int getNumberOfCameras(void); int open(const char* id, struct hw_device_t** device); Loading Loading @@ -63,4 +67,3 @@ private: } // namespace android #endif