Merge "cec: Fixes for 8994"
diff --git a/hdmi_cec/Android.mk b/hdmi_cec/Android.mk
index a605b6b..ed06da1 100644
--- a/hdmi_cec/Android.mk
+++ b/hdmi_cec/Android.mk
@@ -3,7 +3,7 @@
 include $(CLEAR_VARS)
 
 LOCAL_MODULE                  := hdmi_cec.$(TARGET_BOARD_PLATFORM)
-LOCAL_MODULE_PATH             := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_MODULE_RELATIVE_PATH    := hw
 LOCAL_MODULE_TAGS             := optional
 LOCAL_C_INCLUDES              := $(common_includes)
 LOCAL_SHARED_LIBRARIES        := $(common_libs) libqservice libbinder libqdutils
diff --git a/hdmi_cec/qhdmi_cec.cpp b/hdmi_cec/qhdmi_cec.cpp
index c6ae97b..6e46254 100644
--- a/hdmi_cec/qhdmi_cec.cpp
+++ b/hdmi_cec/qhdmi_cec.cpp
@@ -27,7 +27,7 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#define DEBUG 1
+#define DEBUG 0
 #define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
 #include <cstdlib>
 #include <cutils/log.h>
@@ -65,6 +65,7 @@
 //Forward declarations
 static void cec_close_context(cec_context_t* ctx __unused);
 static int cec_enable(cec_context_t *ctx, int enable);
+static int cec_is_connected(const struct hdmi_cec_device* dev, int port_id);
 
 static ssize_t read_node(const char *path, char *data)
 {
@@ -171,7 +172,7 @@
     //XXX: We can get multiple logical addresses here but we can only send one
     //to the driver. Store locally for now
     ssize_t err = write_int_to_node(ctx, "cec/logical_addr", addr);
-    ALOGD_IF(DEBUG, "%s: Allocated logical address: %d ", __FUNCTION__, addr);
+    ALOGI("%s: Allocated logical address: %d ", __FUNCTION__, addr);
     return (int) err;
 }
 
@@ -206,6 +207,9 @@
         const cec_message_t* msg)
 {
     ATRACE_CALL();
+    if(cec_is_connected(dev, 0) <= 0)
+        return HDMI_RESULT_FAIL;
+
     cec_context_t* ctx = (cec_context_t*)(dev);
     ALOGD_IF(DEBUG, "%s: initiator: %d destination: %d length: %u",
             __FUNCTION__, msg->initiator, msg->destination,
@@ -254,7 +258,7 @@
 
     if (err < 0) {
        if (err == -ENXIO) {
-           ALOGE("%s: No device exists with the destination address",
+           ALOGI("%s: No device exists with the destination address",
                    __FUNCTION__);
            return HDMI_RESULT_NACK;
        } else if (err == -EAGAIN) {