DO NOT MERGE - Merge pie-platform-release (PPRL.190705.004) into master

Bug: 136196576
Change-Id: Id22dca352d5135497589b1d1f4fe112ff24e1580
diff --git a/codec2/Android.mk b/codec2/Android.mk
index 948b145..82d739f 100644
--- a/codec2/Android.mk
+++ b/codec2/Android.mk
@@ -10,6 +10,7 @@
 C2_DOXY := $(or $(shell command -v doxygen),\
 		$(shell command -v /Applications/Doxygen.app/Contents/Resources/doxygen))
 
+.PHONY: check-doxygen
 check-doxygen:
 ifndef C2_DOXY
 	$(error 'doxygen is not available')
@@ -27,18 +28,21 @@
 	sed 's:\(^OUTPUT_DIRECTORY *= \)out\(.*\)api:\1'$(OUT_DIR)'\2internal:;' \
 		$(C2_ROOT)/docs/doxygen.config > $@
 
+.PHONY: docs-api
 docs-api: $(C2_OUT_TEMP)/doxy-api.config check-doxygen
 	echo API docs are building in $(C2_DOCS_ROOT)/api
 	rm -rf $(C2_DOCS_ROOT)/api
 	mkdir -p $(C2_DOCS_ROOT)/api
 	$(C2_DOXY) $(C2_OUT_TEMP)/doxy-api.config
 
+.PHONY: docs-internal
 docs-internal: $(C2_OUT_TEMP)/doxy-internal.config check-doxygen
 	echo Internal docs are building in $(C2_DOCS_ROOT)/internal
 	rm -rf $(C2_DOCS_ROOT)/internal
 	mkdir -p $(C2_DOCS_ROOT)/internal
 	$(C2_DOXY) $(C2_OUT_TEMP)/doxy-internal.config
 
+.PHONY: docs-all
 docs-all: docs-api docs-internal
 
 include $(call all-makefiles-under,$(call my-dir))
diff --git a/codec2/include/C2.h b/codec2/include/C2.h
index 8a55f8d..ef3466d 100644
--- a/codec2/include/C2.h
+++ b/codec2/include/C2.h
@@ -289,7 +289,7 @@
      * Convert to a smaller counter type. This is always safe.
      */
     template<typename U, typename E=typename std::enable_if<(sizeof(U) < sizeof(T))>::type>
-    inline operator c2_cntr_t<U>() {
+    inline constexpr operator c2_cntr_t<U>() {
         return c2_cntr_t<U>(mValue);
     }
 
diff --git a/codec2/include/C2Param.h b/codec2/include/C2Param.h
index 40be3b3..efc5c89 100644
--- a/codec2/include/C2Param.h
+++ b/codec2/include/C2Param.h
@@ -988,7 +988,10 @@
     /** specialization for easy enums */
     template<typename E>
     inline static NamedValuesType namedValuesFor(const C2EasyEnum<E> &) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnull-dereference"
         return namedValuesFor(*(E*)nullptr);
+#pragma GCC diagnostic pop
     }
 
 private:
@@ -1104,7 +1107,10 @@
 template<typename B>
 struct C2FieldDescriptor::_NamedValuesGetter<B, true> {
     inline static C2FieldDescriptor::NamedValuesType getNamedValues() {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnull-dereference"
         return C2FieldDescriptor::namedValuesFor(*(B*)nullptr);
+#pragma GCC diagnostic pop
     }
 };
 
@@ -1599,11 +1605,13 @@
     /// \internal
     /// \todo: create separate values vs. flags initializer as for flags we want
     /// to list both allowed and required flags
