[Feature] get temp api

Change-Id: I9819738ad7f757c7d3614c7272f2b286368c1794
diff --git a/src/lynq/lib/liblynq-thermal/include/liblynq-thermal/lynq_get_thermal.h b/src/lynq/lib/liblynq-thermal/include/liblynq-thermal/lynq_get_thermal.h
new file mode 100755
index 0000000..8228710
--- /dev/null
+++ b/src/lynq/lib/liblynq-thermal/include/liblynq-thermal/lynq_get_thermal.h
@@ -0,0 +1,40 @@
+#ifndef __LYNQ_GET_THERMAL_H__

+#define __LYNQ_GET_THERMAL_H__

+

+#define LYNQ_THM_PATH 256

+

+#define TYPE_PATH_PRE "/sys/class/thermal"

+

+#define LYNQ_THM_OK 0

+#define LYNQ_THM_OPEN_ERROR -1

+#define LYNQ_THM_READ_ERROR -2

+#define LYNQ_THM_ACCESS_ERROR -3

+#define LYNQ_THM_ZONE_ERROR -4

+

+#define LYNQ_THM_ZONE_KEY "thermal_zone"

+#define LYNQ_THM_COOLER_KEY "cooling_device"

+

+typedef enum {

+    soc_max=0,

+    cpu0,

+    cpu1,

+    cpu2,

+    cpu3,

+    gpu0,

+    gpu1,

+    dramc,

+    mmsys,

+    md_5g,

+    md_4g,

+    md_3g,

+    soc_dram_ntc,

+    pa_5g,

+    pa_4g,

+    rf_ntc,

+    pmic,

+    pmic_vcore,

+    pmic_vpro,

+    pmic_vgpu=19,

+} ZONE_NUM;

+

+#endif  //__LYNQ_GET_THERMAL_H__
\ No newline at end of file
diff --git a/src/lynq/lib/liblynq-thermal/makefile b/src/lynq/lib/liblynq-thermal/makefile
new file mode 100755
index 0000000..bae164e
--- /dev/null
+++ b/src/lynq/lib/liblynq-thermal/makefile
@@ -0,0 +1,85 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=gnu++14 \
+                -g -Os \
+                -flto \
+                -fPIC \
+                -fpermissive \
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+    LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+    LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+                     -DANDROID_MULTI_SIM \
+                     -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+    LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+$(warning ################# TARGET_PLATFORM_MT2731)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+                    -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+                    -DMD_90_SUPPORT
+endif
+
+$(warning ################# RITA ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+
+SOURCES = $(wildcard *.c wildcard *.h src/*.c)
+
+EXECUTABLE = liblynq-thermal.so
+
+OBJECTS=$(SOURCES:.c=.o)
+
+
+.PHONY: build clean install pack_rootfs 
+
+all: build
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $< 
+
+build:  $(EXECUTABLE)
+	$(warning ########## build $(EXECUTABLE)  ##########)
+
+install:
+	mkdir -p $(ROOT)$(base_libdir)/
+	install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+	mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+
+pack_rootfs:
+	mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+	mkdir -p $(PACK_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/src/lynq/lib/liblynq-thermal/src/lynq_get_thermal.c b/src/lynq/lib/liblynq-thermal/src/lynq_get_thermal.c
new file mode 100755
index 0000000..0b3f3c0
--- /dev/null
+++ b/src/lynq/lib/liblynq-thermal/src/lynq_get_thermal.c
@@ -0,0 +1,63 @@
+#include <sys/types.h>

+#include <dirent.h>

+#include <unistd.h>

+#include <stdio.h>

+#include <string.h>

+#include <fcntl.h>

+#include <stdlib.h>

+#include <unistd.h>

+#include "liblynq-thermal/lynq_get_thermal.h"

+

+

+char* lynq_read_version()

+{

+    return "THERMAL-V1.0";

+}

+

+int read_sys_info(char *sys_path, char *out_buf)

+{

+    int fd, ret;

+    char buf[LYNQ_THM_PATH] = "";

+    

+    if ((access(sys_path, F_OK)) == -1) 

+        return LYNQ_THM_ACCESS_ERROR;

+    

+    fd = open(sys_path, O_RDONLY);

+    

+    if (fd < 0)

+    {

+        printf("[%s-%d] open error!!!\n", __FUNCTION__, __LINE__);

+        return LYNQ_THM_OPEN_ERROR;

+    }

+    

+    ret = read(fd, buf, sizeof(buf));

+    memcpy(out_buf, buf, strlen(buf));

+

+    if(ret<0){

+        printf("[%s-%d] read error!!!\n", __FUNCTION__, __LINE__);

+        return LYNQ_THM_READ_ERROR;

+    }

+    close(fd);

+    

+    return LYNQ_THM_OK;

+}

+

+int lynq_get_zone_tmp(ZONE_NUM num, int *temp)

+{

+    char tz_path[LYNQ_THM_PATH] = "";

+    char buf[LYNQ_THM_PATH] = "";

+    

+    if(num < 0 && num > 19)

+    {

+        printf("[%s-%d] no such device,please reinput!!\n", __FUNCTION__, __LINE__);

+        return  LYNQ_THM_ZONE_ERROR;

+    }

+    sprintf(tz_path, "%s/%s%d/temp", TYPE_PATH_PRE, LYNQ_THM_ZONE_KEY, num);

+    int ret = read_sys_info(tz_path, buf);

+    if(!ret)

+    {

+        *temp = atoi(buf);

+    }

+    

+    return ret;

+}