summaryrefslogtreecommitdiff
path: root/tilt
diff options
context:
space:
mode:
authorZhengyin Qian <qianzy@google.com>2015-12-15 10:25:10 -0800
committerZhengyin Qian <qianzy@google.com>2015-12-15 10:25:10 -0800
commit68dc9e70b79dacddc4e0bf00af0de7f764b04eed (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /tilt
parent2f7df3191d933bc5df29ab12fed58e3b6a8b86dc (diff)
downloadsensors-n-iot-preview-4.tar.gz
remove robby sensor codeHEADandroid-wear-p-preview-2android-wear-o-preview-4android-wear-o-preview-3android-wear-n-preview-3android-wear-n-preview-2android-wear-n-preview-1android-wear-9.0.0_r9android-wear-9.0.0_r8android-wear-9.0.0_r7android-wear-9.0.0_r6android-wear-9.0.0_r5android-wear-9.0.0_r4android-wear-9.0.0_r34android-wear-9.0.0_r33android-wear-9.0.0_r32android-wear-9.0.0_r31android-wear-9.0.0_r30android-wear-9.0.0_r3android-wear-9.0.0_r29android-wear-9.0.0_r28android-wear-9.0.0_r27android-wear-9.0.0_r26android-wear-9.0.0_r25android-wear-9.0.0_r24android-wear-9.0.0_r23android-wear-9.0.0_r22android-wear-9.0.0_r21android-wear-9.0.0_r20android-wear-9.0.0_r2android-wear-9.0.0_r19android-wear-9.0.0_r18android-wear-9.0.0_r17android-wear-9.0.0_r16android-wear-9.0.0_r15android-wear-9.0.0_r14android-wear-9.0.0_r13android-wear-9.0.0_r12android-wear-9.0.0_r11android-wear-9.0.0_r10android-wear-9.0.0_r1android-wear-8.1.0_r1android-wear-8.0.0_r1android-wear-7.1.1_r1android-vts-9.0_r9android-vts-9.0_r8android-vts-9.0_r7android-vts-9.0_r6android-vts-9.0_r5android-vts-9.0_r4android-vts-9.0_r19android-vts-9.0_r18android-vts-9.0_r17android-vts-9.0_r16android-vts-9.0_r15android-vts-9.0_r14android-vts-9.0_r13android-vts-9.0_r12android-vts-9.0_r11android-vts-9.0_r10android-vts-8.1_r9android-vts-8.1_r8android-vts-8.1_r7android-vts-8.1_r6android-vts-8.1_r5android-vts-8.1_r4android-vts-8.1_r3android-vts-8.1_r14android-vts-8.1_r13android-vts-8.1_r12android-vts-8.1_r11android-vts-8.1_r10android-vts-8.0_r9android-vts-8.0_r8android-vts-8.0_r7android-vts-8.0_r6android-vts-8.0_r2android-vts-8.0_r13android-vts-8.0_r12android-vts-8.0_r11android-vts-8.0_r10android-vts-8.0_r1android-security-9.0.0_r76android-security-9.0.0_r75android-security-9.0.0_r74android-security-9.0.0_r73android-security-9.0.0_r72android-security-9.0.0_r71android-security-9.0.0_r70android-security-9.0.0_r69android-security-9.0.0_r68android-security-9.0.0_r67android-security-9.0.0_r66android-security-9.0.0_r65android-security-9.0.0_r64android-security-9.0.0_r63android-security-9.0.0_r62android-security-8.1.0_r93android-security-8.1.0_r92android-security-8.1.0_r91android-security-8.1.0_r90android-security-8.1.0_r89android-security-8.1.0_r88android-security-8.1.0_r87android-security-8.1.0_r86android-security-8.1.0_r85android-security-8.1.0_r84android-security-8.1.0_r83android-security-8.1.0_r82android-security-8.0.0_r54android-security-8.0.0_r53android-security-8.0.0_r52android-p-preview-3android-p-preview-2android-p-preview-1android-o-preview-4android-o-preview-3android-o-preview-2android-o-preview-1android-o-mr1-preview-2android-o-mr1-preview-1android-o-mr1-iot-release-smart-display-r9android-o-mr1-iot-release-smart-display-r8android-o-mr1-iot-release-smart-display-r5android-o-mr1-iot-release-smart-display-r40.1Jandroid-o-mr1-iot-release-smart-display-r4android-o-mr1-iot-release-smart-display-r39android-o-mr1-iot-release-smart-display-r30android-o-mr1-iot-release-smart-display-r3android-o-mr1-iot-release-smart-display-r22android-o-mr1-iot-release-smart-display-r14android-o-mr1-iot-release-smart-clock-r6android-o-mr1-iot-release-smart-clock-r2android-o-mr1-iot-release-smart-clock-fsiandroid-o-mr1-iot-release-smart-clock-fcsandroid-o-mr1-iot-release-cube_r2android-o-mr1-iot-release-cube-fsiandroid-o-mr1-iot-release-cube-fcsandroid-o-mr1-iot-release-1.0.8android-o-mr1-iot-release-1.0.7android-o-mr1-iot-release-1.0.5android-o-mr1-iot-release-1.0.4android-o-mr1-iot-release-1.0.3android-o-mr1-iot-release-1.0.2android-o-mr1-iot-release-1.0.14android-o-mr1-iot-release-1.0.13android-o-mr1-iot-release-1.0.12android-o-mr1-iot-release-1.0.10android-o-mr1-iot-release-1.0.1android-o-mr1-iot-release-1.0.0android-o-mr1-iot-preview-8android-o-mr1-iot-preview-7android-o-mr1-iot-preview-6android-o-iot-preview-5android-n-preview-5android-n-preview-4android-n-preview-3android-n-preview-2android-n-mr2-preview-2android-n-mr2-preview-1android-n-mr1-preview-2android-n-mr1-preview-1android-n-iot-release-smart-display-r2android-n-iot-release-smart-displayandroid-n-iot-release-polk-at1android-n-iot-release-lg-thinq-wk7android-n-iot-release-ihome-igv1android-n-iot-preview-4android-n-iot-preview-2android-cts_7.1_r1android-cts-9.0_r9android-cts-9.0_r8android-cts-9.0_r7android-cts-9.0_r6android-cts-9.0_r5android-cts-9.0_r4android-cts-9.0_r3android-cts-9.0_r20android-cts-9.0_r2android-cts-9.0_r19android-cts-9.0_r18android-cts-9.0_r17android-cts-9.0_r16android-cts-9.0_r15android-cts-9.0_r14android-cts-9.0_r13android-cts-9.0_r12android-cts-9.0_r11android-cts-9.0_r10android-cts-9.0_r1android-cts-8.1_r9android-cts-8.1_r8android-cts-8.1_r7android-cts-8.1_r6android-cts-8.1_r5android-cts-8.1_r4android-cts-8.1_r3android-cts-8.1_r25android-cts-8.1_r24android-cts-8.1_r23android-cts-8.1_r22android-cts-8.1_r21android-cts-8.1_r20android-cts-8.1_r2android-cts-8.1_r19android-cts-8.1_r18android-cts-8.1_r17android-cts-8.1_r16android-cts-8.1_r15android-cts-8.1_r14android-cts-8.1_r13android-cts-8.1_r12android-cts-8.1_r11android-cts-8.1_r10android-cts-8.1_r1android-cts-8.0_r9android-cts-8.0_r8android-cts-8.0_r7android-cts-8.0_r6android-cts-8.0_r5android-cts-8.0_r4android-cts-8.0_r3android-cts-8.0_r26android-cts-8.0_r25android-cts-8.0_r24android-cts-8.0_r23android-cts-8.0_r22android-cts-8.0_r21android-cts-8.0_r20android-cts-8.0_r2android-cts-8.0_r19android-cts-8.0_r18android-cts-8.0_r17android-cts-8.0_r16android-cts-8.0_r15android-cts-8.0_r14android-cts-8.0_r13android-cts-8.0_r12android-cts-8.0_r11android-cts-8.0_r10android-cts-8.0_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-cts-7.0_r9android-cts-7.0_r8android-cts-7.0_r7android-cts-7.0_r6android-cts-7.0_r5android-cts-7.0_r4android-cts-7.0_r33android-cts-7.0_r32android-cts-7.0_r31android-cts-7.0_r30android-cts-7.0_r3android-cts-7.0_r29android-cts-7.0_r28android-cts-7.0_r27android-cts-7.0_r26android-cts-7.0_r25android-cts-7.0_r24android-cts-7.0_r23android-cts-7.0_r22android-cts-7.0_r21android-cts-7.0_r20android-cts-7.0_r2android-cts-7.0_r19android-cts-7.0_r18android-cts-7.0_r17android-cts-7.0_r16android-cts-7.0_r15android-cts-7.0_r14android-cts-7.0_r13android-cts-7.0_r12android-cts-7.0_r11android-cts-7.0_r10android-cts-7.0_r1android-9.0.0_r9android-9.0.0_r8android-9.0.0_r7android-9.0.0_r61android-9.0.0_r60android-9.0.0_r6android-9.0.0_r59android-9.0.0_r58android-9.0.0_r57android-9.0.0_r56android-9.0.0_r55android-9.0.0_r54android-9.0.0_r53android-9.0.0_r52android-9.0.0_r51android-9.0.0_r50android-9.0.0_r5android-9.0.0_r49android-9.0.0_r48android-9.0.0_r47android-9.0.0_r46android-9.0.0_r45android-9.0.0_r44android-9.0.0_r43android-9.0.0_r42android-9.0.0_r41android-9.0.0_r40android-9.0.0_r39android-9.0.0_r38android-9.0.0_r37android-9.0.0_r36android-9.0.0_r35android-9.0.0_r34android-9.0.0_r33android-9.0.0_r32android-9.0.0_r31android-9.0.0_r30android-9.0.0_r3android-9.0.0_r22android-9.0.0_r21android-9.0.0_r20android-9.0.0_r2android-9.0.0_r19android-9.0.0_r18android-9.0.0_r17android-9.0.0_r16android-9.0.0_r12android-9.0.0_r11android-9.0.0_r10android-9.0.0_r1android-8.1.0_r9android-8.1.0_r81android-8.1.0_r80android-8.1.0_r8android-8.1.0_r79android-8.1.0_r78android-8.1.0_r77android-8.1.0_r76android-8.1.0_r75android-8.1.0_r74android-8.1.0_r73android-8.1.0_r72android-8.1.0_r71android-8.1.0_r70android-8.1.0_r7android-8.1.0_r69android-8.1.0_r68android-8.1.0_r67android-8.1.0_r66android-8.1.0_r65android-8.1.0_r64android-8.1.0_r63android-8.1.0_r62android-8.1.0_r61android-8.1.0_r60android-8.1.0_r6android-8.1.0_r53android-8.1.0_r52android-8.1.0_r51android-8.1.0_r50android-8.1.0_r5android-8.1.0_r48android-8.1.0_r47android-8.1.0_r46android-8.1.0_r45android-8.1.0_r43android-8.1.0_r42android-8.1.0_r41android-8.1.0_r40android-8.1.0_r4android-8.1.0_r39android-8.1.0_r38android-8.1.0_r37android-8.1.0_r36android-8.1.0_r35android-8.1.0_r33android-8.1.0_r32android-8.1.0_r31android-8.1.0_r30android-8.1.0_r3android-8.1.0_r29android-8.1.0_r28android-8.1.0_r27android-8.1.0_r26android-8.1.0_r25android-8.1.0_r23android-8.1.0_r22android-8.1.0_r21android-8.1.0_r20android-8.1.0_r2android-8.1.0_r19android-8.1.0_r18android-8.1.0_r17android-8.1.0_r16android-8.1.0_r15android-8.1.0_r14android-8.1.0_r13android-8.1.0_r12android-8.1.0_r11android-8.1.0_r10android-8.1.0_r1android-8.0.0_r9android-8.0.0_r7android-8.0.0_r51android-8.0.0_r50android-8.0.0_r49android-8.0.0_r48android-8.0.0_r47android-8.0.0_r46android-8.0.0_r45android-8.0.0_r44android-8.0.0_r43android-8.0.0_r42android-8.0.0_r41android-8.0.0_r40android-8.0.0_r4android-8.0.0_r39android-8.0.0_r38android-8.0.0_r37android-8.0.0_r36android-8.0.0_r35android-8.0.0_r34android-8.0.0_r33android-8.0.0_r32android-8.0.0_r31android-8.0.0_r30android-8.0.0_r3android-8.0.0_r29android-8.0.0_r28android-8.0.0_r27android-8.0.0_r26android-8.0.0_r25android-8.0.0_r24android-8.0.0_r23android-8.0.0_r22android-8.0.0_r21android-8.0.0_r2android-8.0.0_r17android-8.0.0_r16android-8.0.0_r15android-8.0.0_r13android-8.0.0_r12android-8.0.0_r11android-8.0.0_r10android-8.0.0_r1android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1android-7.0.0_r9android-7.0.0_r8android-7.0.0_r7android-7.0.0_r6android-7.0.0_r5android-7.0.0_r4android-7.0.0_r36android-7.0.0_r35android-7.0.0_r34android-7.0.0_r33android-7.0.0_r32android-7.0.0_r31android-7.0.0_r30android-7.0.0_r3android-7.0.0_r29android-7.0.0_r28android-7.0.0_r27android-7.0.0_r24android-7.0.0_r21android-7.0.0_r19android-7.0.0_r17android-7.0.0_r15android-7.0.0_r14android-7.0.0_r13android-7.0.0_r12android-7.0.0_r11android-7.0.0_r10android-7.0.0_r1android-6.0.1_r68android-6.0.1_r67android-6.0.1_r62android-6.0.1_r54android-6.0.1_r53android-6.0.1_r45android-6.0.1_r25android-6.0.1_r24android-6.0.1_r22android-6.0.1_r21security-pi-releasesecurity-oc-releasesecurity-oc-mr1-releasesdk-releasepie-vts-releasepie-security-releasepie-s2-releasepie-release-2pie-releasepie-r2-s2-releasepie-r2-s1-releasepie-r2-releasepie-qpr3-s1-releasepie-qpr3-releasepie-qpr3-b-releasepie-qpr2-releasepie-qpr1-s3-releasepie-qpr1-s2-releasepie-qpr1-s1-releasepie-qpr1-releasepie-platform-releasepie-gsipie-dr1-releasepie-dr1-devpie-devpie-cuttlefish-testingpie-cts-releasepie-b4s4-releasepie-b4s4-devoreo-vts-releaseoreo-security-releaseoreo-releaseoreo-r6-releaseoreo-r5-releaseoreo-r4-releaseoreo-r3-releaseoreo-r2-releaseoreo-mr1-wear-releaseoreo-mr1-vts-releaseoreo-mr1-security-releaseoreo-mr1-s1-releaseoreo-mr1-releaseoreo-mr1-iot-releaseoreo-mr1-devoreo-mr1-cuttlefish-testingoreo-mr1-cts-releaseoreo-mr1-1.2-iot-releaseoreo-m8-releaseoreo-m7-releaseoreo-m6-s4-releaseoreo-m6-s3-releaseoreo-m6-s2-releaseoreo-m5-releaseoreo-m4-s9-releaseoreo-m4-s8-releaseoreo-m4-s7-releaseoreo-m4-s6-releaseoreo-m4-s5-releaseoreo-m4-s4-releaseoreo-m4-s3-releaseoreo-m4-s2-releaseoreo-m4-s12-releaseoreo-m4-s11-releaseoreo-m4-s10-releaseoreo-m4-s1-releaseoreo-m3-releaseoreo-m2-s5-releaseoreo-m2-s4-releaseoreo-m2-s3-releaseoreo-m2-s2-releaseoreo-m2-s1-releaseoreo-m2-releaseoreo-dr3-releaseoreo-dr2-releaseoreo-dr1-releaseoreo-dr1-devoreo-devoreo-cts-releaseo-previewo-mr1-iot-preview-8o-mr1-iot-preview-7o-mr1-iot-preview-6o-iot-preview-5nougat-releasenougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-devnougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-wear-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-releasenougat-mr0.5-releasenougat-iot-releasenougat-dr1-releasenougat-devnougat-cts-releasenougat-bugfix-releasen-iot-preview-4n-iot-preview-2mastermarshmallow-dr1.6-releasemarshmallow-dr1.5-releasemarshmallow-dr1.5-devmain
In Emerald, robby project's sensor code has been moved to /vendor/intel/robby/sensors Change-Id: Iff11b2f079ba47003637c9a3024f997da34b5b02
Diffstat (limited to 'tilt')
-rw-r--r--tilt/Android.mk90
-rw-r--r--tilt/InputEventReader.cpp116
-rw-r--r--tilt/InputEventReader.h46
-rw-r--r--tilt/SensorBase.cpp160
-rw-r--r--tilt/SensorBase.h98
-rw-r--r--tilt/TiltSensor.cpp144
-rw-r--r--tilt/TiltSensor.h58
-rw-r--r--tilt/sensors.cpp406
-rw-r--r--tilt/sensors.h61
9 files changed, 0 insertions, 1179 deletions
diff --git a/tilt/Android.mk b/tilt/Android.mk
deleted file mode 100644
index 6c5f9d5..0000000
--- a/tilt/Android.mk
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright (C) 2015 Intel Corp
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-ifeq ($(USE_SENSOR_HAL_PREBUILTS),false)
-
-LOCAL_PATH := $(call my-dir)
-
-# HAL module implemenation, not prelinked, and stored in
-# hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.product.board>.so
-include $(CLEAR_VARS)
-
-# ANDROID version check
-MAJOR_VERSION := $(shell echo $(PLATFORM_VERSION) | cut -f1 -d.)
-MINOR_VERSION := $(shell echo $(PLATFORM_VERSION) | cut -f2 -d.)
-
-VERSION_JB := $(shell test $(MAJOR_VERSION) -eq 4 -a $(MINOR_VERSION) -eq 1 && echo true)
-VERSION_JB := $(shell test $(MAJOR_VERSION) -eq 4 -a $(MINOR_VERSION) -eq 2 && echo true)
-VERSION_JB_MR2 := $(shell test $(MAJOR_VERSION) -eq 4 -a $(MINOR_VERSION) -eq 3 && echo true)
-VERSION_KK := $(shell test $(MAJOR_VERSION) -eq 4 -a $(MINOR_VERSION) -eq 4 && echo true)
-VERSION_L := $(shell test $(MAJOR_VERSION) -eq 5 && echo true)
-VERSION_M := $(shell test $(MAJOR_VERSION) -eq 6 && echo true)
-#ANDROID version check END
-
-LOCAL_MODULE := sensor_tilt.robby
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-
-LOCAL_MODULE_TAGS := optional
-# TODO: remove LOG_NDEBUG=0 for production builds, keep it during integration
-LOCAL_CFLAGS := -DLOG_TAG=\"TiltSensor\" -DANDROID_VERSION=$(MAJOR_VERSION)
-
-ifeq ($(VERSION_JB),true)
-LOCAL_CFLAGS += -DANDROID_JB
-endif
-
-ifeq ($(VERSION_JBMR2),true)
-LOCAL_CFLAGS += -DANDROID_JBMR2
-#hal version is greater than and equal 1_0
-LOCAL_CFLAGS += -DHAL_VERSION_GE_1_0
-endif
-
-ifeq ($(VERSION_KK),true)
-LOCAL_CFLAGS += -DANDROID_KK
-#hal version is greater than and equal 1_0
-LOCAL_CFLAGS += -DHAL_VERSION_GE_1_0
-#hal version is greater than 1_0
-LOCAL_CFLAGS += -DHAL_VERSION_GT_1_0
-endif
-
-ifeq ($(VERSION_L),true)
-LOCAL_CFLAGS += -DANDROID_L
-#hal version is greater than and equal 1_0
-LOCAL_CFLAGS += -DHAL_VERSION_GE_1_0
-#hal version is greater than 1_0
-LOCAL_CFLAGS += -DHAL_VERSION_GT_1_0
-endif
-
-ifeq ($(VERSION_M),true)
-LOCAL_CFLAGS += -DANDROID_M
-#hal version is greater than and equal 1_0
-LOCAL_CFLAGS += -DHAL_VERSION_GE_1_0
-#hal version is greater than 1_0
-LOCAL_CFLAGS += -DHAL_VERSION_GT_1_0
-endif
-
-##LOCAL_C_INCLUDES += hardware/invensense/libsensors_iio
-LOCAL_SRC_FILES := \
- sensors.cpp \
- InputEventReader.cpp \
- TiltSensor.cpp \
- SensorBase.cpp
-
-LOCAL_SHARED_LIBRARIES := liblog libutils libdl
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif # USE_SENSOR_HAL_PREBUILTS
diff --git a/tilt/InputEventReader.cpp b/tilt/InputEventReader.cpp
deleted file mode 100644
index 1812cf5..0000000
--- a/tilt/InputEventReader.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2015 Intel Corp
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <poll.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <linux/input.h>
-#include <cutils/log.h>
-#include "InputEventReader.h"
-
-
-
-struct input_event;
-
-InputEventCircularReader::InputEventCircularReader(size_t numEvents)
- : mBuffer(new input_event[numEvents * 2]),
- mBufferEnd(mBuffer + numEvents),
- mHead(mBuffer),
- mCurr(mBuffer),
- mFreeSpace(numEvents)
-{
- FUNC_LOG;
- mLastFd = -1;
-}
-
-InputEventCircularReader::~InputEventCircularReader()
-{
- FUNC_LOG;
- delete [] mBuffer;
-}
-
-/* TODO: clear DEBUG flag on production builds, keep it during integration */
-#define INPUT_EVENT_DEBUG (0)
-ssize_t InputEventCircularReader::fill(int fd)
-{
- FUNC_LOG;
- size_t numEventsRead = 0;
- mLastFd = fd;
-
- LOGV_IF(INPUT_EVENT_DEBUG,
- "DEBUG:%s enter, fd=%d\n", __PRETTY_FUNCTION__, fd);
- if (mFreeSpace) {
- const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event));
- if (nread < 0 || nread % sizeof(input_event)) {
- /* LOGE("Partial event received nread=%d, required=%d",
- nread, sizeof(input_event));
- LOGE("FD trying to read is: %d"); */
- /* we got a partial event!! */
- if (INPUT_EVENT_DEBUG) {
- LOGV_IF(nread < 0, "DEBUG:%s exit nread < 0\n",
- __PRETTY_FUNCTION__);
- LOGV_IF(nread % sizeof(input_event),
- "DEBUG:%s exit nread %% sizeof(input_event)\n",
- __PRETTY_FUNCTION__);
- }
- return (nread < 0 ? -errno : -EINVAL);
- }
-
- numEventsRead = nread / sizeof(input_event);
- if (numEventsRead) {
- mHead += numEventsRead;
- mFreeSpace -= numEventsRead;
- if (mHead > mBufferEnd) {
- size_t s = mHead - mBufferEnd;
- memcpy(mBuffer, mBufferEnd, s * sizeof(input_event));
- mHead = mBuffer + s;
- }
- }
- }
-
- LOGV_IF(INPUT_EVENT_DEBUG, "DEBUG:%s exit, numEventsRead:%d\n",
- __PRETTY_FUNCTION__, numEventsRead);
- return numEventsRead;
-}
-
-ssize_t InputEventCircularReader::readEvent(input_event const** events)
-{
- FUNC_LOG;
- *events = mCurr;
- ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace;
- LOGV_IF(INPUT_EVENT_DEBUG, "DEBUG:%s fd:%d, available:%d\n",
- __PRETTY_FUNCTION__, mLastFd, (int)available);
- return (available ? 1 : 0);
-}
-
-void InputEventCircularReader::next()
-{
- FUNC_LOG;
- mCurr++;
- mFreeSpace++;
- if (mCurr >= mBufferEnd)
- mCurr = mBuffer;
-
- ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace;
- LOGV_IF(INPUT_EVENT_DEBUG, "DEBUG:%s fd:%d, still available:%d\n",
- __PRETTY_FUNCTION__, mLastFd, (int)available);
-}
-
diff --git a/tilt/InputEventReader.h b/tilt/InputEventReader.h
deleted file mode 100644
index 6e4350b..0000000
--- a/tilt/InputEventReader.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015 Intel Corp
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_INPUT_EVENT_READER_H
-#define ANDROID_INPUT_EVENT_READER_H
-
-#include <stdint.h>
-#include <errno.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include "SensorBase.h"
-
-
-struct input_event;
-
-class InputEventCircularReader
-{
- struct input_event* const mBuffer;
- struct input_event* const mBufferEnd;
- struct input_event* mHead;
- struct input_event* mCurr;
- ssize_t mFreeSpace;
- int mLastFd;
-
-public:
- InputEventCircularReader(size_t numEvents);
- ~InputEventCircularReader();
- ssize_t fill(int fd);
- ssize_t readEvent(input_event const** events);
- void next();
-};
-#endif // ANDROID_INPUT_EVENT_READER_H
diff --git a/tilt/SensorBase.cpp b/tilt/SensorBase.cpp
deleted file mode 100644
index cba4831..0000000
--- a/tilt/SensorBase.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-* Copyright (C) 2015 Intel Corp
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
-#include <poll.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/select.h>
-#include <cutils/log.h>
-#include <linux/input.h>
-#include "SensorBase.h"
-
-
-SensorBase::SensorBase(const char* dev_name,
- const char* data_name) : dev_name(dev_name),
- data_name(data_name),
- dev_fd(-1),
- data_fd(-1)
-{
- /* FUNC_LOG; */
- ALOGV("%s(): dev_name=%s, data_name=%s ", __func__, dev_name, data_name);
-
- if (data_name)
- data_fd = openInput(data_name);
-
-}
-
-SensorBase::~SensorBase() {
- FUNC_LOG;
- if (data_fd >= 0)
- close(data_fd);
-
- if (dev_fd >= 0)
- close(dev_fd);
-
-}
-
-int SensorBase::open_device() {
- FUNC_LOG;
- if (dev_fd<0 && dev_name) {
- dev_fd = open(dev_name, O_RDONLY);
- LOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno));
- }
- return 0;
-}
-
-int SensorBase::close_device() {
- FUNC_LOG;
- if (dev_fd >= 0) {
- close(dev_fd);
- dev_fd = -1;
- }
- return 0;
-}
-
-int SensorBase::getFd() const {
- FUNC_LOG;
- if (!data_name)
- return dev_fd;
-
- return data_fd;
-}
-
-int SensorBase::setDelay(int32_t handle, int64_t ns) {
- FUNC_LOG;
- return 0;
-}
-
-bool SensorBase::hasPendingEvents() const {
- FUNC_LOG;
- return false;
-}
-
-int64_t SensorBase::getTimestamp() {
- FUNC_LOG;
- struct timespec t;
- t.tv_sec = t.tv_nsec = 0;
- clock_gettime(CLOCK_MONOTONIC, &t);
- return int64_t(t.tv_sec) * 1000000000LL + t.tv_nsec;
-}
-
-int SensorBase::openInput(const char* inputName) {
- FUNC_LOG;
- int fd = -1;
- const char *dirname = "/dev/input";
- char devname[PATH_MAX];
- char *filename;
- DIR *dir;
- struct dirent *de;
- dir = opendir(dirname);
- if(dir == NULL)
- return -1;
- strcpy(devname, dirname);
- filename = devname + strlen(devname);
- *filename++ = '/';
- while((de = readdir(dir))) {
- if(de->d_name[0] == '.' &&
- (de->d_name[1] == '\0' ||
- (de->d_name[1] == '.' && de->d_name[2] == '\0')))
- continue;
- strcpy(filename, de->d_name);
- fd = open(devname, O_RDONLY);
- LOGV_IF(EXTRA_VERBOSE, "path open %s", devname);
- LOGI("path open %s", devname);
- if (fd >= 0) {
- char name[80];
- if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1)
- name[0] = '\0';
-
- LOGV_IF(EXTRA_VERBOSE, "name read %s", name);
- if (!strcmp(name, inputName)) {
- strcpy(input_name, filename);
- break;
- } else {
- close(fd);
- fd = -1;
- }
- }
- }
- closedir(dir);
- LOGE_IF(fd < 0, "couldn't find '%s' input device", inputName);
- return fd;
-}
-
-int SensorBase::enable(int32_t handle, int enabled)
-{
- FUNC_LOG;
- return 0;
-}
-
-int SensorBase::isActivated(int /* handle */)
-{
- FUNC_LOG;
- return 0;
-}
-
-#ifdef HAL_VERSION_GT_1_0
-int SensorBase::batch(int handle, int flags, int64_t period_ns, int64_t timeout)
-{
- FUNC_LOG;
- return 0;
-}
-#endif
diff --git a/tilt/SensorBase.h b/tilt/SensorBase.h
deleted file mode 100644
index 7c2913c..0000000
--- a/tilt/SensorBase.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-* Copyright (C) 2015 Intel Corp
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#ifndef ANDROID_SENSOR_BASE_H
-#define ANDROID_SENSOR_BASE_H
-
-#include <stdint.h>
-#include <errno.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#if ANDROID_VERSION >= 5
-/* #warning "build for Wear" */
-#define LOGV_IF ALOGV_IF
-#define LOGE_IF ALOGE_IF
-#define LOGI_IF ALOGI_IF
-#define LOGI ALOGI
-#define LOGE ALOGE
-#define LOGV ALOGV
-#define LOGW ALOGW
-#else
-#warning "build for ICS or earlier version"
-#endif
-
-/* Log enablers, each of these independent */
-
-/* TODO: clear all logging below on production build, keep it during integration */
-#define PROCESS_VERBOSE (1) /* process log messages */
-#define EXTRA_VERBOSE (1) /* verbose log messages */
-#define SYSFS_VERBOSE (1) /* log sysfs interactions as cat/echo for repro
-purpose on a shell */
-#define FUNC_ENTRY (1) /* log entry in all one-time functions */
-
-/* Note that enabling this logs may affect performance */
-#define HANDLER_ENTRY (1) /* log entry in all handler functions */
-#define ENG_VERBOSE (1) /* log some a lot more info about the internals */
-#define INPUT_DATA (1) /* log the data input from the events */
-#define HANDLER_DATA (1) /* log the data fetched from the handlers */
-
-#define FUNC_LOG \
- LOGV("%s (hardware/intel/sensors/tilt)", __PRETTY_FUNCTION__)
-#define VFUNC_LOG \
- LOGV_IF(FUNC_ENTRY, "Entering function '%s' (hardware/intel/sensors/tilt)", __PRETTY_FUNCTION__)
-#define VHANDLER_LOG \
- LOGV_IF(HANDLER_ENTRY, "Entering handler '%s' (hardware/intel/sensors/tilt)", __PRETTY_FUNCTION__)
-#define CALL_MEMBER_FN(pobject, ptrToMember) ((pobject)->*(ptrToMember))
-
-#define MAX_SYSFS_NAME_LEN (100)
-#define IIO_BUFFER_LENGTH (480)
-
-
-struct sensors_event_t;
-
-class SensorBase {
-protected:
- const char *dev_name;
- const char *data_name;
- char input_name[PATH_MAX];
- int dev_fd;
- int data_fd;
-
- int openInput(const char* inputName);
- static int64_t getTimestamp();
- static int64_t timevalToNano(timeval const& t) {
- return t.tv_sec * 1000000000LL + t.tv_usec * 1000;
- }
-
- int open_device();
- int close_device();
-
-public:
- SensorBase(const char* dev_name, const char* data_name);
- virtual ~SensorBase();
- virtual int readEvents(sensors_event_t* data, int count) = 0;
- virtual bool hasPendingEvents() const;
- virtual int getFd() const;
- virtual int setDelay(int32_t handle, int64_t ns);
- virtual int enable(int32_t handle, int enabled);
- virtual int isActivated(int handle);
-#ifdef HAL_VERSION_GT_1_0
- virtual int batch(int handle, int flags, int64_t period_ns, int64_t timeout);
-#endif
-};
-
-#endif // ANDROID_SENSOR_BASE_H
diff --git a/tilt/TiltSensor.cpp b/tilt/TiltSensor.cpp
deleted file mode 100644
index 710882b..0000000
--- a/tilt/TiltSensor.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2015 Intel Corp
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <fcntl.h>
-#include <errno.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-#include <poll.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/select.h>
-#include <cutils/log.h>
-#include <cutils/properties.h>
-
-#include "TiltSensor.h"
-
-TiltSensor::TiltSensor()
- : SensorBase(NULL, "lis3dsh_acc"),
- mEnabled(0),
- mInputReader(4)
-{
- mPendingEvent.version = sizeof(sensors_event_t);
- mPendingEvent.sensor = ID_T;
- mPendingEvent.type = SENSOR_TYPE_WRIST_TILT_GESTURE;
- memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
-}
-
-TiltSensor::~TiltSensor() {
- if (mEnabled) {
- enable(0, 0);
- }
-}
-
-int TiltSensor::enable(int32_t /* handle */, int en)
-{
- int ret = 0;
- int flags = en ? 1 : 0;
- char sysfs_path[SYSFS_MAX_PATH_LEN];
-
- if (flags != mEnabled) {
- int fd;
- char buf[2];
-
- snprintf(sysfs_path, SYSFS_MAX_PATH_LEN, "%s/%s", INPUT_SYSFS_BASE, ENABLE_DEVICE);
- fd = open(sysfs_path, O_RDWR);
- if (fd > 0) {
- buf[1] = 0;
- if (flags)
- buf[0] = '1';
- else
- buf[0] = '0';
- write(fd, buf, sizeof(buf));
- close(fd);
- } else {
- ret = -1;
- goto out;
- }
-
- snprintf(sysfs_path, SYSFS_MAX_PATH_LEN, "%s/%s", INPUT_SYSFS_BASE, ENABLE_INTERRUPT_OUTPUT);
- fd = open(sysfs_path, O_RDWR);
- if (fd > 0) {
- buf[1] = 0;
- if (flags)
- buf[0] = '2'; /* 3: enable int1 and int2; 2: enable int1; 1: enable int2; 0: disbale */
- else
- buf[0] = '0';
- write(fd, buf, sizeof(buf));
- close(fd);
- } else {
- ret = -1;
- goto out;
- }
-
- snprintf(sysfs_path, SYSFS_MAX_PATH_LEN, "%s/%s", INPUT_SYSFS_BASE, ENABLE_STATE_PROG);
- fd = open(sysfs_path, O_RDWR);
- if(fd > 0) {
- buf[1] = 0;
- if (flags)
- buf[0] = '2'; /* 3: enable SM1 and SM2; 2: enable SM1; 1: enable SM2; 0: disbale */
- else
- buf[0] = '0';
- write(fd, buf, sizeof(buf));
- close(fd);
- mEnabled = flags;
- } else {
- ret = -1;
- }
- }
-out:
- return ret;
-}
-
-int TiltSensor::isActivated(int /* handle */)
-{
- return mEnabled;
-}
-
-int TiltSensor::readEvents(sensors_event_t* data, int count)
-{
- if (count < 1)
- return -EINVAL;
-
- ssize_t n = mInputReader.fill(data_fd);
- if (n < 0)
- return n;
-
- int numEventReceived = 0;
- input_event const* event;
-
- while (count && mInputReader.readEvent(&event)) {
- int type = event->type;
- if (type == EV_MSC) {
- mPendingEvent.data[0] = 1.0f;
- /*mPendingEvent.data[event->code] = event->value;*/
- } else if (type == EV_SYN) {
- mPendingEvent.timestamp = timevalToNano(event->time);
- if (mEnabled) {
- *data++ = mPendingEvent;
- count--;
- numEventReceived++;
- }
- } else {
- ALOGE("TiltSensor: unknown event (type=%d, code=%d)",
- type, event->code);
- }
- mInputReader.next();
- }
-
- return numEventReceived;
-}
diff --git a/tilt/TiltSensor.h b/tilt/TiltSensor.h
deleted file mode 100644
index 707ba8b..0000000
--- a/tilt/TiltSensor.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2015 Intel Corp
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_TILT_SENSOR_H
-#define ANDROID_TILT_SENSOR_H
-
-#include <stdint.h>
-#include <errno.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include "sensors.h"
-#include "SensorBase.h"
-#include "InputEventReader.h"
-
-#define SYSFS_MAX_PATH_LEN 64
-#define INPUT_SYSFS_BASE "/sys/class/i2c-adapter/i2c-4/4-001e"
-#define POLL_PERIOD_MS "poll_period_ms"
-#define RANGE "range"
-#define ENABLE_DEVICE "enable_device"
-#define ENABLE_INTERRUPT_OUTPUT "enable_interrupt_output"
-#define ENABLE_STATE_PROG "enable_state_prog"
-#ifdef TILT_DEBUG
-#define REG_VALUE "reg_value"
-#define REG_ADDR "reg_addr"
-#endif
-
-
-struct input_event;
-
-class TiltSensor : public SensorBase {
-public:
- TiltSensor();
- virtual ~TiltSensor();
-
- virtual int readEvents(sensors_event_t* data, int count);
- virtual int enable(int32_t handle, int enabled);
- virtual int isActivated(int handle);
-
-private:
- int mEnabled;
- InputEventCircularReader mInputReader;
- sensors_event_t mPendingEvent;
-};
-#endif // ANDROID_TILT_SENSOR_H
diff --git a/tilt/sensors.cpp b/tilt/sensors.cpp
deleted file mode 100644
index 0374cd0..0000000
--- a/tilt/sensors.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Copyright (C) 2015 Intel Corp
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <hardware/sensors.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <dirent.h>
-#include <math.h>
-#include <poll.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <string.h>
-#include <linux/input.h>
-#include <utils/Atomic.h>
-#include <utils/Log.h>
-#include "sensors.h"
-#include "TiltSensor.h"
-
-#define DELAY_OUT_TIME 0x7FFFFFFF
-#define LIGHT_SENSOR_POLLTIME 2000000000
-
-#define SENSORS_LIGHT_HANDLE (ID_L)
-#define SENSORS_TILT_HANDLE (ID_T)
-
-
-/* The SENSORS Module */
-static struct sensor_t sSensorList[] = {
- { "TILT sensor",
- "STMicroelectronics",
- 1, SENSORS_TILT_HANDLE,
- SENSOR_TYPE_WRIST_TILT_GESTURE, 1.0f, 1.0f, 1.0f, 0, 0, 0,
- #ifdef ANDROID_L
- SENSOR_STRING_TYPE_WRIST_TILT_GESTURE, NULL, 0, SENSOR_FLAG_SPECIAL_REPORTING_MODE | SENSOR_FLAG_WAKE_UP,
- #else
- NULL, NULL, 0, 0,
- #endif
- { } },
-};
-
-static int open_sensors(const struct hw_module_t* module, const char* id,
- struct hw_device_t** device);
-
-
-
-static int sensors__get_sensors_list(struct sensors_module_t* module,
- struct sensor_t const** list)
-{
- *list = sSensorList;
- return ARRAY_SIZE(sSensorList);
-}
-
-static struct hw_module_methods_t sensors_module_methods = {
- open: open_sensors
-};
-
-struct sensors_module_t HAL_MODULE_INFO_SYM = {
- common: {
- tag: HARDWARE_MODULE_TAG,
- version_major: 1,
- version_minor: 0,
- id: SENSORS_HARDWARE_MODULE_ID,
- name: "Intel MVN Sensor module",
- author: "Intel MVN Company",
- methods: &sensors_module_methods,
- dso: 0,
- reserved: {},
- },
- get_sensors_list: sensors__get_sensors_list,
-};
-
-struct sensors_poll_context_t {
-#ifdef HAL_VERSION_GE_1_0
- struct sensors_poll_device_1 device; /* must be first */
-#else
- struct sensors_poll_device_t device; /* must be first */
-#endif
- sensors_poll_context_t();
- ~sensors_poll_context_t();
- int activate(int handle, int enabled);
- int setDelay(int handle, int64_t ns);
-#ifdef HAL_VERSION_GT_1_0
- int batch(int handle, int flags, int64_t period_ns, int64_t timeout);
- int flush(int handle);
-#endif
- int pollEvents(sensors_event_t* data, int count);
- bool getInitialized() { return mInitialized; };
-
-private:
- bool mInitialized;
-
- enum {
- TILT = 0,
- numSensorDrivers, /* wake pipe goes here */
- flushPipe, /* flush pipe goes here */
- numFds,
- };
-
- static const size_t wake = numFds - 2;
- static const char WAKE_MESSAGE = 'W';
- struct pollfd mPollFds[numFds];
- int mWritePipeFd;
- int mFlushWritePipeFd;
- SensorBase* mSensors[numSensorDrivers];
-
- int handleToDriver(int handle) const {
- switch (handle) {
- case ID_T:
- return TILT;
- }
- return -EINVAL;
- }
-};
-
-
-
-sensors_poll_context_t::sensors_poll_context_t()
-{
- FUNC_LOG;
- mInitialized = false;
- /* Must clean this up early or else the destructor will make a mess */
- memset(mSensors, 0, sizeof(mSensors));
-
- mSensors[TILT] = new TiltSensor();
- mPollFds[TILT].fd = mSensors[TILT]->getFd();
- mPollFds[TILT].events = POLLIN;
- mPollFds[TILT].revents = 0;
-
- int wakeFds[2];
- int result = pipe(wakeFds);
- ALOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno));
- result = fcntl(wakeFds[0], F_SETFL, O_NONBLOCK);
- ALOGE_IF(result<0, "error setting wakeFds[0] access mode (%s)", strerror(errno));
- result = fcntl(wakeFds[1], F_SETFL, O_NONBLOCK);
- ALOGE_IF(result<0, "error setting wakeFds[1] access mode (%s)", strerror(errno));
- mWritePipeFd = wakeFds[1];
-
- mPollFds[wake].fd = wakeFds[0];
- mPollFds[wake].events = POLLIN;
- mPollFds[wake].revents = 0;
-
- int flushFds[2];
- result = pipe(flushFds);
- ALOGE_IF(result<0, "error creating flush pipe (%s)", strerror(errno));
- result = fcntl(flushFds[0], F_SETFL, O_NONBLOCK);
- ALOGE_IF(result<0, "error setting flushFds[0] access mode (%s)", strerror(errno));
- result = fcntl(flushFds[1], F_SETFL, O_NONBLOCK);
- ALOGE_IF(result<0, "error setting flushFds[1] access mode (%s)", strerror(errno));
- mFlushWritePipeFd = flushFds[1];
-
- mPollFds[flushPipe].fd = flushFds[0];
- mPollFds[flushPipe].events = POLLIN;
- mPollFds[flushPipe].revents = 0;
- mInitialized = true;
-}
-
-sensors_poll_context_t::~sensors_poll_context_t()
-{
- FUNC_LOG;
- for (int i=0 ; i<numSensorDrivers ; i++)
- delete mSensors[i];
-
- close(mPollFds[wake].fd);
- close(mWritePipeFd);
- close(mPollFds[flushPipe].fd);
- close(mFlushWritePipeFd);
- mInitialized = false;
-}
-
-int sensors_poll_context_t::activate(int handle, int enabled)
-{
- FUNC_LOG;
- if (!mInitialized)
- return -EINVAL;
-
- int index = handleToDriver(handle);
- if (index < 0)
- return index;
- int err = mSensors[index]->enable(handle, enabled);
- if (!err) {
- const char wakeMessage(WAKE_MESSAGE);
- int result = write(mWritePipeFd, &wakeMessage, 1);
- ALOGE_IF(result<0, "error sending wake message (%s)", strerror(errno));
- }
- return err;
-}
-
-int sensors_poll_context_t::setDelay(int handle, int64_t ns)
-{
- FUNC_LOG;
- int index = handleToDriver(handle);
- if (index < 0)
- return index;
-
- return mSensors[index]->setDelay(handle, ns);
-}
-
-#ifdef HAL_VERSION_GT_1_0
-int sensors_poll_context_t::batch(int handle, int flags, int64_t period_ns, int64_t timeout)
-{
- FUNC_LOG;
- int index = handleToDriver(handle);
- if (index < 0)
- return index;
-
- return mSensors[index]->batch(handle, flags, period_ns, timeout);
-}
-
-int sensors_poll_context_t::flush(int handle)
-{
- FUNC_LOG;
- int result;
- sensors_event_t flush_event_data;
-
- int index = handleToDriver(handle);
- if (index < 0) return index;
-
- result = mSensors[index]->isActivated(handle);
- if (!result)
- return -EINVAL;
-
- flush_event_data.sensor = 0;
- flush_event_data.timestamp = 0;
- flush_event_data.meta_data.sensor = handle;
- flush_event_data.meta_data.what = META_DATA_FLUSH_COMPLETE;
- flush_event_data.type = SENSOR_TYPE_META_DATA;
- flush_event_data.version = META_DATA_VERSION;
-
- result = write(mFlushWritePipeFd, &flush_event_data, sizeof(sensors_event_t));
- ALOGE_IF(result<0, "error sending flush event data (%s)", strerror(errno));
-
- return (result >= 0 ? 0 : result);
-}
-
-#endif
-
-int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
-{
- FUNC_LOG;
- int nbEvents = 0;
- int n = 0;
-
- do {
- for (int i=0 ; count && i<numSensorDrivers; i++) {
- SensorBase* const sensor(mSensors[i]);
- /* See if we have some pending events from the last poll() */
- if ((mPollFds[i].revents & POLLIN) || (sensor->hasPendingEvents())) {
- int nb = sensor->readEvents(data, count);
-
- /* no more data for this sensor */
- if (nb < count)
- mPollFds[i].revents = 0;
-
- count -= nb;
- nbEvents += nb;
- data += nb;
- }
- }
-
- /* flush event data */
- if (count) {
- if (mPollFds[flushPipe].revents & POLLIN) {
- int nb = read(mPollFds[flushPipe].fd, data, count * sizeof(sensors_event_t));
- if (nb < 0) {
- ALOGE("error reading from flush pipe (%s)", strerror(errno));
- return -errno;
- }
- nb = nb/sizeof(sensors_event_t);
- mPollFds[flushPipe].revents = 0;
- count -= nb;
- nbEvents += nb;
- data += nb;
- }
- }
-
-
- if (count) {
- ALOGV("%s: start poll syscall to kernel", __func__);
- n = poll(mPollFds, numFds, nbEvents ? 0 : -1);
- if (n < 0) {
- ALOGE("poll() failed (%s)", strerror(errno));
- return -errno;
- }
- if (mPollFds[wake].revents & POLLIN) {
- char msg;
- int result = read(mPollFds[wake].fd, &msg, 1);
- ALOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno));
- ALOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg));
- mPollFds[wake].revents = 0;
- }
- }
- /* if we have events and space, go read them */
- } while (n && count);
-
- return nbEvents;
-}
-
-static int poll__close(struct hw_device_t *dev)
-{
- FUNC_LOG;
- sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
- if (ctx)
- delete ctx;
-
- return 0;
-}
-
-static int poll__activate(struct sensors_poll_device_t *dev,
- int handle, int enabled)
-{
- FUNC_LOG;
- sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
- return ctx->activate(handle, enabled);
-}
-
-static int poll__setDelay(struct sensors_poll_device_t *dev,
- int handle, int64_t ns)
-{
- FUNC_LOG;
- sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
- return ctx->setDelay(handle, ns);
-}
-
-#ifdef HAL_VERSION_GT_1_0
-static int poll__batch(struct sensors_poll_device_1 *dev,
- int handle, int flags, int64_t period_ns, int64_t timeout)
-{
- FUNC_LOG;
- sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
- return ctx->batch(handle, flags, period_ns, timeout);
-}
-
-static int poll_flush(struct sensors_poll_device_1 *dev, int handle)
-{
- FUNC_LOG;
- sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
- return ctx->flush(handle);
-}
-#endif
-
-static int poll__poll(struct sensors_poll_device_t *dev,
- sensors_event_t* data, int count)
-{
- FUNC_LOG;
- sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
- return ctx->pollEvents(data, count);
-}
-
-/* Open a new instance of a sensor device using name */
-static int open_sensors(const struct hw_module_t* module, const char* id,
- struct hw_device_t** device)
-{
- FUNC_LOG;
- int status = -EINVAL;
- sensors_poll_context_t *dev = new sensors_poll_context_t();
-
- if (!dev->getInitialized()) {
- ALOGE("Failed to open the sensors (%s)", id);
- return status;
- }
-#ifdef HAL_VERSION_GE_1_0
- memset(&dev->device, 0, sizeof(sensors_poll_device_1));
-#else
- memset(&dev->device, 0, sizeof(sensors_poll_device_t));
-#endif
-
- dev->device.common.tag = HARDWARE_DEVICE_TAG;
-#ifdef ANDROID_L
- dev->device.common.version = SENSORS_DEVICE_API_VERSION_1_3;
-#endif
-#ifdef ANDROID_KK
- dev->device.common.version = SENSORS_DEVICE_API_VERSION_1_1;
-#endif
-#ifdef ANDROID_JBMR2
- dev->device.common.version = SENSORS_DEVICE_API_VERSION_1_0;
-#endif
-#ifdef ANDROID_JB
- dev->device.common.version = 0;
-#endif
- dev->device.common.module = const_cast<hw_module_t*>(module);
- dev->device.common.close = poll__close;
- dev->device.activate = poll__activate;
- dev->device.setDelay = poll__setDelay;
-#ifdef HAL_VERSION_GT_1_0
- dev->device.batch = poll__batch;
- dev->device.flush = poll_flush;
-#endif
- dev->device.poll = poll__poll;
-
- *device = &dev->device.common;
- status = 0;
-
- return status;
-}
diff --git a/tilt/sensors.h b/tilt/sensors.h
deleted file mode 100644
index 869c9a7..0000000
--- a/tilt/sensors.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2015 Intel Corp
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_INTELNDG_SENSORS_H
-#define ANDROID_INTELNDG_SENSORS_H
-
-#include <stdint.h>
-#include <errno.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <linux/input.h>
-
-#include <hardware/hardware.h>
-#include <hardware/sensors.h>
-
-__BEGIN_DECLS
-
-/*****************************************************************************/
-
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-
-#define ID_INTELNDG_BASE (0x1000)
-/* light sensor ID */
-#define ID_L (ID_INTELNDG_BASE)
-/* tilt sensor ID */
-#define ID_T (ID_L + 1)
-
-/*****************************************************************************/
-
-/*
- * The SENSORS Module
- */
-
-/*****************************************************************************/
-/* the GP2A is a binary proximity sensor that triggers around 5 cm on
- * this hardware */
-#define PROXIMITY_THRESHOLD_GP2A 5.0f
-
-/* input event code for light sensor */
-#define EVENT_TYPE_LIGHT MSC_RAW
-/*****************************************************************************/
-
-
-
-__END_DECLS
-
-#endif /* ANDROID_INTELNDG_SENSORS_H */