-    template<typename T, typename E=decltype(C2FieldDescriptor::namedValuesFor(*(T*)0))>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wnull-dereference"
+    template<typename T, typename E=decltype(C2FieldDescriptor::namedValuesFor(*(T*)nullptr))>
     C2FieldSupportedValues(bool flags, const T*)
         : type(flags ? FLAGS : VALUES),
           range{(T)0, (T)0, (T)0, (T)0, (T)0} {
-              C2FieldDescriptor::NamedValuesType named = C2FieldDescriptor::namedValuesFor(*(T*)0);
+              C2FieldDescriptor::NamedValuesType named = C2FieldDescriptor::namedValuesFor(*(T*)nullptr);
         if (flags) {
             values.emplace_back(0); // min-mask defaults to 0
         }
@@ -1612,6 +1620,7 @@
         }
     }
 };
+#pragma GCC diagnostic pop
 
 /**
  * Supported values for a specific field.
diff --git a/media/codecs/aac/C2SoftAacEnc.cpp b/media/codecs/aac/C2SoftAacEnc.cpp
index 889016a..75b5ea8 100644
--- a/media/codecs/aac/C2SoftAacEnc.cpp
+++ b/media/codecs/aac/C2SoftAacEnc.cpp
@@ -485,7 +485,8 @@
         uint32_t drainMode,
         const std::shared_ptr<C2BlockPool> &pool) {
     switch (drainMode) {
-        case DRAIN_COMPONENT_NO_EOS:  // fall-through
+        case DRAIN_COMPONENT_NO_EOS:
+            [[fallthrough]];
         case NO_DRAIN:
             // no-op
             return C2_OK;
diff --git a/media/codecs/avc/C2SoftAvcEnc.cpp b/media/codecs/avc/C2SoftAvcEnc.cpp
index cafda79..c10de61 100644
--- a/media/codecs/avc/C2SoftAvcEnc.cpp
+++ b/media/codecs/avc/C2SoftAvcEnc.cpp
@@ -270,7 +270,7 @@
 
     IV_PROFILE_T getProfile_l() const {
         switch (mProfileLevel->profile) {
-        case PROFILE_AVC_CONSTRAINED_BASELINE:  // fall-through
+        case PROFILE_AVC_CONSTRAINED_BASELINE:  [[fallthrough]];
         case PROFILE_AVC_BASELINE: return IV_PROFILE_BASE;
         case PROFILE_AVC_MAIN:     return IV_PROFILE_MAIN;
         default:
@@ -1162,7 +1162,7 @@
 
     switch (layout.type) {
         case C2PlanarLayout::TYPE_RGB:
-            // fall-through
+            [[fallthrough]];
         case C2PlanarLayout::TYPE_RGBA: {
             ALOGV("yPlaneSize = %zu", yPlaneSize);
             MemoryBlock conversionBuffer = mConversionBuffers.fetch(yPlaneSize * 3 / 2);
diff --git a/media/codecs/base/Android.bp b/media/codecs/base/Android.bp
index ad456e2..2aa84f6 100644
--- a/media/codecs/base/Android.bp
+++ b/media/codecs/base/Android.bp
@@ -31,9 +31,6 @@
             "signed-integer-overflow",
         ],
         cfi: true,
-        diag: {
-            cfi: true,
-        },
     },
 
     ldflags: ["-Wl,-Bsymbolic"],
diff --git a/media/codecs/base/SimpleC2Component.cpp b/media/codecs/base/SimpleC2Component.cpp
index d6a62a7..cf80ffa 100644
--- a/media/codecs/base/SimpleC2Component.cpp
+++ b/media/codecs/base/SimpleC2Component.cpp
@@ -102,7 +102,7 @@
         case kWhatInit: {
             int32_t err = thiz->onInit();
             Reply(msg, &err);
-            // fall-through
+            [[fallthrough]];
         }
         case kWhatStart: {
             mRunning = true;
diff --git a/media/codecs/cmds/Android.bp b/media/codecs/cmds/Android.bp
index c48ae07..4019fbe 100644
--- a/media/codecs/cmds/Android.bp
+++ b/media/codecs/cmds/Android.bp
@@ -34,8 +34,5 @@
             "unsigned-integer-overflow",
             "signed-integer-overflow",
         ],
-        diag: {
-            cfi: true,
-        },
     },
 }
diff --git a/media/codecs/mpeg4_h263/C2SoftMpeg4Enc.cpp b/media/codecs/mpeg4_h263/C2SoftMpeg4Enc.cpp
index ddc1c7b..dd9d94b 100644
--- a/media/codecs/mpeg4_h263/C2SoftMpeg4Enc.cpp
+++ b/media/codecs/mpeg4_h263/C2SoftMpeg4Enc.cpp
@@ -493,7 +493,7 @@
     size_t yPlaneSize = width * height;
     switch (layout.type) {
         case C2PlanarLayout::TYPE_RGB:
-        // fall-through
+            [[fallthrough]];
         case C2PlanarLayout::TYPE_RGBA: {
             MemoryBlock conversionBuffer = mConversionBuffers.fetch(yPlaneSize * 3 / 2);
             mConversionBuffersInUse.emplace(conversionBuffer.data(), conversionBuffer);
diff --git a/media/codecs/vpx/C2SoftVpxEnc.cpp b/media/codecs/vpx/C2SoftVpxEnc.cpp
index ead9c73..37fd59d 100644
--- a/media/codecs/vpx/C2SoftVpxEnc.cpp
+++ b/media/codecs/vpx/C2SoftVpxEnc.cpp
@@ -348,7 +348,7 @@
               break;
           case kTemporalUpdateGoldenWithoutDependency:
               flags |= VP8_EFLAG_NO_REF_GF;
-              // Deliberately no break here.
+              [[fallthrough]];
           case kTemporalUpdateGolden:
               flags |= VP8_EFLAG_NO_REF_ARF;
               flags |= VP8_EFLAG_NO_UPD_ARF;
@@ -357,14 +357,14 @@
           case kTemporalUpdateAltrefWithoutDependency:
               flags |= VP8_EFLAG_NO_REF_ARF;
               flags |= VP8_EFLAG_NO_REF_GF;
-              // Deliberately no break here.
+              [[fallthrough]];
           case kTemporalUpdateAltref:
               flags |= VP8_EFLAG_NO_UPD_GF;
               flags |= VP8_EFLAG_NO_UPD_LAST;
               break;
           case kTemporalUpdateNoneNoRefAltref:
               flags |= VP8_EFLAG_NO_REF_ARF;
-              // Deliberately no break here.
+              [[fallthrough]];
           case kTemporalUpdateNone:
               flags |= VP8_EFLAG_NO_UPD_GF;
               flags |= VP8_EFLAG_NO_UPD_ARF;
diff --git a/media/sfplugin/Android.bp b/media/sfplugin/Android.bp
index 831fb35..5e2e3bd 100644
--- a/media/sfplugin/Android.bp
+++ b/media/sfplugin/Android.bp
@@ -54,8 +54,5 @@
             "unsigned-integer-overflow",
             "signed-integer-overflow",
         ],
-        diag: {
-            cfi: true,
-        },
     },
 }
diff --git a/media/sfplugin/Codec2Buffer.cpp b/media/sfplugin/Codec2Buffer.cpp
index df87a67..866a529 100644
--- a/media/sfplugin/Codec2Buffer.cpp
+++ b/media/sfplugin/Codec2Buffer.cpp
@@ -296,7 +296,7 @@
                             break;
                         }
                     }
-                    // fall through if we could not wrap
+                    [[fallthrough]];
 
                     case COLOR_FormatYUV420Planar:
                     case COLOR_FormatYUV420PackedPlanar:
diff --git a/media/sfplugin/utils/Android.bp b/media/sfplugin/utils/Android.bp
index cd572a4..fb5d9e4 100644
--- a/media/sfplugin/utils/Android.bp
+++ b/media/sfplugin/utils/Android.bp
@@ -36,8 +36,5 @@
             "unsigned-integer-overflow",
             "signed-integer-overflow",
         ],
-        diag: {
-            cfi: true,
-        },
     },
 }