device/amlogic/common/products/tv/product_tv.mk | 1 +
device/amlogic/common/sepolicy.mk | 1 +
device/amlogic/common/sepolicy/file_contexts | 1 +
device/amlogic/common/sepolicy/mainService.te | 4 ++++
device/customer/r34tv/init.amlogic.rc | 8 ++++++++
vendor/amlogic/frameworks/services/mainService/Android.mk | 22 ++++++++++++++++++++++
vendor/amlogic/frameworks/services/mainService/adc.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
vendor/amlogic/frameworks/services/mainService/adc.h | 20 ++++++++++++++++++++
vendor/amlogic/frameworks/services/mainService/main.c | 37 +++++++++++++++++++++++++++++++++++++
vendor/amlogic/frameworks/services/mainService/main.rc | 9 +++++++++
vendor/amlogic/frameworks/services/mainService/temperature.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
vendor/amlogic/frameworks/services/mainService/temperature.h | 25 +++++++++++++++++++++++++
+++ b/device/amlogic/common/products/tv/product_tv.mk
@@ -30,6 +30,7 @@ PRODUCT_PACKAGES +=
PRODUCT_PACKAGES +=
imageserver
busybox \
- mainService
utility_busybox
+++ b/device/amlogic/common/sepolicy.mk
@@ -56,6 +56,7 @@ BOARD_SEPOLICY_UNION :=
lmkd.te
usbpm.te
seapp_contexts \
-
hdcp_tx22.temainService.te \
hdcp_rx22.te
+++ b/device/amlogic/common/sepolicy/file_contexts
@@ -63,6 +63,7 @@
/system/bin/usbtestpm u:object_r:usbpm_exec:s0
/system/bin/hdcp_tx22 u:object_r:hdcp_tx22_exec:s0
/system/bin/hdcp_rx22 u:object_r:hdcp_rx22_exec:s0
+/system/bin/mainService u:object_r:main_service_exec:s0
/sys/class/audiodsp/digital_raw u:object_r:sysfs_xbmc:s0
/sys/class/video/disable_video u:object_r:sysfs_xbmc:s0
+++ b/device/amlogic/common/sepolicy/mainService.te
@@ -0,0 +1,4 @@
+type main_service, domain;^M
+type main_service_exec, exec_type, file_type;^M
+^M
+init_daemon_domain(main_service)
\ No newline at end of file
+++ b/device/customer/r34tv/init.amlogic.rc
@@ -459,6 +459,14 @@ service tvd /system/bin/tvserver
#on property:init.svc.bootanim=stopped
start tvd
+service main_service /system/bin/mainService
- class main
- user root
- group root
- seclabel u:r:main_service:s0
+#on property:sys.boot_completed=1
+# start mainService
diff --git a/vendor/amlogic/frameworks/services/mainService/Android.mk b/vendor/amlogic/frameworks/services/mainService/Android.mk
new file mode 100755
index 0000000…98016ae
— /dev/null
+++ b/vendor/amlogic/frameworks/services/mainService/Android.mk
@@ -0,0 +1,22 @@
+LOCAL_PATH := $(call my-dir)^M
+include KaTeX parse error: Expected 'EOF', got '#' at position 52: …mainService^M +#̲LOCAL_INIT_RC :…(LOCAL_MODULE)"^M
+^M
+#stm patch^M
+ifeq ($(AUTO_POWER_DOWN),true)^M
+LOCAL_CFLAGS += -DAUTO_POWER_DOWN^M
+endif^M
+^M
+LOCAL_SRC_FILES := main.c adc.c temperature.c^M
+LOCAL_C_INCLUDES += $(LOCAL_PATH)^M
+LOCAL_MULTILIB := 32^M
+^M
+LOCAL_SHARED_LIBRARIES := libcutils libutils liblog libm libdl^M
+LOCAL_MODULE_PATH := $(PRODUCT_OUT)/system/bin^M
+include $(BUILD_EXECUTABLE)^M
+^M
diff --git a/vendor/amlogic/frameworks/services/mainService/adc.c b/vendor/amlogic/frameworks/services/mainService/adc.c
new file mode 100755
index 0000000…096f021
— /dev/null
+++ b/vendor/amlogic/frameworks/services/mainService/adc.c
@@ -0,0 +1,70 @@
+#include <adc.h>^M
+^M
+//ch0~ch7^M
+/**^M
+int adcfd[7] = {0};^M
+int getAdcVal(unsigned int chan){^M
-
int adcVal;^M
-
int ret;^M
-
char buf[32]={0};^M
-
//const char* chanString = toSting(chan);^M
-
if(chan > 7)return -1;^M
-
if(adcfd[chan]==0){^M
-
//adcfd[chan] = open(strcat(adcPath,chanString),O_RDONLY);dest必须是数组^M
-
//adcfd[chan] = open(adcPath toSting(chan),O_RDONLY); toSting 变量是不可以传的^M
-
//printf("open path = %s\n",adcPath toSting(chan));^M
-
getAdcPath(buf,chan);^M
-
adcfd[chan] = open(buf,O_RDONLY);^M
-
printf("open path = %s |fd = %d\n",buf,adcfd[chan]);^M
-
memset(buf,0,sizeof(buf));^M
-
if(adcfd[chan]<0){^M
-
printf("open err\n");^M
-
return -1;^M
-
}^M
-
}^M
-
^M
-
if(adcfd[chan]!=0){^M
-
ret = read(adcfd[chan],buf ,sizeof(buf));^M
-
//if(ret){^M
-
printf("read err ret=%d adcfd[chan]=%d \n",ret,adcfd[chan]);^M
-
perror ("lgy read buff");^M
-
//return -1;^M
-
//}^M
-
//memcpy(&adcVal,buf,sizeof(int)); ^M
-
adcVal = strtol(buf,NULL,10);^M
-
printf("adcVal = %d\n",adcVal);^M
-
}^M
-
^M
-
return adcVal;^M
+}^M
+**/^M
+static int adcfd = -1;^M
+int getAdcVal(unsigned int chan){^M
-
int adcVal;^M
-
int ret;^M
-
char buf[32]={0};^M
-
//const char* chanString = toSting(chan);^M
-
if(chan > 7)return -1;^M
+^M
-
getAdcPath(buf,chan);^M
-
adcfd = open(buf,O_RDONLY);^M
-
printf("open path = %s |fd = %d\n",buf,adcfd);^M
-
memset(buf,0,sizeof(buf));^M
-
if(adcfd<0){^M
-
printf("open err\n");^M
-
return -1;^M
-
}^M
+^M
-
ret = read(adcfd,buf ,sizeof(buf));^M
-
if(ret<0){^M
-
printf("read err ret=%d adcfd[chan]=%d \n",ret,adcfd);^M
-
perror ("lgy read buff");^M
-
return -1;^M
-
}^M
-
//memcpy(&adcVal,buf,sizeof(int)); ^M
-
adcVal = strtol(buf,NULL,10);^M
-
printf("adcVal = %d\n",adcVal);^M
-
close(adcfd);^M
-
^M
-
return adcVal;^M
+}^M
diff --git a/vendor/amlogic/frameworks/services/mainService/adc.h b/vendor/amlogic/frameworks/services/mainService/adc.h
new file mode 100755
index 0000000…d83344d
— /dev/null
+++ b/vendor/amlogic/frameworks/services/mainService/adc.h
@@ -0,0 +1,20 @@
+#ifndef ADC_H^M
+#define ADC_H^M
+#include <stdio.h>^M
+#include <stdlib.h>^M
+#include <unistd.h>^M
+#include <errno.h>^M
+#include <string.h>^M
+#include <sys/types.h>^M
+#include <sys/stat.h>^M
+#include <fcntl.h>^M
+#include <sys/ioctl.h>^M
+^M
+^M
+//#define adcPath “sys/class/saradc/ch”^M
+//#define getAdcPath(path,chan) path##chan^M
+//#define toSting(x) #x^M
+#define getAdcPath(buf,chan) sprintf(buf, “sys/class/saradc/ch%d”,chan)^M
+^M
+int getAdcVal(unsigned int chan);^M
+#endif
\ No newline at end of file
diff --git a/vendor/amlogic/frameworks/services/mainService/main.c b/vendor/amlogic/frameworks/services/mainService/main.c
new file mode 100755
index 0000000…9711617
— /dev/null
+++ b/vendor/amlogic/frameworks/services/mainService/main.c
@@ -0,0 +1,37 @@
+#include <stdio.h>^M
+#include <stdlib.h>^M
+#include <unistd.h>^M
+#include <errno.h>^M
+#include <string.h>^M
+#include <sys/types.h>^M
+#include <sys/socket.h>^M
+#include <netinet/in.h>^M
+#include <arpa/inet.h>^M
+#include <string.h>^M
+#include <pthread.h>^M
+^M
+#include “temperature.h”^M
+#include "adc.h"s^M
+^M
+void *adc_thread(void *arg){^M
-
int adc_val,temperature;^M
-
while (1) {^M
-
sleep(5);^M
-
adc_val = getAdcVal(1);^M
-
getCurrentTemp(adc_val,&temperature);^M
-
}^M
-
return (void *)0;^M
+}^M
+^M
+int main(int argc, char *argv[]){^M
-
int ret;^M
- pthread_t thread;^M
-
ret = pthread_create(&thread,NULL, adc_thread, NULL);^M
- if (ret < 0) {^M
-
perror("Failt to create thread!");^M
-
exit(-1);^M
- }^M
-
pthread_join(thread, NULL);^M
-
printf("hello world\n");^M
-
return 0 ;^M
- }
\ No newline at end of file
diff --git a/vendor/amlogic/frameworks/services/mainService/main.rc b/vendor/amlogic/frameworks/services/mainService/main.rc
new file mode 100755
index 0000000…96c6cd9
— /dev/null
+++ b/vendor/amlogic/frameworks/services/mainService/main.rc
@@ -0,0 +1,9 @@
+service mainService /system/bin/mainService^M - class main^M
- user root^M
- group root^M
+seclabel u:object_r:mainService_exec:s0^M
+^M
+on property:sys.boot_completed=1^M -
start mainService^M
+^M
diff --git a/vendor/amlogic/frameworks/services/mainService/temperature.c b/vendor/amlogic/frameworks/services/mainService/temperature.c
new file mode 100755
index 0000000…54032c7
— /dev/null
+++ b/vendor/amlogic/frameworks/services/mainService/temperature.c
@@ -0,0 +1,46 @@
+#include “temperature.h”^M
+^M
+int currentTemperatureTemp = MINTEMP;^M
-
^M
+int getCurrentTemp(const int adcValue,int* currentTemp){^M
-
int value = 0;^M
-
int i = 0;^M
-
if(adcValue > tempADCArray[0]){^M
-
*currentTemp= MINTEMP;^M
-
return 0;^M
-
}^M
-
//if(adcValue < 79){^M
-
// *currentTemp = 80;^M
-
// return HI_SUCCESS;^M
-
//}^M
-
for (i;i<MAXLENGTH;i++ ){^M
-
if(i==MAXLENGTH-1){^M
-
if(adcValue <=tempADCArray[i+1]){^M
-
*currentTemp= MINTEMP+i;^M
-
break;^M
-
}^M
-
}else {^M
-
if(adcValue <= tempADCArray[i]&& adcValue > tempADCArray[i+1]){^M
-
*currentTemp= MINTEMP+i;^M
-
break;^M
-
}^M
-
}^M
-
}^M
-
value = *currentTemp - currentTemperatureTemp;^M
-
printf("currentTemp start: %d %d\n", *currentTemp,value);^M
-
if(*currentTemp > currentTemperatureTemp ^M
-
&& (value>2 && value<12)){^M
-
//保证温度上升显示不跳跃^M
-
//*currentTemp -=3;^M
-
//*currentTemp -=(value-1);^M
-
//*currentTemp -= 2;^M
-
//currentTemperatureTemp = *currentTemp;^M
-
currentTemperatureTemp+=2;^M
-
*currentTemp = currentTemperatureTemp;^M
-
printf("currentTemp change currentTemperatureTemp: %d %d %d\n", *currentTemp,value,currentTemperatureTemp);^M
-
}else{^M
-
currentTemperatureTemp = *currentTemp;^M
-
printf("currentTemp, 3333333 currentTemperatureTemp: %d %d %d\n", *currentTemp,value,currentTemperatureTemp);^M
-
}^M
-
return 0;^M
+}
\ No newline at end of file
diff --git a/vendor/amlogic/frameworks/services/mainService/temperature.h b/vendor/amlogic/frameworks/services/mainService/temperature.h
new file mode 100755
index 0000000…19f54f1
— /dev/null
+++ b/vendor/amlogic/frameworks/services/mainService/temperature.h
@@ -0,0 +1,25 @@
+#ifndef TEMPERATURE_H^M
+#define TEMPERATURE_H^M
+^M
+#include <stdio.h>^M
+#include <stdlib.h>^M
+#include <unistd.h>^M
+#include <errno.h>^M
+#include <string.h>^M
+#include <sys/types.h>^M
+^M
+#define MAXLENGTH 60^M
+#define MINTEMP 21^M
+#define MAXTEMP 80^M
+^M
- static const int tempADCArray[MAXLENGTH] = {^M
-
731,722,712,707,698,688,678,663,658,648,^M
-
638,628,618,608,598,587,577,567,559,549,^M
-
536,526,516,506,496,487,482,467,462,447,^M
-
442,433,428,419,410,405,396,387,381,373,^M
-
364, 350, 341, 333, 325, 312, 303, 295, 288, 281,^M
-
274, 268, 261, 255, 248, 242,236,230,224,216};^M
-
^M
+int getCurrentTemp(const int adcValue,int* currentTemp);^M
+^M
+#endif