Merge "AAPT: ProGuard config for components in main dex."
diff --git a/cmds/app_process/Android.mk b/cmds/app_process/Android.mk
index 3ae9e12..fae0400 100644
--- a/cmds/app_process/Android.mk
+++ b/cmds/app_process/Android.mk
@@ -53,7 +53,6 @@
     libutils \
     liblog \
     libbinder \
-    libnativeloader \
     libandroid_runtime \
     $(app_process_common_shared_libs) \
 
diff --git a/cmds/app_process/app_main.cpp b/cmds/app_process/app_main.cpp
index 7590325..2e02382 100644
--- a/cmds/app_process/app_main.cpp
+++ b/cmds/app_process/app_main.cpp
@@ -21,7 +21,6 @@
 #include <cutils/properties.h>
 #include <cutils/trace.h>
 #include <android_runtime/AndroidRuntime.h>
-#include <nativeloader/native_loader.h>
 #include <private/android_filesystem_config.h>  // for AID_SYSTEM
 
 namespace android {
@@ -305,7 +304,6 @@
     }
 
     if (zygote) {
-        InitializeNativeLoader();
         runtime.start("com.android.internal.os.ZygoteInit", args, zygote);
     } else if (className) {
         runtime.start("com.android.internal.os.RuntimeInit", args, zygote);
diff --git a/core/java/android/app/ApplicationLoaders.java b/core/java/android/app/ApplicationLoaders.java
index b20c091..d633e02 100644
--- a/core/java/android/app/ApplicationLoaders.java
+++ b/core/java/android/app/ApplicationLoaders.java
@@ -18,6 +18,7 @@
 
 import android.os.Trace;
 import android.util.ArrayMap;
+import com.android.internal.os.PathClassLoaderFactory;
 import dalvik.system.PathClassLoader;
 
 class ApplicationLoaders {
@@ -51,24 +52,19 @@
                 if (loader != null) {
                     return loader;
                 }
-    
+
                 Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, zip);
 
-                PathClassLoader pathClassloader =
-                    new PathClassLoader(zip, librarySearchPath, parent);
+                PathClassLoader pathClassloader = PathClassLoaderFactory.createClassLoader(
+                                                      zip,
+                                                      librarySearchPath,
+                                                      libraryPermittedPath,
+                                                      parent,
+                                                      targetSdkVersion,
+                                                      isBundled);
 
-                String errorMessage = createClassloaderNamespace(pathClassloader,
-                                                                 targetSdkVersion,
-                                                                 librarySearchPath,
-                                                                 libraryPermittedPath,
-                                                                 isBundled);
                 Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
 
-                if (errorMessage != null) {
-                    throw new UnsatisfiedLinkError("Unable to create namespace for the classloader " +
-                                                   pathClassloader + ": " + errorMessage);
-                }
-
                 mLoaders.put(zip, pathClassloader);
                 return pathClassloader;
             }
@@ -80,14 +76,7 @@
         }
     }
 
-    private static native String createClassloaderNamespace(ClassLoader classLoader,
-                                                            int targetSdkVersion,
-                                                            String librarySearchPath,
-                                                            String libraryPermittedPath,
-                                                            boolean isShared);
-
     private final ArrayMap<String, ClassLoader> mLoaders = new ArrayMap<String, ClassLoader>();
 
-    private static final ApplicationLoaders gApplicationLoaders
-        = new ApplicationLoaders();
+    private static final ApplicationLoaders gApplicationLoaders = new ApplicationLoaders();
 }
diff --git a/core/java/com/android/internal/os/PathClassLoaderFactory.java b/core/java/com/android/internal/os/PathClassLoaderFactory.java
new file mode 100644
index 0000000..e5d3694
--- /dev/null
+++ b/core/java/com/android/internal/os/PathClassLoaderFactory.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.internal.os;
+
+import dalvik.system.PathClassLoader;
+
+/**
+ * Creates path class loaders.
+ *
+ * @hide
+ */
+public class PathClassLoaderFactory {
+    // Unconstructable
+    private PathClassLoaderFactory() {}
+
+    /**
+     * Create a PathClassLoader and initialize a linker-namespace for it.
+     *
+     * @hide
+     */
+    public static PathClassLoader createClassLoader(String dexPath,
+                                                    String librarySearchPath,
+                                                    String libraryPermittedPath,
+                                                    ClassLoader parent,
+                                                    int targetSdkVersion,
+                                                    boolean isNamespaceShared) {
+        PathClassLoader pathClassloader = new PathClassLoader(dexPath, librarySearchPath, parent);
+
+        String errorMessage = createClassloaderNamespace(pathClassloader,
+                                                         targetSdkVersion,
+                                                         librarySearchPath,
+                                                         libraryPermittedPath,
+                                                         isNamespaceShared);
+
+        if (errorMessage != null) {
+            throw new UnsatisfiedLinkError("Unable to create namespace for the classloader " +
+                                           pathClassloader + ": " + errorMessage);
+        }
+
+        return pathClassloader;
+    }
+
+    private static native String createClassloaderNamespace(ClassLoader classLoader,
+                                                            int targetSdkVersion,
+                                                            String librarySearchPath,
+                                                            String libraryPermittedPath,
+                                                            boolean isNamespaceShared);
+}
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index a91ad51..d84cb80 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -458,7 +458,9 @@
         } else {
             ClassLoader cl = null;
             if (systemServerClasspath != null) {
-                cl = new PathClassLoader(systemServerClasspath, ClassLoader.getSystemClassLoader());
+                cl = createSystemServerClassLoader(systemServerClasspath,
+                                                   parsedArgs.targetSdkVersion);
+
                 Thread.currentThread().setContextClassLoader(cl);
             }
 
@@ -472,6 +474,23 @@
     }
 
     /**
+     * Creates a PathClassLoader for the system server. It also creates
+     * a shared namespace associated with the classloader to let it access
+     * platform-private native libraries.
+     */
+    private static PathClassLoader createSystemServerClassLoader(String systemServerClasspath,
+                                                                 int targetSdkVersion) {
+      String librarySearchPath = System.getProperty("java.library.path");
+
+      return PathClassLoaderFactory.createClassLoader(systemServerClasspath,
+                                                      librarySearchPath,
+                                                      null /* libraryPermittedPath */,
+                                                      ClassLoader.getSystemClassLoader(),
+                                                      targetSdkVersion,
+                                                      true /* isNamespaceShared */);
+    }
+
+    /**
      * Performs dex-opt on the elements of {@code classPath}, if needed. We
      * choose the instruction set of the current runtime.
      */
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 9e58944..ef83998 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -32,7 +32,6 @@
     com_android_internal_content_NativeLibraryHelper.cpp \
     com_google_android_gles_jni_EGLImpl.cpp \
     com_google_android_gles_jni_GLImpl.cpp.arm \
-    android_app_ApplicationLoaders.cpp \
     android_app_NativeActivity.cpp \
     android_opengl_EGL14.cpp \
     android_opengl_EGLExt.cpp \
@@ -173,6 +172,7 @@
     android_content_res_Configuration.cpp \
     android_animation_PropertyValuesHolder.cpp \
     com_android_internal_net_NetworkStatsFactory.cpp \
+    com_android_internal_os_PathClassLoaderFactory.cpp \
     com_android_internal_os_Zygote.cpp \
     com_android_internal_util_VirtualRefBasePtr.cpp \
     com_android_internal_view_animation_NativeInterpolatorFactoryHelper.cpp
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 1fec627..28a0784 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -173,7 +173,6 @@
 extern int register_android_backup_FileBackupHelperBase(JNIEnv *env);
 extern int register_android_backup_BackupHelperDispatcher(JNIEnv *env);
 extern int register_android_app_backup_FullBackup(JNIEnv *env);
-extern int register_android_app_ApplicationLoaders(JNIEnv* env);
 extern int register_android_app_ActivityThread(JNIEnv *env);
 extern int register_android_app_NativeActivity(JNIEnv *env);
 extern int register_android_media_RemoteDisplay(JNIEnv *env);
