Merge remote-tracking branch 'caf/LA.BR.1.3.7_rb1.4' into lineage-15.0-caf-8952
diff --git a/hdmi_cec/qhdmi_cec.cpp b/hdmi_cec/qhdmi_cec.cpp
index 1bc7df6..75c8063 100644
--- a/hdmi_cec/qhdmi_cec.cpp
+++ b/hdmi_cec/qhdmi_cec.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2014 The Linux Foundation. All rights reserved.
+* Copyright (c)2014-2015, 2017, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -296,8 +296,10 @@
     event.cec.initiator = (cec_logical_address_t) msg[CEC_OFFSET_SENDER_ID];
     event.cec.destination = (cec_logical_address_t) msg[CEC_OFFSET_RECEIVER_ID];
     //Copy opcode and operand
-    memcpy(event.cec.body, &msg[CEC_OFFSET_OPCODE], event.cec.length);
-    hex_to_string((char *) event.cec.body, event.cec.length, dump);
+    size_t copy_size = event.cec.length > sizeof(event.cec.body) ?
+                       sizeof(event.cec.body) : event.cec.length;
+    memcpy(event.cec.body, &msg[CEC_OFFSET_OPCODE],copy_size);
+    hex_to_string((char *) event.cec.body, copy_size, dump);
     ALOGD_IF(DEBUG, "%s: Message to framework: %s", __FUNCTION__, dump);
     ctx->callback.callback_func(&event, ctx->callback.callback_arg);
 }
diff --git a/libhwcomposer/Android.mk b/libhwcomposer/Android.mk
index 7e3dd42..b2d3580 100644
--- a/libhwcomposer/Android.mk
+++ b/libhwcomposer/Android.mk
@@ -19,7 +19,7 @@
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libEGL liboverlay \
                                  libhdmi libqdutils libhardware_legacy \
                                  libdl libmemalloc libqservice libsync \
-                                 libbinder libmedia
+                                 libbinder libmedia libdisplayconfig
 
 LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdhwcomposer\" -Wno-absolute-value \
                                  -Wno-float-conversion -Wno-unused-parameter
diff --git a/libqdutils/Android.mk b/libqdutils/Android.mk
index f86d432..8a3bde4 100644
--- a/libqdutils/Android.mk
+++ b/libqdutils/Android.mk
@@ -9,12 +9,25 @@
 LOCAL_CFLAGS                  := $(common_flags) -DLOG_TAG=\"qdutils\" -Wno-float-conversion
 LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
 LOCAL_COPY_HEADERS_TO         := $(common_header_export_path)
-LOCAL_COPY_HEADERS            := display_config.h mdp_version.h
+LOCAL_COPY_HEADERS            := mdp_version.h
 LOCAL_SRC_FILES               := profiler.cpp mdp_version.cpp \
                                  idle_invalidator.cpp \
                                  comptype.cpp qd_utils.cpp \
-                                 cb_utils.cpp display_config.cpp \
-                                 cb_swap_rect.cpp
+                                 cb_utils.cpp cb_swap_rect.cpp
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_COPY_HEADERS_TO           := $(common_header_export_path)
+LOCAL_COPY_HEADERS              := DisplayConfig.h display_config.h
+LOCAL_SHARED_LIBRARIES          := $(common_libs) libbinder libqservice libqdutils
+LOCAL_C_INCLUDES                := $(common_includes)
+LOCAL_ADDITIONAL_DEPENDENCIES   := $(common_deps)
+LOCAL_SRC_FILES                 := display_config.cpp
+LOCAL_CFLAGS                    := $(common_flags)
+LOCAL_CFLAGS                    += -DLOG_TAG=\"DisplayConfig\"
+LOCAL_MODULE_TAGS               := optional
+LOCAL_MODULE                    := libdisplayconfig
 include $(BUILD_SHARED_LIBRARY)
 
 include $(CLEAR_VARS)
diff --git a/libqdutils/DisplayConfig.h b/libqdutils/DisplayConfig.h
new file mode 100644
index 0000000..190db99
--- /dev/null
+++ b/libqdutils/DisplayConfig.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2017 The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *    * Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    * Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *    * Neither the name of The Linux Foundation. nor the names of its
+ *      contributors may be used to endorse or promote products derived
+ *      from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "display_config.h"
+
diff --git a/libqdutils/display_config.cpp b/libqdutils/display_config.cpp
index 5ef7702..e3e8fe6 100644
--- a/libqdutils/display_config.cpp
+++ b/libqdutils/display_config.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2013-2014,2016 The Linux Foundation. All rights reserved.
+* Copyright (c) 2013-2014,2016-2017 The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -144,7 +144,7 @@
     return err;
 }
 
-int setSecondaryDisplayStatus(int dpy, uint32_t status) {
+int setSecondayDisplayStatus(int dpy, uint32_t status) {
     status_t err = (status_t) FAILED_TRANSACTION;
     sp<IQService> binder = getBinder();
     Parcel inParcel, outParcel;
@@ -162,7 +162,7 @@
     return err;
 }
 
-int configureDynRefreshRate(uint32_t op, uint32_t refreshRate) {
+int configureDynRefeshRate(uint32_t op, uint32_t refreshRate) {
     status_t err = (status_t) FAILED_TRANSACTION;
     sp<IQService> binder = getBinder();
     Parcel inParcel, outParcel;
diff --git a/libqdutils/display_config.h b/libqdutils/display_config.h
index cdb1985..8ec2f29 100644
--- a/libqdutils/display_config.h
+++ b/libqdutils/display_config.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013, 2017 The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -34,7 +34,8 @@
 // This header is for clients to use to set/get global display configuration.
 // Only primary and external displays are supported here.
 
-namespace qdutils {
+namespace display = qdutils;
+namespace qdutils{
 
 
 /* TODO: Have all the common enums that need be exposed to clients and which
@@ -46,9 +47,6 @@
 enum {
     DISPLAY_PRIMARY  = HWC_DISPLAY_PRIMARY,
     DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL,
-#ifdef QTI_BSP
-    DISPLAY_TERTIARY = HWC_DISPLAY_TERTIARY,
-#endif
     DISPLAY_VIRTUAL  = HWC_DISPLAY_VIRTUAL,
 };
 
@@ -112,10 +110,10 @@
 int setViewFrame(int dpy, int l, int t, int r, int b);
 
 // Set the secondary display status(pause/resume/offline etc.,)
-int setSecondaryDisplayStatus(int dpy, uint32_t status);
+int setSecondayDisplayStatus(int dpy, uint32_t status);
 
 // Enable/Disable/Set refresh rate dynamically
-int configureDynRefreshRate(uint32_t op, uint32_t refreshRate);
+int configureDynRefeshRate(uint32_t op, uint32_t refreshRate);
 
 // Returns the number of configs supported for the display on success.
 // Returns -1 on error.