Loading services/camera/libcameraservice/CameraServiceWatchdog.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -41,8 +41,10 @@ bool CameraServiceWatchdog::threadLoop() tidToCycleCounterMap[currentThreadId]++; if (tidToCycleCounterMap[currentThreadId] >= mMaxCycles) { ALOGW("CameraServiceWatchdog triggering kill for pid: %d", getpid()); kill(getpid(), SIGKILL); ALOGW("CameraServiceWatchdog triggering abort for pid: %d", getpid()); // We use abort here so we can get a tombstone for better // debugging. abort(); } } } Loading services/camera/libcameraservice/CameraServiceWatchdog.h +3 −4 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ * and single call monitoring differently. See function documentation for * more details. */ #pragma once #include <chrono> #include <thread> #include <time.h> Loading Loading @@ -61,7 +61,7 @@ public: /** Used to wrap monitored calls in start and stop functions using custom timer values */ template<typename T> auto watchThread(T func, uint32_t tid, uint32_t cycles, uint32_t cycleLength) { auto res = NULL; decltype(func()) res; if (cycles != mMaxCycles || cycleLength != mCycleLengthMs) { // Create another instance of the watchdog to prevent disruption Loading @@ -84,10 +84,9 @@ public: /** Used to wrap monitored calls in start and stop functions using class timer values */ template<typename T> auto watchThread(T func, uint32_t tid) { auto res = NULL; start(tid); res = func(); auto res = func(); stop(tid); return res; Loading services/camera/libcameraservice/common/Camera2ClientBase.cpp +13 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ #include "utils/CameraServiceProxyWrapper.h" namespace android { const static size_t kDisconnectTimeoutMs = 2500; using namespace camera2; // Interface used by CameraService Loading Loading @@ -144,6 +147,10 @@ status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr wp<NotificationListener> weakThis(this); res = mDevice->setNotifyCallback(weakThis); /** Start watchdog thread */ mCameraServiceWatchdog = new CameraServiceWatchdog(); mCameraServiceWatchdog->run("Camera2ClientBaseWatchdog"); return OK; } Loading Loading @@ -238,9 +245,14 @@ status_t Camera2ClientBase<TClientBase>::dumpDevice( // ICameraClient2BaseUser interface template <typename TClientBase> binder::Status Camera2ClientBase<TClientBase>::disconnect() { return mCameraServiceWatchdog->WATCH_CUSTOM_TIMER(disconnectImpl(), kDisconnectTimeoutMs / kCycleLengthMs, kCycleLengthMs); } template <typename TClientBase> binder::Status Camera2ClientBase<TClientBase>::disconnectImpl() { ATRACE_CALL(); ALOGD("Camera %s: start to disconnect", TClientBase::mCameraIdStr.string()); Mutex::Autolock icl(mBinderSerializationLock); Loading services/camera/libcameraservice/common/Camera2ClientBase.h +7 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include "common/CameraDeviceBase.h" #include "camera/CaptureResult.h" #include "CameraServiceWatchdog.h" namespace android { Loading Loading @@ -173,6 +174,12 @@ protected: private: template<typename TProviderPtr> status_t initializeImpl(TProviderPtr providerPtr, const String8& monitorTags); binder::Status disconnectImpl(); // Watchdog thread sp<CameraServiceWatchdog> mCameraServiceWatchdog; }; }; // namespace android Loading Loading
services/camera/libcameraservice/CameraServiceWatchdog.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -41,8 +41,10 @@ bool CameraServiceWatchdog::threadLoop() tidToCycleCounterMap[currentThreadId]++; if (tidToCycleCounterMap[currentThreadId] >= mMaxCycles) { ALOGW("CameraServiceWatchdog triggering kill for pid: %d", getpid()); kill(getpid(), SIGKILL); ALOGW("CameraServiceWatchdog triggering abort for pid: %d", getpid()); // We use abort here so we can get a tombstone for better // debugging. abort(); } } } Loading
services/camera/libcameraservice/CameraServiceWatchdog.h +3 −4 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ * and single call monitoring differently. See function documentation for * more details. */ #pragma once #include <chrono> #include <thread> #include <time.h> Loading Loading @@ -61,7 +61,7 @@ public: /** Used to wrap monitored calls in start and stop functions using custom timer values */ template<typename T> auto watchThread(T func, uint32_t tid, uint32_t cycles, uint32_t cycleLength) { auto res = NULL; decltype(func()) res; if (cycles != mMaxCycles || cycleLength != mCycleLengthMs) { // Create another instance of the watchdog to prevent disruption Loading @@ -84,10 +84,9 @@ public: /** Used to wrap monitored calls in start and stop functions using class timer values */ template<typename T> auto watchThread(T func, uint32_t tid) { auto res = NULL; start(tid); res = func(); auto res = func(); stop(tid); return res; Loading
services/camera/libcameraservice/common/Camera2ClientBase.cpp +13 −1 Original line number Diff line number Diff line Loading @@ -40,6 +40,9 @@ #include "utils/CameraServiceProxyWrapper.h" namespace android { const static size_t kDisconnectTimeoutMs = 2500; using namespace camera2; // Interface used by CameraService Loading Loading @@ -144,6 +147,10 @@ status_t Camera2ClientBase<TClientBase>::initializeImpl(TProviderPtr providerPtr wp<NotificationListener> weakThis(this); res = mDevice->setNotifyCallback(weakThis); /** Start watchdog thread */ mCameraServiceWatchdog = new CameraServiceWatchdog(); mCameraServiceWatchdog->run("Camera2ClientBaseWatchdog"); return OK; } Loading Loading @@ -238,9 +245,14 @@ status_t Camera2ClientBase<TClientBase>::dumpDevice( // ICameraClient2BaseUser interface template <typename TClientBase> binder::Status Camera2ClientBase<TClientBase>::disconnect() { return mCameraServiceWatchdog->WATCH_CUSTOM_TIMER(disconnectImpl(), kDisconnectTimeoutMs / kCycleLengthMs, kCycleLengthMs); } template <typename TClientBase> binder::Status Camera2ClientBase<TClientBase>::disconnectImpl() { ATRACE_CALL(); ALOGD("Camera %s: start to disconnect", TClientBase::mCameraIdStr.string()); Mutex::Autolock icl(mBinderSerializationLock); Loading
services/camera/libcameraservice/common/Camera2ClientBase.h +7 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include "common/CameraDeviceBase.h" #include "camera/CaptureResult.h" #include "CameraServiceWatchdog.h" namespace android { Loading Loading @@ -173,6 +174,12 @@ protected: private: template<typename TProviderPtr> status_t initializeImpl(TProviderPtr providerPtr, const String8& monitorTags); binder::Status disconnectImpl(); // Watchdog thread sp<CameraServiceWatchdog> mCameraServiceWatchdog; }; }; // namespace android Loading