@@ -193,6 +192,7 @@
 extern int register_android_animation_PropertyValuesHolder(JNIEnv *env);
 extern int register_com_android_internal_content_NativeLibraryHelper(JNIEnv *env);
 extern int register_com_android_internal_net_NetworkStatsFactory(JNIEnv *env);
+extern int register_com_android_internal_os_PathClassLoaderFactory(JNIEnv* env);
 extern int register_com_android_internal_os_Zygote(JNIEnv *env);
 extern int register_com_android_internal_util_VirtualRefBasePtr(JNIEnv *env);
 
@@ -1338,6 +1338,7 @@
     REG_JNI(register_android_net_NetworkUtils),
     REG_JNI(register_android_net_TrafficStats),
     REG_JNI(register_android_os_MemoryFile),
+    REG_JNI(register_com_android_internal_os_PathClassLoaderFactory),
     REG_JNI(register_com_android_internal_os_Zygote),
     REG_JNI(register_com_android_internal_util_VirtualRefBasePtr),
     REG_JNI(register_android_hardware_Camera),
@@ -1368,7 +1369,6 @@
     REG_JNI(register_android_backup_FileBackupHelperBase),
     REG_JNI(register_android_backup_BackupHelperDispatcher),
     REG_JNI(register_android_app_backup_FullBackup),
-    REG_JNI(register_android_app_ApplicationLoaders),
     REG_JNI(register_android_app_ActivityThread),
     REG_JNI(register_android_app_NativeActivity),
     REG_JNI(register_android_util_jar_StrictJarFile),
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index a805b6d..167294e 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -380,7 +380,7 @@
 // on the caller already having a local JNI ref
 class LocalScopedBitmap {
 public:
-    LocalScopedBitmap(jlong bitmapHandle)
+    explicit LocalScopedBitmap(jlong bitmapHandle)
             : mBitmap(reinterpret_cast<Bitmap*>(bitmapHandle)) {}
 
     Bitmap* operator->() {
diff --git a/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp b/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp
index e537942..939249a 100644
--- a/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp
+++ b/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp
@@ -50,7 +50,7 @@
 // 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 bcd0b60..b7d6524 100644
--- a/core/jni/android/graphics/Region.cpp
+++ b/core/jni/android/graphics/Region.cpp
@@ -268,7 +268,7 @@
     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 f042058..a081665 100644
--- a/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp
+++ b/core/jni/android_hardware_camera2_legacy_PerfMeasurement.cpp
@@ -114,7 +114,7 @@
      * 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 8385f75..5bbc4a4 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -1059,7 +1059,7 @@
 
 class XmlAttributeFinder : public BackTrackingAttributeFinder<XmlAttributeFinder, jsize> {
 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 a4ab9fd..af975fb 100644
--- a/core/jni/android_view_GraphicBuffer.cpp
+++ b/core/jni/android_view_GraphicBuffer.cpp
@@ -88,7 +88,7 @@
 
 class GraphicBufferWrapper {
 public:
-    GraphicBufferWrapper(const sp<GraphicBuffer>& buffer): buffer(buffer) {
+    explicit GraphicBufferWrapper(const sp<GraphicBuffer>& buffer): buffer(buffer) {
     }
 
     sp<GraphicBuffer> buffer;
diff --git a/core/jni/android_view_InputChannel.cpp b/core/jni/android_view_InputChannel.cpp
index 092ac27..c7998a1 100644
--- a/core/jni/android_view_InputChannel.cpp
+++ b/core/jni/android_view_InputChannel.cpp
@@ -43,7 +43,7 @@
 
 class NativeInputChannel {
 public:
-    NativeInputChannel(const sp<InputChannel>& inputChannel);
+    explicit NativeInputChannel(const sp<InputChannel>& inputChannel);
     ~NativeInputChannel();
 
     inline sp<InputChannel> getInputChannel() { return mInputChannel; }
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index 7b2a40b..6290706 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -68,7 +68,7 @@
 
 class InvokeAnimationListeners : public MessageHandler {
 public:
-    InvokeAnimationListeners(std::vector<OnFinishedEvent>& events) {
+    explicit InvokeAnimationListeners(std::vector<OnFinishedEvent>& events) {
         mOnFinishedEvents.swap(events);
     }
 
@@ -108,7 +108,7 @@
 
 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!");
@@ -197,7 +197,7 @@
 
 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 04ec705..e1f2241 100644
--- a/core/jni/android_view_VelocityTracker.cpp
+++ b/core/jni/android_view_VelocityTracker.cpp
@@ -45,7 +45,7 @@
 
 class VelocityTrackerState {
 public:
-    VelocityTrackerState(const char* strategy);
+    explicit VelocityTrackerState(const char* strategy);
 
     void clear();
     void addMovement(const MotionEvent* event);
diff --git a/core/jni/android_app_ApplicationLoaders.cpp b/core/jni/com_android_internal_os_PathClassLoaderFactory.cpp
similarity index 85%
rename from core/jni/android_app_ApplicationLoaders.cpp
rename to core/jni/com_android_internal_os_PathClassLoaderFactory.cpp
index 89f22eb..a7a912c 100644
--- a/core/jni/android_app_ApplicationLoaders.cpp
+++ b/core/jni/com_android_internal_os_PathClassLoaderFactory.cpp
@@ -39,13 +39,13 @@
       reinterpret_cast<void*>(createClassloaderNamespace_native) },
 };
 
-static const char* const kApplicationLoadersPathName = "android/app/ApplicationLoaders";
+static const char* const kPathClassLoaderFactoryPathName = "com/android/internal/os/PathClassLoaderFactory";
 
 namespace android
 {
 
-int register_android_app_ApplicationLoaders(JNIEnv* env) {
-    return RegisterMethodsOrDie(env, kApplicationLoadersPathName, g_methods, NELEM(g_methods));
+int register_com_android_internal_os_PathClassLoaderFactory(JNIEnv* env) {
+    return RegisterMethodsOrDie(env, kPathClassLoaderFactoryPathName, g_methods, NELEM(g_methods));
 }
 
 } // namespace android
diff --git a/include/androidfw/ZipUtils.h b/include/androidfw/ZipUtils.h
index 094eaa8..55575d7 100644
--- a/include/androidfw/ZipUtils.h
+++ b/include/androidfw/ZipUtils.h
@@ -21,6 +21,7 @@
 #define __LIBS_ZIPUTILS_H
 
 #include <stdint.h>
+#include <string.h>
 #include <stdio.h>
 #include <time.h>
 
@@ -63,16 +64,21 @@
 
     /*
      * Utility function to convert ZIP's time format to a timespec struct.
+     *
+     * NOTE: this method will clear all existing state from |timespec|.
      */
     static inline void zipTimeToTimespec(uint32_t when, struct tm* timespec) {
         const uint32_t date = when >> 16;
+
+        memset(timespec, 0, sizeof(struct tm));
         timespec->tm_year = ((date >> 9) & 0x7F) + 80; // Zip is years since 1980
-        timespec->tm_mon = (date >> 5) & 0x0F;
+        timespec->tm_mon = ((date >> 5) & 0x0F) - 1;
         timespec->tm_mday = date & 0x1F;
 
         timespec->tm_hour = (when >> 11) & 0x1F;
         timespec->tm_min = (when >> 5) & 0x3F;
         timespec->tm_sec = (when & 0x1F) << 1;
+        timespec->tm_isdst = -1;
     }
 private:
     ZipUtils() {}
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 806eeda..d6dd983 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -3008,7 +3008,7 @@
 
 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 6fa0f14..5abfc8e 100644
--- a/libs/androidfw/ZipUtils.cpp
+++ b/libs/androidfw/ZipUtils.cpp
@@ -150,7 +150,7 @@
 
 class FileReader {
 public:
-   FileReader(FILE* fp) :
+   explicit FileReader(FILE* fp) :
        mFp(fp), mReadBuf(new unsigned char[kReadBufSize])
    {
    }
@@ -170,7 +170,7 @@
 
 class FdReader {
 public:
-   FdReader(int fd) :
+   explicit FdReader(int fd) :
        mFd(fd), mReadBuf(new unsigned char[kReadBufSize])
    {
    }
diff --git a/libs/androidfw/tests/ZipUtils_test.cpp b/libs/androidfw/tests/ZipUtils_test.cpp
index c6038b5..7293843 100644
--- a/libs/androidfw/tests/ZipUtils_test.cpp
+++ b/libs/androidfw/tests/ZipUtils_test.cpp
@@ -45,7 +45,7 @@
     EXPECT_EQ(2011, t.tm_year + 1900)
             << "Year was improperly converted.";
 
-    EXPECT_EQ(6, t.tm_mon)
+    EXPECT_EQ(5, t.tm_mon)
             << "Month was improperly converted.";
 
     EXPECT_EQ(29, t.tm_mday)
@@ -59,6 +59,11 @@
 
     EXPECT_EQ(40, t.tm_sec)
             << "Second was improperly converted.";
+
+    // We don't have enough information to determine timezone related info.
+    EXPECT_EQ(-1, t.tm_isdst);
+    EXPECT_EQ(0, t.tm_gmtoff);
+    EXPECT_EQ(nullptr, t.tm_zone);
 }
 
 }
diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp
index cd30b18..22947b0 100644
--- a/libs/hwui/AnimatorManager.cpp
+++ b/libs/hwui/AnimatorManager.cpp
@@ -155,7 +155,7 @@
 
 class EndActiveAnimatorsFunctor {
 public:
-    EndActiveAnimatorsFunctor(AnimationContext& context) : mContext(context) {}
+    explicit EndActiveAnimatorsFunctor(AnimationContext& context) : mContext(context) {}
 
     void operator() (BaseRenderNodeAnimator* animator) {
         animator->forceEndNow(mContext);
diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp
index 03aecd4..610398c 100644
--- a/libs/hwui/DeferredDisplayList.cpp
+++ b/libs/hwui/DeferredDisplayList.cpp
@@ -61,7 +61,7 @@
 
 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 644a4f3..a8e1a4b 100644
--- a/libs/hwui/SkiaCanvas.cpp
+++ b/libs/hwui/SkiaCanvas.cpp
@@ -164,7 +164,7 @@
 
 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 17cb3a7..84c2a40 100644
--- a/libs/hwui/TessellationCache.cpp
+++ b/libs/hwui/TessellationCache.cpp
@@ -110,7 +110,7 @@
 
 class TessellationCache::TessellationProcessor : public TaskProcessor<VertexBuffer*> {
 public:
-    TessellationProcessor(Caches& caches)
+    explicit TessellationProcessor(Caches& caches)
             : TaskProcessor<VertexBuffer*>(&caches.tasks) {}
     ~TessellationProcessor() {}
 
@@ -124,7 +124,7 @@
 
 class TessellationCache::Buffer {
 public:
-    Buffer(const sp<Task<VertexBuffer*> >& task)
+    explicit Buffer(const sp<Task<VertexBuffer*> >& task)
             : mTask(task)
             , mBuffer(nullptr) {
     }
@@ -283,7 +283,7 @@
 
 class ShadowProcessor : public TaskProcessor<TessellationCache::vertexBuffer_pair_t*> {
 public:
-    ShadowProcessor(Caches& caches)
+    explicit ShadowProcessor(Caches& caches)
             : TaskProcessor<TessellationCache::vertexBuffer_pair_t*>(&caches.tasks) {}
     ~ShadowProcessor() {}
 
diff --git a/libs/hwui/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp
index 84b6965..229aa46 100644
--- a/libs/hwui/renderstate/RenderState.cpp
+++ b/libs/hwui/renderstate/RenderState.cpp
@@ -186,7 +186,7 @@
 
 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 64075f1..8301107 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -129,7 +129,7 @@
 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/hwui/unit_tests/LinearAllocatorTests.cpp b/libs/hwui/unit_tests/LinearAllocatorTests.cpp
index b3959d1..18dc8f9 100644
--- a/libs/hwui/unit_tests/LinearAllocatorTests.cpp
+++ b/libs/hwui/unit_tests/LinearAllocatorTests.cpp
@@ -30,7 +30,7 @@
     SignalingDtor() {
         mDestroyed = nullptr;
     }
-    SignalingDtor(bool* destroyedSignal) {
+    explicit SignalingDtor(bool* destroyedSignal) {
         mDestroyed = destroyedSignal;
         *mDestroyed = false;
     }
diff --git a/libs/storage/IMountService.cpp b/libs/storage/IMountService.cpp
index c643ed0..74638e7 100644
--- a/libs/storage/IMountService.cpp
+++ b/libs/storage/IMountService.cpp
@@ -55,7 +55,7 @@
 class BpMountService: public BpInterface<IMountService>
 {
 public:
-    BpMountService(const sp<IBinder>& impl)
+    explicit BpMountService(const sp<IBinder>& impl)
         : BpInterface<IMountService>(impl)
     {
     }
diff --git a/libs/storage/IObbActionListener.cpp b/libs/storage/IObbActionListener.cpp
index 9656e65..a71341b 100644
--- a/libs/storage/IObbActionListener.cpp
+++ b/libs/storage/IObbActionListener.cpp
@@ -26,7 +26,7 @@
 // This is a stub that real consumers should override.
 class BpObbActionListener: public BpInterface<IObbActionListener> {
 public:
-    BpObbActionListener(const sp<IBinder>& impl)
+    explicit BpObbActionListener(const sp<IBinder>& impl)
         : BpInterface<IObbActionListener>(impl)
     { }
 
diff --git a/media/mca/filterfw/jni/jni_gl_environment.cpp b/media/mca/filterfw/jni/jni_gl_environment.cpp
index 5f00739..096120e 100644
--- a/media/mca/filterfw/jni/jni_gl_environment.cpp
+++ b/media/mca/filterfw/jni/jni_gl_environment.cpp
@@ -39,7 +39,7 @@
 
 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 dee3f8c..0e5e5c6 100644
--- a/native/android/asset_manager.cpp
+++ b/native/android/asset_manager.cpp
@@ -39,7 +39,7 @@
     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 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 e35c85b..c3629da 100644
--- a/native/android/choreographer.cpp
+++ b/native/android/choreographer.cpp
@@ -64,7 +64,7 @@
     virtual ~Choreographer() = default;
 
 private:
-    Choreographer(const sp<Looper>& looper);
+    explicit Choreographer(const sp<Looper>& 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 399f1ff..137b72c 100644
--- a/native/android/storage_manager.cpp
+++ b/native/android/storage_manager.cpp
@@ -37,7 +37,7 @@
     sp<AStorageManager> 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 246ab0d..407c072 100644
--- a/services/core/jni/com_android_server_AlarmManagerService.cpp
+++ b/services/core/jni/com_android_server_AlarmManagerService.cpp
@@ -74,7 +74,7 @@
 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 b72cf4d..5f73d42 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 @@
 // it to service thread.
 class CecEventWrapper : public LightRefBase<CecEventWrapper> {
 public:
-    CecEventWrapper(const hdmi_event_t& event) {
+    explicit CecEventWrapper(const hdmi_event_t& event) {
         // Copy message.
         switch (event.type) {
         case HDMI_EVENT_CEC_MESSAGE:
diff --git a/tools/aapt2/ResourceTable_test.cpp b/tools/aapt2/ResourceTable_test.cpp
index 06d8699..d3b9af3 100644
--- a/tools/aapt2/ResourceTable_test.cpp
+++ b/tools/aapt2/ResourceTable_test.cpp
@@ -28,7 +28,7 @@
 struct TestValue : public Value {
     std::u16string value;
 
-    TestValue(StringPiece16 str) : value(str.toString()) {
+    explicit TestValue(StringPiece16 str) : value(str.toString()) {
     }
 
     TestValue* clone(StringPool* /*newPool*/) const override {