thermal: Add thermal logging daemon
authorWei Wang <wvw@google.com>
Wed, 20 Nov 2019 20:00:21 +0000 (12:00 -0800)
committerFrancescodario Cuzzocrea <bosconovic@gmail.com>
Tue, 22 Dec 2020 10:36:36 +0000 (11:36 +0100)
Bug: 126562025
Bug: 144859663
Test: build and check thermal logging
Change-Id: I996546110f4d66b3ff8052cb46000fe0e5f7b0da

hidl/thermal/Android.bp
hidl/thermal/init.thermal.logging.sh [new file with mode: 0755]
hidl/thermal/samsung-thermal-logd.rc [new file with mode: 0644]

index 5fbad22bab4983c3d4f4d7a81aa25b0b4af9c7ff..f5e06463e1fffae67daa9bccaf0147782eeb7fea 100644 (file)
@@ -41,6 +41,15 @@ cc_binary {
     "clang-analyzer-security*",
   ],
   tidy_flags: [
-      "-warnings-as-errors=android-*,clang-analyzer-security*,cert-*"
+    "-warnings-as-errors=android-*,clang-analyzer-security*,cert-*"
+  ],
+}
+
+sh_binary {
+  name: "thermal_logd.samsung",
+  src: "init.thermal.logging.sh",
+  vendor: true,
+  init_rc: [
+    "samsung-thermal-logd.rc",
   ],
 }
diff --git a/hidl/thermal/init.thermal.logging.sh b/hidl/thermal/init.thermal.logging.sh
new file mode 100755 (executable)
index 0000000..de385ab
--- /dev/null
@@ -0,0 +1,25 @@
+#!/vendor/bin/sh
+
+if [ $# -eq 1 ]; then
+  interval=$1
+else
+  exit 1
+fi
+
+while true
+do
+  logline="tz:"
+  for f in /sys/class/thermal/thermal*
+  do
+    temp=`cat $f/temp`
+    logline+="|$temp"
+  done
+  logline+=" cdev:"
+  for f in /sys/class/thermal/cooling_device*
+  do
+    cur_state=`cat $f/cur_state`
+    logline+="|$cur_state"
+  done
+  log -p w -t THERMAL_LOG $logline
+  sleep $interval
+done
diff --git a/hidl/thermal/samsung-thermal-logd.rc b/hidl/thermal/samsung-thermal-logd.rc
new file mode 100644 (file)
index 0000000..f973cbc
--- /dev/null
@@ -0,0 +1,14 @@
+on property:persist.vendor.log.thermal=1
+    start vendor.thermal.logd
+
+on property:persist.vendor.log.thermal=0
+    stop vendor.thermal.logd
+
+on property:persist.vendor.log.thermal=1 && property:persist.vendor.log.thermal.interval=*
+    restart vendor.thermal.logd
+
+service vendor.thermal.logd /vendor/bin/thermal_logd.samsung ${persist.vendor.log.thermal.interval:-5}
+    class main
+    user root
+    group root system
+    disabled