diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index d68124660a51e..01c2a0b50c62f 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -373,7 +373,7 @@ using namespace android; // on the caller already having a local JNI ref class LocalScopedBitmap { public: - LocalScopedBitmap(jlong bitmapHandle) + explicit LocalScopedBitmap(jlong bitmapHandle) : mBitmap(reinterpret_cast(bitmapHandle)) {} Bitmap* operator->() { diff --git a/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp b/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp index 731d22ada7102..aa6348ee2a31f 100644 --- a/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp +++ b/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp @@ -50,7 +50,7 @@ static const bool kDebugGlyphs = false; // calls. See the Harfbuzz source for references about what these callbacks do. struct HarfBuzzFontData { - HarfBuzzFontData(SkPaint* paint) : m_paint(paint) { } + explicit HarfBuzzFontData(SkPaint* paint) : m_paint(paint) { } SkPaint* m_paint; }; diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp index 0c30fdc63905f..2bffaf01fb741 100644 --- a/core/jni/android/graphics/Region.cpp +++ b/core/jni/android/graphics/Region.cpp @@ -266,7 +266,7 @@ struct RgnIterPair { SkRegion fRgn; // a copy of the caller's region SkRegion::Iterator fIter; // an iterator acting upon the copy (fRgn) - RgnIterPair(const SkRegion& rgn) : fRgn(rgn) { + explicit RgnIterPair(const SkRegion& rgn) : fRgn(rgn) { // have our iterator reference our copy (fRgn), so we know it will be // unchanged for the lifetime of the iterator fIter.reset(fRgn); diff --git a/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp b/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp index f0420585bfa4c..a08166568c9f1 100644 --- a/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp +++ b/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp @@ -114,7 +114,7 @@ class PerfMeasurementContext { * will be active at once, which is a function of the GPU's level of * pipelining and the frequency of queries. */ - PerfMeasurementContext(size_t maxQueryCount): + explicit PerfMeasurementContext(size_t maxQueryCount): mTimingStartIndex(0), mTimingEndIndex(0), mTimingQueryIndex(0) { diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 3473d9dab732f..1e6b125b0e961 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -1112,7 +1112,7 @@ static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz, class XmlAttributeFinder : public BackTrackingAttributeFinder { public: - XmlAttributeFinder(const ResXMLParser* parser) + explicit XmlAttributeFinder(const ResXMLParser* parser) : BackTrackingAttributeFinder(0, parser != NULL ? parser->getAttributeCount() : 0) , mParser(parser) {} diff --git a/core/jni/android_view_GraphicBuffer.cpp b/core/jni/android_view_GraphicBuffer.cpp index 7682dd6ca8e3b..ea0d4a356c7f5 100644 --- a/core/jni/android_view_GraphicBuffer.cpp +++ b/core/jni/android_view_GraphicBuffer.cpp @@ -88,7 +88,7 @@ static struct { class GraphicBufferWrapper { public: - GraphicBufferWrapper(const sp& buffer): buffer(buffer) { + explicit GraphicBufferWrapper(const sp& buffer): buffer(buffer) { } sp buffer; diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp index 092ac27176cc8..c7998a169225f 100644 --- a/core/jni/android_view_InputChannel.cpp +++ b/core/jni/android_view_InputChannel.cpp @@ -43,7 +43,7 @@ static struct { class NativeInputChannel { public: - NativeInputChannel(const sp& inputChannel); + explicit NativeInputChannel(const sp& inputChannel); ~NativeInputChannel(); inline sp getInputChannel() { return mInputChannel; } diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp index 9a545e9f72723..7717143fbe2a0 100644 --- a/core/jni/android_view_ThreadedRenderer.cpp +++ b/core/jni/android_view_ThreadedRenderer.cpp @@ -107,7 +107,7 @@ public: class InvokeAnimationListeners : public MessageHandler { public: - InvokeAnimationListeners(std::vector& events) { + explicit InvokeAnimationListeners(std::vector& events) { mOnFinishedEvents.swap(events); } @@ -147,7 +147,7 @@ private: class RootRenderNode : public RenderNode, ErrorHandler { public: - RootRenderNode(JNIEnv* env) : RenderNode() { + explicit RootRenderNode(JNIEnv* env) : RenderNode() { mLooper = Looper::getForThread(); LOG_ALWAYS_FATAL_IF(!mLooper.get(), "Must create RootRenderNode on a thread with a looper!"); @@ -250,7 +250,7 @@ private: class ContextFactoryImpl : public IContextFactory { public: - ContextFactoryImpl(RootRenderNode* rootNode) : mRootNode(rootNode) {} + explicit ContextFactoryImpl(RootRenderNode* rootNode) : mRootNode(rootNode) {} virtual AnimationContext* createAnimationContext(renderthread::TimeLord& clock) { return new AnimationContextBridge(clock, mRootNode); diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp index 04ec7059365e4..e1f2241bfd474 100644 --- a/core/jni/android_view_VelocityTracker.cpp +++ b/core/jni/android_view_VelocityTracker.cpp @@ -45,7 +45,7 @@ static struct { class VelocityTrackerState { public: - VelocityTrackerState(const char* strategy); + explicit VelocityTrackerState(const char* strategy); void clear(); void addMovement(const MotionEvent* event); diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index c3dfb89180de6..c3aa438a9241a 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -3116,7 +3116,7 @@ String8 ResTable_config::toString() const { struct ResTable::Header { - Header(ResTable* _owner) : owner(_owner), ownedData(NULL), header(NULL), + explicit Header(ResTable* _owner) : owner(_owner), ownedData(NULL), header(NULL), resourceIDMap(NULL), resourceIDMapSize(0) { } ~Header() diff --git a/libs/androidfw/ZipUtils.cpp b/libs/androidfw/ZipUtils.cpp index 6fa0f14ecb8e7..5abfc8ee917e9 100644 --- a/libs/androidfw/ZipUtils.cpp +++ b/libs/androidfw/ZipUtils.cpp @@ -150,7 +150,7 @@ bail: class FileReader { public: - FileReader(FILE* fp) : + explicit FileReader(FILE* fp) : mFp(fp), mReadBuf(new unsigned char[kReadBufSize]) { } @@ -170,7 +170,7 @@ public: class FdReader { public: - FdReader(int fd) : + explicit FdReader(int fd) : mFd(fd), mReadBuf(new unsigned char[kReadBufSize]) { } diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp index f170e9cda8afa..9d5860ca0d1a0 100644 --- a/libs/hwui/AnimatorManager.cpp +++ b/libs/hwui/AnimatorManager.cpp @@ -168,7 +168,7 @@ void AnimatorManager::endAllStagingAnimators() { class EndActiveAnimatorsFunctor { public: - EndActiveAnimatorsFunctor(AnimationContext& context) : mContext(context) {} + explicit EndActiveAnimatorsFunctor(AnimationContext& context) : mContext(context) {} void operator() (sp& animator) { animator->forceEndNow(mContext); diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp index 1b0f42466bff0..689179dd8fb43 100644 --- a/libs/hwui/DeferredDisplayList.cpp +++ b/libs/hwui/DeferredDisplayList.cpp @@ -62,7 +62,7 @@ public: class DrawBatch : public Batch { public: - DrawBatch(const DeferInfo& deferInfo) : mAllOpsOpaque(true), + explicit DrawBatch(const DeferInfo& deferInfo) : mAllOpsOpaque(true), mBatchId(deferInfo.batchId), mMergeId(deferInfo.mergeId) { mOps.clear(); } diff --git a/libs/hwui/SkiaCanvas.cpp b/libs/hwui/SkiaCanvas.cpp index ce67554645d13..0693804d57700 100644 --- a/libs/hwui/SkiaCanvas.cpp +++ b/libs/hwui/SkiaCanvas.cpp @@ -208,7 +208,7 @@ SkiaCanvas::SkiaCanvas(const SkBitmap& bitmap) { class ClipCopier : public SkCanvas::ClipVisitor { public: - ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {} + explicit ClipCopier(SkCanvas* dstCanvas) : m_dstCanvas(dstCanvas) {} virtual void clipRect(const SkRect& rect, SkRegion::Op op, bool antialias) { m_dstCanvas->clipRect(rect, op, antialias); diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp index cfdc0848c8b0b..d9e811684610f 100644 --- a/libs/hwui/TessellationCache.cpp +++ b/libs/hwui/TessellationCache.cpp @@ -136,7 +136,7 @@ public: class TessellationCache::TessellationProcessor : public TaskProcessor { public: - TessellationProcessor(Caches& caches) + explicit TessellationProcessor(Caches& caches) : TaskProcessor(&caches.tasks) {} ~TessellationProcessor() {} @@ -150,7 +150,7 @@ public: class TessellationCache::Buffer { public: - Buffer(const sp >& task) + explicit Buffer(const sp >& task) : mTask(task) , mBuffer(nullptr) { } @@ -270,7 +270,7 @@ void tessellateShadows( class ShadowProcessor : public TaskProcessor { public: - ShadowProcessor(Caches& caches) + explicit ShadowProcessor(Caches& caches) : TaskProcessor(&caches.tasks) {} ~ShadowProcessor() {} diff --git a/libs/hwui/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp index ea4391b870068..9b8661132d526 100644 --- a/libs/hwui/renderstate/RenderState.cpp +++ b/libs/hwui/renderstate/RenderState.cpp @@ -211,7 +211,7 @@ void RenderState::debugOverdraw(bool enable, bool clear) { class DecStrongTask : public renderthread::RenderTask { public: - DecStrongTask(VirtualLightRefBase* object) : mObject(object) {} + explicit DecStrongTask(VirtualLightRefBase* object) : mObject(object) {} virtual void run() override { mObject->decStrong(nullptr); diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 9fb30c928c005..3c1c0bceba582 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -128,7 +128,7 @@ class DispatchFrameCallbacks : public RenderTask { private: RenderThread* mRenderThread; public: - DispatchFrameCallbacks(RenderThread* rt) : mRenderThread(rt) {} + explicit DispatchFrameCallbacks(RenderThread* rt) : mRenderThread(rt) {} virtual void run() override { mRenderThread->dispatchFrameCallbacks(); diff --git a/libs/storage/IMountService.cpp b/libs/storage/IMountService.cpp index c643ed008a3b3..74638e7eccc35 100644 --- a/libs/storage/IMountService.cpp +++ b/libs/storage/IMountService.cpp @@ -55,7 +55,7 @@ enum { class BpMountService: public BpInterface { public: - BpMountService(const sp& impl) + explicit BpMountService(const sp& impl) : BpInterface(impl) { } diff --git a/libs/storage/IObbActionListener.cpp b/libs/storage/IObbActionListener.cpp index 9656e655e22ce..a71341bc13646 100644 --- a/libs/storage/IObbActionListener.cpp +++ b/libs/storage/IObbActionListener.cpp @@ -26,7 +26,7 @@ enum { // This is a stub that real consumers should override. class BpObbActionListener: public BpInterface { public: - BpObbActionListener(const sp& impl) + explicit BpObbActionListener(const sp& impl) : BpInterface(impl) { } diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp index 5f007396f2878..096120e5a26d0 100644 --- a/media/mca/filterfw/jni/jni_gl_environment.cpp +++ b/media/mca/filterfw/jni/jni_gl_environment.cpp @@ -39,7 +39,7 @@ using android::Surface; class NativeWindowHandle : public WindowHandle { public: - NativeWindowHandle(ANativeWindow* window) : window_(window) { + explicit NativeWindowHandle(ANativeWindow* window) : window_(window) { } virtual ~NativeWindowHandle() { diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp index dee3f8c700edd..0e5e5c60d506a 100644 --- a/native/android/asset_manager.cpp +++ b/native/android/asset_manager.cpp @@ -39,7 +39,7 @@ struct AAssetDir { size_t mCurFileIndex; String8 mCachedFileName; - AAssetDir(AssetDir* dir) : mAssetDir(dir), mCurFileIndex(0) { } + explicit AAssetDir(AssetDir* dir) : mAssetDir(dir), mCurFileIndex(0) { } ~AAssetDir() { delete mAssetDir; } }; @@ -48,7 +48,7 @@ struct AAssetDir { struct AAsset { Asset* mAsset; - AAsset(Asset* asset) : mAsset(asset) { } + explicit AAsset(Asset* asset) : mAsset(asset) { } ~AAsset() { delete mAsset; } }; diff --git a/native/android/choreographer.cpp b/native/android/choreographer.cpp index e35c85b883e8a..c3629da1cb121 100644 --- a/native/android/choreographer.cpp +++ b/native/android/choreographer.cpp @@ -64,7 +64,7 @@ protected: virtual ~Choreographer() = default; private: - Choreographer(const sp& looper); + explicit Choreographer(const sp& looper); Choreographer(const Choreographer&) = delete; virtual void dispatchVsync(nsecs_t timestamp, int32_t id, uint32_t count); diff --git a/native/android/storage_manager.cpp b/native/android/storage_manager.cpp index 399f1ffcb594c..137b72cf14e32 100644 --- a/native/android/storage_manager.cpp +++ b/native/android/storage_manager.cpp @@ -37,7 +37,7 @@ private: sp mStorageManager; public: - ObbActionListener(AStorageManager* mgr) : + explicit ObbActionListener(AStorageManager* mgr) : mStorageManager(mgr) {} diff --git a/services/core/jni/com_android_server_AlarmManagerService.cpp b/services/core/jni/com_android_server_AlarmManagerService.cpp index 246ab0d259f4e..407c0726e5212 100644 --- a/services/core/jni/com_android_server_AlarmManagerService.cpp +++ b/services/core/jni/com_android_server_AlarmManagerService.cpp @@ -74,7 +74,7 @@ protected: class AlarmImplAlarmDriver : public AlarmImpl { public: - AlarmImplAlarmDriver(int fd) : AlarmImpl(&fd, 1) { } + explicit AlarmImplAlarmDriver(int fd) : AlarmImpl(&fd, 1) { } int set(int type, struct timespec *ts); int setTime(struct timeval *tv); diff --git a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp index 656c2141ff2ee..c389a94f84a45 100644 --- a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp +++ b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp @@ -84,7 +84,7 @@ private: // it to service thread. class CecEventWrapper : public LightRefBase { public: - CecEventWrapper(const hdmi_event_t& event) { + explicit CecEventWrapper(const hdmi_event_t& event) { // Copy message. switch (event.type) { case HDMI_EVENT_CEC_MESSAGE: