Fix google-explicit-constructor warnings in frameworks/rs.

 * Declare explicit conversion constructors.
 * Add NOLINT to implicit conversion constructors.

 Bug: 28341362
 Test: build with clang-tidy

Change-Id: If5114de668c1c8946b8fca9cee4b2b14f95be5f1
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index 1802386..a3e65ab 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -1412,7 +1412,7 @@
         bool mSkipPadding;
 
     public:
-        Builder(sp<RS> rs);
+        explicit Builder(sp<RS> rs);
         ~Builder();
         void add(sp<const Element> e, const char * name, uint32_t arraySize = 1);
         sp<const Element> create();
@@ -1428,7 +1428,7 @@
             uint32_t * arraySizes);
     Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
     Element(void *id, sp<RS> rs);
-    Element(sp<RS> rs);
+    explicit Element(sp<RS> rs);
     virtual ~Element();
 
 private:
@@ -1458,7 +1458,7 @@
     size_t mLen;
 
 public:
-    FieldPacker(size_t len)
+    explicit FieldPacker(size_t len)
         : mPos(0), mLen(len) {
             mData = new unsigned char[len];
         }
diff --git a/cpp/util/RefBase.h b/cpp/util/RefBase.h
index 01c0b5f..40bb7bc 100644
--- a/cpp/util/RefBase.h
+++ b/cpp/util/RefBase.h
@@ -202,12 +202,12 @@
 
     inline wp() : m_ptr(0) { }
 
-    wp(T* other);
+    explicit wp(T* other);
     wp(const wp<T>& other);
-    wp(const sp<T>& other);
-    template<typename U> wp(U* other);
-    template<typename U> wp(const sp<U>& other);
-    template<typename U> wp(const wp<U>& other);
+    explicit wp(const sp<T>& other);
+    template<typename U> explicit wp(U* other);
+    template<typename U> explicit wp(const sp<U>& other);
+    template<typename U> explicit wp(const wp<U>& other);
 
     ~wp();
 
diff --git a/cpp/util/StrongPointer.h b/cpp/util/StrongPointer.h
index 0f68615..a9995ba 100644
--- a/cpp/util/StrongPointer.h
+++ b/cpp/util/StrongPointer.h
@@ -65,10 +65,10 @@
 public:
     inline sp() : m_ptr(0) { }
 
-    sp(T* other);
+    sp(T* other);  // NOLINT, implicit
     sp(const sp<T>& other);
-    template<typename U> sp(U* other);
-    template<typename U> sp(const sp<U>& other);
+    template<typename U> sp(U* other);  // NOLINT, implicit
+    template<typename U> sp(const sp<U>& other);  // NOLINT, implicit
 
     ~sp();
 
diff --git a/cpp/util/TypeHelpers.h b/cpp/util/TypeHelpers.h
index 33a5201..e738cd3 100644
--- a/cpp/util/TypeHelpers.h
+++ b/cpp/util/TypeHelpers.h
@@ -233,7 +233,7 @@
     key_value_pair_t() { }
     key_value_pair_t(const key_value_pair_t& o) : key(o.key), value(o.value) { }
     key_value_pair_t(const KEY& k, const VALUE& v) : key(k), value(v)  { }
-    key_value_pair_t(const KEY& k) : key(k) { }
+    explicit key_value_pair_t(const KEY& k) : key(k) { }
     inline bool operator < (const key_value_pair_t& o) const {
         return strictly_order_type(key, o.key);
     }
diff --git a/rsAllocation.h b/rsAllocation.h
index 4d09679..0f60150 100644
--- a/rsAllocation.h
+++ b/rsAllocation.h
@@ -223,7 +223,7 @@
 #if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
     class NewBufferListener : public android::ConsumerBase::FrameAvailableListener {
     public:
-        NewBufferListener(uint32_t numAlloc);
+        explicit NewBufferListener(uint32_t numAlloc);
         virtual ~NewBufferListener();
         const android::renderscript::Context *rsc;
         const android::renderscript::Allocation **alloc;
diff --git a/rsAnimation.h b/rsAnimation.h
index de4957e..f77d3cb 100644
--- a/rsAnimation.h
+++ b/rsAnimation.h
@@ -41,7 +41,7 @@
     static Animation *createFromStream(Context *rsc, IStream *stream);
 
 protected:
-    Animation(Context *rsc);
+    explicit Animation(Context *rsc);
 
 
 
diff --git a/rsContext.h b/rsContext.h
index 4a8cd29..fe771ec 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -102,7 +102,7 @@
 
     class PushState {
     public:
-        PushState(Context *);
+        explicit PushState(Context *);
         ~PushState();
 
     private:
diff --git a/rsCppUtils.h b/rsCppUtils.h
index 606046e..3da0d03 100644
--- a/rsCppUtils.h
+++ b/rsCppUtils.h
@@ -65,7 +65,7 @@
     // server has no Vector or String8 classes; implement on top of STL
     class String8: public std::string {
     public:
-    String8(const char *ptr) : std::string(ptr) {
+    explicit String8(const char *ptr) : std::string(ptr) {
 
         }
     String8(const char *ptr, size_t len) : std::string(ptr, len) {
diff --git a/rsElement.h b/rsElement.h
index 9374c64..d8f101b 100644
--- a/rsElement.h
+++ b/rsElement.h
@@ -152,7 +152,7 @@
 
 
     virtual ~Element();
-    Element(Context *);
+    explicit Element(Context *);
 
     Component mComponent;
     uint32_t mBitsUnpadded;
diff --git a/rsFileA3D.h b/rsFileA3D.h
index 8bf36b9..ae74455 100644
--- a/rsFileA3D.h
+++ b/rsFileA3D.h
@@ -32,7 +32,7 @@
 
 class FileA3D : public ObjectBase {
 public:
-    FileA3D(Context *rsc);
+    explicit FileA3D(Context *rsc);
     ~FileA3D();
 
     uint32_t mMajorVersion;
diff --git a/rsFont.h b/rsFont.h
index 0f17340..3be5c3c 100644
--- a/rsFont.h
+++ b/rsFont.h
@@ -116,7 +116,7 @@
     float mFontSize;
     uint32_t mDpi;
 
-    Font(Context *rsc);
+    explicit Font(Context *rsc);
     bool init(const char *name, float fontSize, uint32_t dpi, const void *data = nullptr, uint32_t dataLen = 0);
 
     virtual void preDestroy() const;
diff --git a/rsList.h b/rsList.h
index 24720a2..052ec77 100644
--- a/rsList.h
+++ b/rsList.h
@@ -92,7 +92,7 @@
         T* operator->() { return p; }
 
     protected:
-        iterator(const List* list_) : list(list_) {}
+        explicit iterator(const List* list_) : list(list_) {}
         iterator(const List* list_, LinkedBuffer* buffer_, T* p_) :
             p(p_), buffer(buffer_), list(list_) {}
 
diff --git a/rsMesh.h b/rsMesh.h
index c7ee088..6c60555 100644
--- a/rsMesh.h
+++ b/rsMesh.h
@@ -55,7 +55,7 @@
     };
     Hal mHal;
 
-    Mesh(Context *);
+    explicit Mesh(Context *);
     Mesh(Context *, uint32_t vertexBuffersCount, uint32_t primitivesCount);
     ~Mesh();
 
diff --git a/rsObjectBase.h b/rsObjectBase.h
index c51d85c..4f29e57 100644
--- a/rsObjectBase.h
+++ b/rsObjectBase.h
@@ -35,7 +35,7 @@
     static const bool gDebugLeaks = false;
     static const bool gDebugLifetime = false;
 
-    ObjectBase(Context *rsc);
+    ObjectBase(Context *rsc);  // NOLINT, implicit
 
     void incSysRef() const;
     bool decSysRef() const;
@@ -111,7 +111,7 @@
         }
     }
 
-    ObjectBaseRef(T *ref) {
+    ObjectBaseRef(T *ref) {  // NOLINT, implicit
         mRef = ref;
         if (mRef) {
             ref->incSysRef();
diff --git a/rsProgramBase.h b/rsProgramBase.h
index 80da453..aeee5c1 100644
--- a/rsProgramBase.h
+++ b/rsProgramBase.h
@@ -26,7 +26,7 @@
 
 class ProgramBase : public ObjectBase {
 public:
-    ProgramBase(Context *rsc) : ObjectBase(rsc) {
+    explicit ProgramBase(Context *rsc) : ObjectBase(rsc) {
         mDirty = true;
     }
 
diff --git a/rsSampler.h b/rsSampler.h
index 2fdf707..c63a4a8 100644
--- a/rsSampler.h
+++ b/rsSampler.h
@@ -74,7 +74,7 @@
     virtual ~Sampler();
 
 private:
-    Sampler(Context *);
+    explicit Sampler(Context *);
     Sampler(Context *,
             RsSamplerValue magFilter,
             RsSamplerValue minFilter,
diff --git a/rsScript.h b/rsScript.h
index e336f07..39620c1 100644
--- a/rsScript.h
+++ b/rsScript.h
@@ -98,7 +98,7 @@
     };
     Hal mHal;
 
-    Script(Context *);
+    explicit Script(Context *);
     virtual ~Script();
 
     struct Enviroment_t {
diff --git a/rsScriptC.h b/rsScriptC.h
index 6c34215..3c342d4 100644
--- a/rsScriptC.h
+++ b/rsScriptC.h
@@ -31,7 +31,7 @@
     typedef int (*RunScript_t)();
     typedef void (*VoidFunc_t)();
 
-    ScriptC(Context *);
+    explicit ScriptC(Context *);
     virtual ~ScriptC();
 
     void Invoke(Context *rsc, uint32_t slot, const void *data, size_t len) override;
diff --git a/rsScriptGroup.h b/rsScriptGroup.h
index 68783f3..835d8c0 100644
--- a/rsScriptGroup.h
+++ b/rsScriptGroup.h
@@ -56,7 +56,7 @@
 
     class Node {
     public:
-        Node(Script *);
+        explicit Node(Script *);
 
         Vector<const ScriptKernelID *> mKernels;
         Vector<Link *> mOutputs;
@@ -68,7 +68,7 @@
 
     class IO {
     public:
-        IO(const ScriptKernelID *);
+        explicit IO(const ScriptKernelID *);
 
         const ScriptKernelID *mKernel;
         ObjectBaseRef<Allocation> mAlloc;
@@ -103,7 +103,7 @@
     // executes. Skips the exeuction if validation fails.
     bool validateInputAndOutput(Context *);
 
-    ScriptGroup(Context *);
+    explicit ScriptGroup(Context *);
 };
 
 
diff --git a/rsScriptGroupBase.h b/rsScriptGroupBase.h
index 00ae6c6..f79f08f 100644
--- a/rsScriptGroupBase.h
+++ b/rsScriptGroupBase.h
@@ -8,7 +8,7 @@
 
 class ScriptGroupBase : public ObjectBase {
  public:
-  ScriptGroupBase(Context* rsc) : ObjectBase(rsc) {}
+  explicit ScriptGroupBase(Context* rsc) : ObjectBase(rsc) {}
   virtual ~ScriptGroupBase() {}
 
   virtual void serialize(Context *rsc, OStream *stream) const {}
diff --git a/rsScriptIntrinsic.h b/rsScriptIntrinsic.h
index 9b4f9d3..cd8253d 100644
--- a/rsScriptIntrinsic.h
+++ b/rsScriptIntrinsic.h
@@ -30,7 +30,7 @@
 
     ObjectBaseRef<const Element> mElement;
 
-    ScriptIntrinsic(Context *);
+    explicit ScriptIntrinsic(Context *);
     ~ScriptIntrinsic() override;
 
     bool init(Context *rsc, RsScriptIntrinsicID iid, Element *e);
diff --git a/rsType.h b/rsType.h
index 6ae8446..6e260fa 100644
--- a/rsType.h
+++ b/rsType.h
@@ -150,7 +150,7 @@
     virtual ~Type();
 
 private:
-    Type(Context *);
+    explicit Type(Context *);
     Type(const Type &);
 };