Fix clang-tidy warnings in camera.
* Add explicit keyword to conversion constructors.
Bug: 28341362
* Use const reference type for read-only parameters.
Bug: 30407689
* Use const reference type to avoid unnecessary copy.
Bug: 30413862
Test: build with WITH_TIDY=1
Change-Id: I71d3008da843ba5f1df1a73a320fb2af6ceffa16
diff --git a/services/camera/libcameraservice/common/Camera2ClientBase.h b/services/camera/libcameraservice/common/Camera2ClientBase.h
index 4f60034..dbbf638 100644
--- a/services/camera/libcameraservice/common/Camera2ClientBase.h
+++ b/services/camera/libcameraservice/common/Camera2ClientBase.h
@@ -93,13 +93,13 @@
public:
class Lock {
public:
- Lock(SharedCameraCallbacks &client);
+ explicit Lock(SharedCameraCallbacks &client);
~Lock();
sp<TCamCallbacks> &mRemoteCallback;
private:
SharedCameraCallbacks &mSharedClient;
};
- SharedCameraCallbacks(const sp<TCamCallbacks>& client);
+ explicit SharedCameraCallbacks(const sp<TCamCallbacks>& client);
SharedCameraCallbacks& operator=(const sp<TCamCallbacks>& client);
void clear();
private:
diff --git a/services/camera/libcameraservice/common/CameraModule.h b/services/camera/libcameraservice/common/CameraModule.h
index 1a1c274..d131a26 100644
--- a/services/camera/libcameraservice/common/CameraModule.h
+++ b/services/camera/libcameraservice/common/CameraModule.h
@@ -32,7 +32,7 @@
*/
class CameraModule {
public:
- CameraModule(camera_module_t *module);
+ explicit CameraModule(camera_module_t *module);
virtual ~CameraModule();
// Must be called after construction
diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.cpp b/services/camera/libcameraservice/common/FrameProcessorBase.cpp
index 29eb78f..2ef3057 100644
--- a/services/camera/libcameraservice/common/FrameProcessorBase.cpp
+++ b/services/camera/libcameraservice/common/FrameProcessorBase.cpp
@@ -47,7 +47,7 @@
}
status_t FrameProcessorBase::registerListener(int32_t minId,
- int32_t maxId, wp<FilteredListener> listener, bool sendPartials) {
+ int32_t maxId, const wp<FilteredListener>& listener, bool sendPartials) {
Mutex::Autolock l(mInputMutex);
List<RangeListener>::iterator item = mRangeListeners.begin();
while (item != mRangeListeners.end()) {
@@ -70,7 +70,7 @@
status_t FrameProcessorBase::removeListener(int32_t minId,
int32_t maxId,
- wp<FilteredListener> listener) {
+ const wp<FilteredListener>& listener) {
Mutex::Autolock l(mInputMutex);
List<RangeListener>::iterator item = mRangeListeners.begin();
while (item != mRangeListeners.end()) {
diff --git a/services/camera/libcameraservice/common/FrameProcessorBase.h b/services/camera/libcameraservice/common/FrameProcessorBase.h
index a618d84..00763a4 100644
--- a/services/camera/libcameraservice/common/FrameProcessorBase.h
+++ b/services/camera/libcameraservice/common/FrameProcessorBase.h
@@ -36,7 +36,7 @@
*/
class FrameProcessorBase: public Thread {
public:
- FrameProcessorBase(wp<CameraDeviceBase> device);
+ explicit FrameProcessorBase(wp<CameraDeviceBase> device);
virtual ~FrameProcessorBase();
struct FilteredListener: virtual public RefBase {
@@ -48,10 +48,10 @@
// the same range of IDs has no effect.
// sendPartials controls whether partial results will be sent.
status_t registerListener(int32_t minId, int32_t maxId,
- wp<FilteredListener> listener,
+ const wp<FilteredListener>& listener,
bool sendPartials = true);
status_t removeListener(int32_t minId, int32_t maxId,
- wp<FilteredListener> listener);
+ const wp<FilteredListener>& listener);
void dump(int fd, const Vector<String16>& args);
protected: