summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xBoardConfig.mk4
-rw-r--r--DeviceSettings/res/values-de/arrays.xml42
-rw-r--r--DeviceSettings/res/values-es/arrays.xml9
-rw-r--r--DeviceSettings/res/values-es/strings.xml7
-rw-r--r--DeviceSettings/res/values-fi/arrays.xml9
-rw-r--r--DeviceSettings/res/values-fi/strings.xml5
-rw-r--r--DeviceSettings/res/values-fr/arrays.xml50
-rw-r--r--DeviceSettings/res/values-fr/strings.xml2
-rw-r--r--DeviceSettings/res/values-hu/arrays.xml94
-rw-r--r--DeviceSettings/res/values-hu/strings.xml13
-rw-r--r--DeviceSettings/res/values-nl/arrays.xml50
-rw-r--r--DeviceSettings/res/values-nl/strings.xml40
-rwxr-xr-xDeviceSettings/res/values-pt-rBR/arrays.xml116
-rwxr-xr-xDeviceSettings/res/values-pt-rBR/strings.xml14
-rw-r--r--DeviceSettings/res/values/arrays.xml82
-rw-r--r--DeviceSettings/res/values/strings.xml2
-rw-r--r--DeviceSettings/res/xml/sensors_preferences.xml9
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java1
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java32
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java2
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java59
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java82
-rw-r--r--camera/CameraWrapper.cpp18
-rwxr-xr-xextract-files.sh4
-rw-r--r--init.smdk4210.rc3
-rw-r--r--libsensors/AkmSensor.cpp331
-rw-r--r--libsensors/AkmSensor.h64
-rw-r--r--libsensors/Android.mk45
-rw-r--r--libsensors/GyroSensor.cpp185
-rw-r--r--libsensors/GyroSensor.h55
-rw-r--r--libsensors/InputEventReader.cpp88
-rw-r--r--libsensors/InputEventReader.h47
-rw-r--r--libsensors/LightSensor.cpp161
-rw-r--r--libsensors/LightSensor.h55
-rw-r--r--libsensors/MODULE_LICENSE_APACHE20
-rw-r--r--libsensors/ProximitySensor.cpp146
-rw-r--r--libsensors/ProximitySensor.h54
-rw-r--r--libsensors/SensorBase.cpp128
-rw-r--r--libsensors/SensorBase.h65
-rw-r--r--libsensors/ak8973b.h51
-rw-r--r--libsensors/sensors.cpp326
-rw-r--r--libsensors/sensors.h117
-rwxr-xr-xoverlay/frameworks/base/core/res/res/values/config.xml78
-rw-r--r--overlay/packages/apps/Camera/res/values/config.xml2
-rwxr-xr-xoverlay/packages/apps/Phone/res/values/config.xml5
-rwxr-xr-xreleasetools/n7000_ota_from_target_files2
46 files changed, 2534 insertions, 220 deletions
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 0c5dbf6..047cd99 100755
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -87,6 +87,7 @@ BOARD_USES_MFC_FPS := true
# Audio
BOARD_USE_YAMAHAPLAYER := true
BOARD_USE_SAMSUNG_SEPARATEDSTREAM := true
+BOARD_HAS_SAMSUNG_VOLUME_BUG := true
# RIL
BOARD_MOBILEDATA_INTERFACE_NAME := "pdp0"
@@ -96,6 +97,9 @@ BOARD_MOBILEDATA_INTERFACE_NAME := "pdp0"
#BOARD_GLOBAL_CFLAGS += -DHAVE_FM_RADIO
#BOARD_FM_DEVICE := si4709
+# Camera
+COMMON_GLOBAL_CFLAGS += -DSAMSUNG_CAMERA_HARDWARE
+
# WiFi (BCM4330)
BOARD_WLAN_DEVICE := bcmdhd
BOARD_WLAN_DEVICE_REV := bcm4330_b1
diff --git a/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml
index 6f5dda7..04797c6 100644
--- a/DeviceSettings/res/values-de/arrays.xml
+++ b/DeviceSettings/res/values-de/arrays.xml
@@ -2,30 +2,30 @@
<string-array name="mdnie_scenario_entries">
<item>Kamera (Standard)</item>
- <item>Video</item>
- <item>Video warm</item>
- <item>Video kalt</item>
- <item>UI</item>
- <item>Navigation</item>
- <item>Gallerie</item>
+ <item>Video</item>
+ <item>Video warm</item>
+ <item>Video kalt</item>
+ <item>UI</item>
+ <item>Navigation</item>
+ <item>Gallerie</item>
<item>VT</item>
</string-array>
<string-array name="mdnie_mode_entries">
- <item>Standard</item>
- <item>Dynamisch</item>
+ <item>Standard</item>
+ <item>Dynamisch</item>
<item>Natürlich</item>
- <item>Film</item>
+ <item>Film</item>
</string-array>
<string-array name="mdnie_negative_entries">
- <item>Normal</item>
- <item>Invertiert</item>
+ <item>Normal</item>
+ <item>Invertiert</item>
</string-array>
<string-array name="mdnie_outdoor_entries">
- <item>Deaktiviert</item>
- <item>Aktiviert</item>
+ <item>Deaktiviert</item>
+ <item>Aktiviert</item>
</string-array>
<string-array name="panel_gamma_entries">
@@ -51,9 +51,19 @@
</string-array>
<string-array name="hspa_entries">
- <item>Nur UMTS</item>
- <item>Nur HSDPA</item>
- <item>HSDPA + HSUPA</item>
+ <item>Nur UMTS</item>
+ <item>Nur HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries">
+ <item>Niemals</item>
+ <item>1 Sekunde</item>
+ <item>2 Sekunden</item>
+ <item>3 Sekunden (Standard)</item>
+ <item>4 Sekunden</item>
+ <item>5 Sekunden</item>
+ <item>6 Sekunden</item>
</string-array>
</resources>
diff --git a/DeviceSettings/res/values-es/arrays.xml b/DeviceSettings/res/values-es/arrays.xml
index 3bc45b7..8cf4fd9 100644
--- a/DeviceSettings/res/values-es/arrays.xml
+++ b/DeviceSettings/res/values-es/arrays.xml
@@ -2,7 +2,7 @@
<string-array name="hspa_entries">
<item>Solo UMTS</item>
- <item>solo HSDPA</item>
+ <item>Solo HSDPA</item>
<item>HSDPA + HSUPA</item>
</string-array>
@@ -48,4 +48,11 @@
<item>100</item>
</string-array>
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Predeterminado)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
</resources>
diff --git a/DeviceSettings/res/values-es/strings.xml b/DeviceSettings/res/values-es/strings.xml
index 95d05ca..feb29e9 100644
--- a/DeviceSettings/res/values-es/strings.xml
+++ b/DeviceSettings/res/values-es/strings.xml
@@ -27,8 +27,13 @@
<string name="use_gyro_calibration_title_head">Usar datos de calibración</string>
<string name="use_gyro_calibration_summary_head">Usar los datos de calibración del giroscopio. ¡Calibrar despues de activar!</string>
<string name="calibrate_gyro_title_head">Calibrar</string>
- <string name="calibrate_gyro_summary_head">Poner el dispositivo de una superficie plana y pulsar para calibrar</string>
+ <string name="calibrate_gyro_summary_head">Colocar el dispositivo en una superficie plana y pulsar para calibrar</string>
<string name="touchkey_subcat_title">Botones Táctiles</string>
<string name="touchkey_light_title_head">Activar iluminación</string>
<string name="touchkey_light_summary_head">Iluminar los botones táctiles al encender la pantalla</string>
+
+ <string name="category_haptic_title">Háptica</string>
+ <string name="vibrator_subcat_title">Vibración</string>
+ <string name="vibrator_intensity_title_head">Intensidad de vibración</string>
+ <string name="vibrator_intensity_summary_head">Establecer la intensidad de la vibración</string>
</resources>
diff --git a/DeviceSettings/res/values-fi/arrays.xml b/DeviceSettings/res/values-fi/arrays.xml
index eeebd7a..aaa4d82 100644
--- a/DeviceSettings/res/values-fi/arrays.xml
+++ b/DeviceSettings/res/values-fi/arrays.xml
@@ -48,4 +48,13 @@
<item>HSDPA + HSUPA</item>
</string-array>
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Oletus)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+
</resources>
diff --git a/DeviceSettings/res/values-fi/strings.xml b/DeviceSettings/res/values-fi/strings.xml
index 188371d..081f0ef 100644
--- a/DeviceSettings/res/values-fi/strings.xml
+++ b/DeviceSettings/res/values-fi/strings.xml
@@ -29,6 +29,11 @@
<string name="touchkey_light_title_head">Ota näppäinvalot käyttöön</string>
<string name="touchkey_light_summary_head">Valot syttyvät kun näyttö on päällä</string>
+ <string name="category_haptic_title">Haptinen</string>
+ <string name="vibrator_subcat_title">Värinä</string>
+ <string name="vibrator_intensity_title_head">Värinän voimakkuus</string>
+ <string name="vibrator_intensity_summary_head">Säädä värinän voimakkuutta</string>
+
<string name="category_radio_title">Radio</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">Ota HSDPA/HSUPA käyttöön</string>
diff --git a/DeviceSettings/res/values-fr/arrays.xml b/DeviceSettings/res/values-fr/arrays.xml
index 124f531..d421873 100644
--- a/DeviceSettings/res/values-fr/arrays.xml
+++ b/DeviceSettings/res/values-fr/arrays.xml
@@ -1,36 +1,36 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="mdnie_scenario_entries">
- <item>Caméra (Par défaut)</item>
- <item>Vidéo</item>
- <item>Vidéo (chaud)</item>
- <item>Video (froid)</item>
- <item>UI</item>
- <item>Navigation</item>
- <item>Gallerie</item>
- <item>VT</item>
+ <string-array name="mdnie_scenario_entries">
+ <item>Caméra (Par défaut)</item>
+ <item>Vidéo</item>
+ <item>Vidéo (chaud)</item>
+ <item>Video (froid)</item>
+ <item>UI</item>
+ <item>Navigation</item>
+ <item>Gallerie</item>
+ <item>VT</item>
</string-array>
- <string-array name="mdnie_mode_entries">
- <item>Standard (Par défaut)</item>
- <item>Dynamique</item>
- <item>Naturel</item>
- <item>Vidéo</item>
+ <string-array name="mdnie_mode_entries">
+ <item>Standard (Par défaut)</item>
+ <item>Dynamique</item>
+ <item>Naturel</item>
+ <item>Vidéo</item>
</string-array>
- <string-array name="mdnie_negative_entries">
- <item>Normal</item>
- <item>Inversé</item>
+ <string-array name="mdnie_negative_entries">
+ <item>Normal</item>
+ <item>Inversé</item>
</string-array>
- <string-array name="mdnie_outdoor_entries">
- <item>Inactif (Par défaut)</item>
- <item>Actif</item>
+ <string-array name="mdnie_outdoor_entries">
+ <item>Inactif (Par défaut)</item>
+ <item>Actif</item>
</string-array>
<string-array name="panel_gamma_entries">
- <item>2.2 (Par défaut)</item>
- <item>1.9</item>
+ <item>2.2 (Par défaut)</item>
+ <item>1.9</item>
</string-array>
<string-array name="touchscreen_sensitivity_entries">
@@ -43,9 +43,9 @@
</string-array>
<string-array name="hspa_entries">
- <item>UMTS seulement</item>
- <item>HSDPA seulement</item>
- <item>HSDPA + HSUPA</item>
+ <item>UMTS seulement</item>
+ <item>HSDPA seulement</item>
+ <item>HSDPA + HSUPA</item>
</string-array>
</resources>
diff --git a/DeviceSettings/res/values-fr/strings.xml b/DeviceSettings/res/values-fr/strings.xml
index c11f8cf..ab81716 100644
--- a/DeviceSettings/res/values-fr/strings.xml
+++ b/DeviceSettings/res/values-fr/strings.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="app_name">Paramètres GalaxyNote</string>
+ <string name="app_name">Paramètres Galaxy Note</string>
<string name="category_mdnie_title">Ecran</string>
<string name="screen_colors_title">Couleurs</string>
diff --git a/DeviceSettings/res/values-hu/arrays.xml b/DeviceSettings/res/values-hu/arrays.xml
index ab52e04..ee1f831 100644
--- a/DeviceSettings/res/values-hu/arrays.xml
+++ b/DeviceSettings/res/values-hu/arrays.xml
@@ -1,51 +1,51 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="mdnie_scenario_entries">
- <item>Kamera (Alapbeállítás)</item>
- <item>Videó</item>
- <item>Videó (Meleg árnyalat)</item>
- <item>Videó (Hideg árnyalat)</item>
- <item>Felhasználói felület</item>
- <item>Navigáció</item>
- <item>Galéria</item>
- <item>VT</item>
- </string-array>
-
- <string-array name="mdnie_mode_entries">
- <item>Hagyományos (Alapbeállítás)</item>
- <item>Dinamikus</item>
- <item>Természetes</item>
- <item>Film</item>
- </string-array>
-
- <string-array name="mdnie_negative_entries">
- <item>Hagyományos</item>
- <item>Fordított</item>
- </string-array>
-
- <string-array name="mdnie_outdoor_entries">
- <item>Kikapcsolva (Alapbeállítás)</item>
- <item>Bekapcsolva</item>
- </string-array>
-
- <string-array name="panel_gamma_entries">
- <item>2.2 (Alapbeállítás)</item>
- <item>1.9</item>
- </string-array>
-
- <string-array name="touchscreen_sensitivity_entries">
- <item>10</item>
- <item>20</item>
- <item>30</item>
- <item>50 (Alapbeállítás)</item>
- <item>70</item>
- <item>100</item>
- </string-array>
-
- <string-array name="hspa_entries">
- <item>UMTS</item>
- <item>HSDPA</item>
- <item>HSDPA + HSUPA</item>
- </string-array>
+ <string-array name="mdnie_scenario_entries">
+ <item>Kamera (Alapbeállítás)</item>
+ <item>Videó</item>
+ <item>Videó (Meleg árnyalat)</item>
+ <item>Videó (Hideg árnyalat)</item>
+ <item>Felhasználói felület</item>
+ <item>Navigáció</item>
+ <item>Galéria</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>Hagyományos (Alapbeállítás)</item>
+ <item>Dinamikus</item>
+ <item>Természetes</item>
+ <item>Film</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>Hagyományos</item>
+ <item>Fordított</item>
+ </string-array>
+
+ <string-array name="mdnie_outdoor_entries">
+ <item>Kikapcsolva (Alapbeállítás)</item>
+ <item>Bekapcsolva</item>
+ </string-array>
+
+ <string-array name="panel_gamma_entries">
+ <item>2.2 (Alapbeállítás)</item>
+ <item>1.9</item>
+ </string-array>
+
+ <string-array name="touchscreen_sensitivity_entries">
+ <item>10</item>
+ <item>20</item>
+ <item>30</item>
+ <item>50 (Alapbeállítás)</item>
+ <item>70</item>
+ <item>100</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>UMTS</item>
+ <item>HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
</resources>
diff --git a/DeviceSettings/res/values-hu/strings.xml b/DeviceSettings/res/values-hu/strings.xml
index 54197e0..6a24926 100644
--- a/DeviceSettings/res/values-hu/strings.xml
+++ b/DeviceSettings/res/values-hu/strings.xml
@@ -17,18 +17,23 @@
<string name="touchscreen_subcat_title">Érintőképernyő</string>
<string name="touchscreen_sensitivity_title_head">Érzékenység</string>
- <string name="touchscreen_sensitivity_summary_head">Állítsd be az érintőképernyő érzékenységét</string>
+ <string name="touchscreen_sensitivity_summary_head">Érintőképernyő érzékenységének beállítása</string>
<string name="category_sensors_title">Szenzorok</string>
<string name="gyro_subcat_title">Giroszkóp</string>
- <string name="use_gyro_calibration_title_head">Használd a kalibrálási értékeket</string>
- <string name="use_gyro_calibration_summary_head">Használd a kalibrálási értékeket. Készíts kalibrációt ha ezt bepipálod!</string>
+ <string name="use_gyro_calibration_title_head">Kalibrálási érték használata</string>
+ <string name="use_gyro_calibration_summary_head">Kalibrálási érték használata. Érdemes újra kalibrálni, ha ez a funkció használatban van!</string>
<string name="calibrate_gyro_title_head">Kalibrálás</string>
- <string name="calibrate_gyro_summary_head">Tedd a telefont egy vízszintes felületre, és nyomd meg ezt a gombot a kalibráláshoz</string>
+ <string name="calibrate_gyro_summary_head">Kalibráláshoz a telefont vízszintes felületre kell helyezni, és megérinteni ezt a gombot</string>
<string name="touchkey_subcat_title">Érintőgombok</string>
<string name="touchkey_light_title_head">Érintőgombok háttérvilágítása</string>
<string name="touchkey_light_summary_head">Bekapcsolja az érintőgombok háttérvilágítását bekapcsolt képernyőnél</string>
+ <string name="category_haptic_title">Érintési visszajelzés</string>
+ <string name="vibrator_subcat_title">Rezgés</string>
+ <string name="vibrator_intensity_title_head">Rezgés erőssége</string>
+ <string name="vibrator_intensity_summary_head">Rezgés erősségének beállítása</string>
+
<string name="category_radio_title">GSM rádió</string>
<string name="hspa_title_head">HSPA</string>
<string name="hspa_summary_head">HSDPA/HSUPA engedélyezése</string>
diff --git a/DeviceSettings/res/values-nl/arrays.xml b/DeviceSettings/res/values-nl/arrays.xml
new file mode 100644
index 0000000..ab28dc7
--- /dev/null
+++ b/DeviceSettings/res/values-nl/arrays.xml
@@ -0,0 +1,50 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string-array name="mdnie_scenario_entries">
+ <item>Camera (standaard)</item>
+ <item>Video</item>
+ <item>Video (warm)</item>
+ <item>Video (koud)</item>
+ <item>Uiterlijk</item>
+ <item>Navigatie</item>
+ <item>Galerij</item>
+ <item>VT</item>
+ </string-array>
+ <string-array name="mdnie_mode_entries">
+ <item>Standaard</item>
+ <item>Dynamisch</item>
+ <item>Natuurlijk</item>
+ <item>Film</item>
+ </string-array>
+ <string-array name="mdnie_negative_entries">
+ <item>Normaal</item>
+ <item>Omgedraaid</item>
+ </string-array>
+ <string-array name="mdnie_outdoor_entries">
+ <item>Uit (standaard)</item>
+ <item>Aan</item>
+ </string-array>
+ <string-array name="panel_gamma_entries">
+ <item>2,2 (standaard)</item>
+ <item>1,9</item>
+ </string-array>
+ <string-array name="touchscreen_sensitivity_entries">
+ <item>10</item>
+ <item>20</item>
+ <item>30</item>
+ <item>50 (standaard)</item>
+ <item>70</item>
+ <item>100</item>
+ </string-array>
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (standaard)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+ <string-array name="hspa_entries">
+ <item>Alleen UMTS</item>
+ <item>Alleen HSDPA</item>
+ <item>HSDPA &amp; HSUPA</item>
+ </string-array>
+</resources>
diff --git a/DeviceSettings/res/values-nl/strings.xml b/DeviceSettings/res/values-nl/strings.xml
new file mode 100644
index 0000000..587b923
--- /dev/null
+++ b/DeviceSettings/res/values-nl/strings.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy Note-instellingen</string>
+
+ <string name="screen_colors_title">Kleuren</string>
+ <string name="category_mdnie_title">Scherm</string>
+ <string name="mdnie_scenario_title_head">Scenario</string>
+ <string name="mdnie_scenario_summary_head">mDNIe-scenario instellen</string>
+ <string name="mdnie_mode_title_head">Modus</string>
+ <string name="mdnie_mode_summary_head">mDNIe-modus instellen</string>
+ <string name="mdnie_negative_title_head">Negatieve modus</string>
+ <string name="mdnie_negative_summary_head">Negatieve kleuren in-/uitschakelen</string>
+ <string name="mdnie_outdoor_title_head">Buitenmodus</string>
+ <string name="mdnie_outdoor_summary_head">Buitenmodus in-/uitschakelen</string>
+ <string name="panel_gamma_title_head">Schermgamma</string>
+ <string name="panel_gamma_summary_head">Schermgammawaarden instellen</string>
+
+ <string name="touchscreen_subcat_title">Aanraakscherm</string>
+ <string name="touchscreen_sensitivity_title_head">Aanraakgevoeligheid</string>
+ <string name="touchscreen_sensitivity_summary_head">Gevoeligheid aanraakscherm instellen</string>
+
+ <string name="category_sensors_title">Sensoren</string>
+ <string name="gyro_subcat_title">Gyroscoop</string>
+ <string name="use_gyro_calibration_title_head">Kalibratiegegevens gebruiken</string>
+ <string name="use_gyro_calibration_summary_head">Gebruik de kalibratiewaarden van de gyroscoop. Gelieve hierna een kalibratie te doen.</string>
+ <string name="calibrate_gyro_title_head">Kalibreren</string>
+ <string name="calibrate_gyro_summary_head">Plaats de telefoon op een vlakke ondergrond en tik hier om te kalibreren</string>
+ <string name="touchkey_subcat_title">Aanraakknop</string>
+ <string name="touchkey_light_title_head">Achtergrondlicht bij knoppen inschakelen</string>
+ <string name="touchkey_light_summary_head">Aanraakknoppen oplichten indien scherm aan is</string>
+
+ <string name="category_haptic_title">Haptisch</string>
+ <string name="vibrator_subcat_title">Trillen</string>
+ <string name="vibrator_intensity_title_head">Trilintensiteit</string>
+ <string name="vibrator_intensity_summary_head">Trilintensiteit instellen</string>
+
+ <string name="category_radio_title">Radio</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">HSDPA/HSUPA inschakelen</string>
+</resources>
diff --git a/DeviceSettings/res/values-pt-rBR/arrays.xml b/DeviceSettings/res/values-pt-rBR/arrays.xml
index 75c3ac5..f51ffde 100755
--- a/DeviceSettings/res/values-pt-rBR/arrays.xml
+++ b/DeviceSettings/res/values-pt-rBR/arrays.xml
@@ -1,51 +1,67 @@
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-
- <string-array name="mdnie_scenario_entries">
- <item>Câmera (Padrão)</item>
- <item>Vídeo</item>
- <item>Vídeo Quente</item>
- <item>Vídeo Frio</item>
- <item>IU</item>
- <item>Navegação</item>
- <item>Galeria</item>
- <item>VT</item>
- </string-array>
-
- <string-array name="mdnie_mode_entries">
- <item>Padrão</item>
- <item>Dinâmico</item>
- <item>Natural</item>
- <item>Filme</item>
- </string-array>
-
- <string-array name="mdnie_negative_entries">
- <item>Normal</item>
- <item>Invertido</item>
- </string-array>
-
- <string-array name="mdnie_outdoor_entries">
- <item>Desligado (Padrão)</item>
- <item>Ligado</item>
- </string-array>
-
- <string-array name="panel_gamma_entries">
- <item>2.2 (Padrão)</item>
- <item>1.9</item>
- </string-array>
-
- <string-array name="touchscreen_sensitivity_entries">
- <item>10</item>
- <item>20</item>
- <item>30</item>
- <item>50 (Padrão)</item>
- <item>70</item>
- <item>100</item>
- </string-array>
-
- <string-array name="hspa_entries">
- <item>Somente UMTS</item>
- <item>Somente HSDPA</item>
- <item>HSDPA + HSUPA</item>
- </string-array>
-
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="mdnie_scenario_entries">
+ <item>Câmera (Padrão)</item>
+ <item>Vídeo</item>
+ <item>Vídeo Quente</item>
+ <item>Vídeo Frio</item>
+ <item>IU</item>
+ <item>Navegação</item>
+ <item>Galeria</item>
+ <item>VT</item>
+ </string-array>
+
+ <string-array name="mdnie_mode_entries">
+ <item>Padrão</item>
+ <item>Dinâmico</item>
+ <item>Natural</item>
+ <item>Filme</item>
+ </string-array>
+
+ <string-array name="mdnie_negative_entries">
+ <item>Normal</item>
+ <item>Invertido</item>
+ </string-array>
+
+ <string-array name="mdnie_outdoor_entries">
+ <item>Desligado (Padrão)</item>
+ <item>Ligado</item>
+ </string-array>
+
+ <string-array name="panel_gamma_entries">
+ <item>2.2 (Padrão)</item>
+ <item>1.9</item>
+ </string-array>
+
+ <string-array name="touchscreen_sensitivity_entries">
+ <item>10</item>
+ <item>20</item>
+ <item>30</item>
+ <item>50 (Padrão)</item>
+ <item>70</item>
+ <item>100</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>Somente UMTS</item>
+ <item>Somente HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Padrão)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+ <string-array name="touchkey_timeout_entries">
+ <item>Nunca</item>
+ <item>1 segundo</item>
+ <item>2 segundos</item>
+ <item>3 segundos (padrão)</item>
+ <item>4 segundos</item>
+ <item>5 segundos</item>
+ <item>6 segundos</item>
+ </string-array>
</resources> \ No newline at end of file
diff --git a/DeviceSettings/res/values-pt-rBR/strings.xml b/DeviceSettings/res/values-pt-rBR/strings.xml
index 5208649..ba94306 100755
--- a/DeviceSettings/res/values-pt-rBR/strings.xml
+++ b/DeviceSettings/res/values-pt-rBR/strings.xml
@@ -8,18 +8,18 @@
<string name="mdnie_mode_title_head">Modo</string>
<string name="mdnie_mode_summary_head">Define o Modo mDNIe</string>
<string name="mdnie_negative_title_head">Modo Negativo</string>
- <string name="mdnie_negative_summary_head">Ativar/Desativar cores invertidas</string>
+ <string name="mdnie_negative_summary_head">Ativa/Desativa cores invertidas</string>
<string name="mdnie_outdoor_title_head">Modo Ao Ar Livre</string>
- <string name="mdnie_outdoor_summary_head">Ativar/Desativar modo ao ar livre</string>
+ <string name="mdnie_outdoor_summary_head">Ativa/Desativa modo ao ar livre</string>
<string name="panel_gamma_title_head">Gama da Tela</string>
<string name="panel_gamma_summary_head">Define valor da gama da tela</string>
<string name="touchscreen_subcat_title">Tela sensível ao toque</string>
<string name="touchscreen_sensitivity_title_head">Sensitividade do toque</string>
- <string name="touchscreen_sensitivity_summary_head">Definir a sensitividade do toque na tela</string>
+ <string name="touchscreen_sensitivity_summary_head">Define a sensitividade do toque na tela</string>
<string name="category_sensors_title">Sensores</string>
<string name="gyro_subcat_title">Giroscópio</string>
<string name="use_gyro_calibration_title_head">Usar dados de calibração</string>
- <string name="use_gyro_calibration_summary_head">Usar os valores de calibração do giroscópio. Fazer uma calibragem depois de selecionar isto!</string>
+ <string name="use_gyro_calibration_summary_head">Usa os valores de calibração do giroscópio. Calibre depois de selecionar isto!</string>
<string name="calibrate_gyro_title_head">Calibrar</string>
<string name="calibrate_gyro_summary_head">Coloque seu telefone em uma superfície plana, e pressione isto para calibrar</string>
<string name="touchkey_subcat_title">Tecla sensível ao toque</string>
@@ -27,9 +27,11 @@
<string name="touchkey_light_summary_head">Acende as teclas sensíveis ao toque quando a tela estiver ligada</string>
<string name="category_radio_title">Rádio</string>
<string name="hspa_title_head">HSPA</string>
- <string name="hspa_summary_head">Ativar HSDPA/HSUPA</string>
+ <string name="hspa_summary_head">Ativa HSDPA/HSUPA</string>
<string name="category_haptic_title">Resposta Tátil</string>
<string name="vibrator_subcat_title">Vibração</string>
- <string name="vibrator_intensity_title_head">Intesidade da Vibração</string>
+ <string name="vibrator_intensity_title_head">Intensidade da Vibração</string>
<string name="vibrator_intensity_summary_head">Define a intensidade da vibração</string>
+ <string name="touchkey_timeout_title_head">Tempo limite da luz de fundo</string>
+ <string name="touchkey_timeout_summary_head">Quanto tempo a luz de fundo irá ficar acesa depois do botão ser pressionado</string>
</resources> \ No newline at end of file
diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml
index e75ee6e..4ee28de 100644
--- a/DeviceSettings/res/values/arrays.xml
+++ b/DeviceSettings/res/values/arrays.xml
@@ -1,59 +1,59 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="mdnie_scenario_entries">
- <item>Camera (Default)</item>
- <item>Video</item>
- <item>Video Warm</item>
- <item>Video Cold</item>
- <item>UI</item>
- <item>Navigation</item>
- <item>Gallery</item>
+ <item>Camera (Default)</item>
+ <item>Video</item>
+ <item>Video Warm</item>
+ <item>Video Cold</item>
+ <item>UI</item>
+ <item>Navigation</item>
+ <item>Gallery</item>
<item>VT</item>
</string-array>
<string-array name="mdnie_scenario_entries_values" translatable="false">
- <item>4</item>
- <item>1</item>
- <item>2</item>
- <item>3</item>
- <item>0</item>
- <item>5</item>
- <item>6</item>
+ <item>4</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>0</item>
+ <item>5</item>
+ <item>6</item>
<item>7</item>
</string-array>
<string-array name="mdnie_mode_entries">
- <item>Standard (Default)</item>
- <item>Dynamic</item>
+ <item>Standard (Default)</item>
+ <item>Dynamic</item>
<item>Natural</item>
- <item>Movie</item>
+ <item>Movie</item>
</string-array>
<string-array name="mdnie_mode_entries_values" translatable="false">
- <item>1</item>
- <item>0</item>
+ <item>1</item>
+ <item>0</item>
<item>2</item>
- <item>3</item>
+ <item>3</item>
</string-array>
<string-array name="mdnie_negative_entries">
- <item>Normal</item>
- <item>Inverted</item>
+ <item>Normal</item>
+ <item>Inverted</item>
</string-array>
<string-array name="mdnie_negative_entries_values" translatable="false">
<item>0</item>
- <item>1</item>
+ <item>1</item>
</string-array>
<string-array name="mdnie_outdoor_entries">
- <item>Off (Default)</item>
- <item>On</item>
+ <item>Off (Default)</item>
+ <item>On</item>
</string-array>
<string-array name="mdnie_outdoor_entries_values" translatable="false">
- <item>0</item>
- <item>1</item>
+ <item>0</item>
+ <item>1</item>
</string-array>
<string-array name="panel_gamma_entries">
@@ -101,15 +101,35 @@
</string-array>
<string-array name="hspa_entries">
- <item>UMTS Only</item>
- <item>HSDPA Only</item>
- <item>HSDPA + HSUPA</item>
+ <item>UMTS Only</item>
+ <item>HSDPA Only</item>
+ <item>HSDPA + HSUPA</item>
</string-array>
<string-array name="hspa_entries_values" translatable="false">
- <item>21</item>
+ <item>21</item>
<item>22</item>
<item>23</item>
</string-array>
+ <string-array name="touchkey_timeout_entries">
+ <item>Never</item>
+ <item>1 second</item>
+ <item>2 seconds</item>
+ <item>3 seconds (default)</item>
+ <item>4 seconds</item>
+ <item>5 seconds</item>
+ <item>6 seconds</item>
+ </string-array>
+
+ <string-array name="touchkey_timeout_entries_values" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ <item>4</item>
+ <item>5</item>
+ <item>6</item>
+ </string-array>
+
</resources>
diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml
index 5c38440..be525f1 100644
--- a/DeviceSettings/res/values/strings.xml
+++ b/DeviceSettings/res/values/strings.xml
@@ -28,6 +28,8 @@
<string name="touchkey_subcat_title">Touch key</string>
<string name="touchkey_light_title_head">Enable keys backlight</string>
<string name="touchkey_light_summary_head">Light up touch keys when screen is on</string>
+ <string name="touchkey_timeout_title_head">Backlight timeout</string>
+ <string name="touchkey_timeout_summary_head">Delay after a keypress before backlight turns off</string>
<string name="category_haptic_title">Haptic</string>
<string name="vibrator_subcat_title">Vibrator</string>
diff --git a/DeviceSettings/res/xml/sensors_preferences.xml b/DeviceSettings/res/xml/sensors_preferences.xml
index 9029a62..497587d 100644
--- a/DeviceSettings/res/xml/sensors_preferences.xml
+++ b/DeviceSettings/res/xml/sensors_preferences.xml
@@ -24,6 +24,15 @@
android:key="touchkey_light"
android:title="@string/touchkey_light_title_head"
android:summary="@string/touchkey_light_summary_head"
+ android:defaultValue="true"
+ />
+ <com.cyanogenmod.settings.device.TouchkeyTimeout
+ android:key="touchkey_timeout"
+ android:title="@string/touchkey_timeout_title_head"
+ android:summary="@string/touchkey_timeout_summary_head"
+ android:entries="@array/touchkey_timeout_entries"
+ android:entryValues="@array/touchkey_timeout_entries_values"
+ android:defaultValue="3"
/>
</PreferenceCategory>
</PreferenceScreen>
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
index 58003a2..a60d9e8 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -45,6 +45,7 @@ public class DeviceSettings extends FragmentActivity {
public static final String KEY_CALIBRATE_GYRO = "calibrate_gyro";
public static final String KEY_TOUCHSCREEN_SENSITIVITY = "touchscreen_sensitivity";
public static final String KEY_TOUCHKEY_LIGHT = "touchkey_light";
+ public static final String KEY_TOUCHKEY_TIMEOUT = "touchkey_timeout";
public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity";
ViewPager mViewPager;
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java
index 015dd7b..bbe5f08 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/SensorsFragmentActivity.java
@@ -36,8 +36,8 @@ public class SensorsFragmentActivity extends PreferenceFragment {
private static final String TAG = "GalaxyNoteParts_General";
private static final String FILE_USE_GYRO_CALIB = "/sys/class/sec/gsensorcal/calibration";
- private static final String FILE_TOUCHKEY_LIGHT = "/data/.disable_touchlight";
- private static final String FILE_TOUCHKEY_TOGGLE = "/sys/class/sec/sec_touchkey/brightness";
+ private static final String FILE_TOUCHKEY_DISABLE = "/sys/class/sec/sec_touchkey/force_disable";
+ private static final String FILE_TOUCHKEY_BRIGHTNESS = "/sys/class/sec/sec_touchkey/brightness";
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -47,6 +47,12 @@ public class SensorsFragmentActivity extends PreferenceFragment {
PreferenceScreen prefSet = getPreferenceScreen();
+ if (((CheckBoxPreference)prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_LIGHT)).isChecked()) {
+ prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true);
+ } else {
+ prefSet.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false);
+ }
+
}
@Override
@@ -67,8 +73,15 @@ public class SensorsFragmentActivity extends PreferenceFragment {
Utils.writeValue(FILE_USE_GYRO_CALIB, "1");
Utils.showDialog((Context)getActivity(), "Calibration done", "The gyroscope has been successfully calibrated!");
} else if (key.compareTo(DeviceSettings.KEY_TOUCHKEY_LIGHT) == 0) {
- Utils.writeValue(FILE_TOUCHKEY_LIGHT, ((CheckBoxPreference)preference).isChecked() ? "1" : "0");
- Utils.writeValue(FILE_TOUCHKEY_TOGGLE, ((CheckBoxPreference)preference).isChecked() ? "1" : "2");
+ if (((CheckBoxPreference)preference).isChecked()) {
+ Utils.writeValue(FILE_TOUCHKEY_DISABLE, "0");
+ Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "1");
+ preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true);
+ } else {
+ Utils.writeValue(FILE_TOUCHKEY_DISABLE, "1");
+ Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "2");
+ preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false);
+ }
}
return true;
@@ -80,14 +93,17 @@ public class SensorsFragmentActivity extends PreferenceFragment {
public static void restore(Context context) {
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- String gyroCalib = sharedPrefs.getString(DeviceSettings.KEY_USE_GYRO_CALIBRATION, "1");
+ boolean gyroCalib = sharedPrefs.getBoolean(DeviceSettings.KEY_USE_GYRO_CALIBRATION, true);
// When use gyro calibration value is set to 1, calibration is done at the same time, which
// means it is reset at each boot, providing wrong calibration most of the time at each reboot.
// So we only set it to "0" if user wants it, as it defaults to 1 at boot
- if (gyroCalib.compareTo("1") != 0)
- Utils.writeValue(FILE_USE_GYRO_CALIB, gyroCalib);
+ if (!gyroCalib)
+ Utils.writeValue(FILE_USE_GYRO_CALIB, "0");
+
+ boolean light = sharedPrefs.getBoolean(DeviceSettings.KEY_TOUCHKEY_LIGHT, true);
- Utils.writeValue(FILE_TOUCHKEY_LIGHT, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_LIGHT, "1"));
+ Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, light ? "1" : "0");
+ Utils.writeValue(FILE_TOUCHKEY_DISABLE, light ? "0" : "1");
}
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
index 7566273..cb3624a 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
@@ -31,6 +31,8 @@ public class Startup extends BroadcastReceiver {
RadioFragmentActivity.restore(context);
HapticFragmentActivity.restore(context);
VibratorIntensity.restore(context);
+ SensorsFragmentActivity.restore(context);
+ TouchkeyTimeout.restore(context);
}
}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java
new file mode 100644
index 0000000..ce741f8
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/TouchkeyTimeout.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 The CyanogenMod Project
+ *
+ * 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.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import java.io.IOException;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class TouchkeyTimeout extends ListPreference implements OnPreferenceChangeListener {
+
+ public TouchkeyTimeout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE_TOUCHKEY_TIMEOUT = "/sys/class/sec/sec_touchkey/led_timeout";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE_TOUCHKEY_TIMEOUT);
+ }
+
+ /**
+ * Restore touchscreen sensitivity setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ Utils.writeValue(FILE_TOUCHKEY_TIMEOUT, sharedPrefs.getString(DeviceSettings.KEY_TOUCHKEY_TIMEOUT, "3"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE_TOUCHKEY_TIMEOUT, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
index 9d4176c..237ea0f 100644
--- a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
@@ -16,32 +16,96 @@
package com.cyanogenmod.settings.device;
+import android.util.Log;
+
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.SyncFailedException;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Context;
public class Utils {
+ private static final String TAG = "GalaxyNoteSettings_Utils";
+ private static final String TAG_READ = "GalaxyNoteSettings_Utils_Read";
+ private static final String TAG_WRITE = "GalaxyNoteSettings_Utils_Write";
+
/**
* Write a string value to the specified file.
- * @param filename The filename
- * @param value The value
+ *
+ * @param filename The filename
+ * @param value The value
*/
public static void writeValue(String filename, String value) {
+ FileOutputStream fos = null;
try {
- FileOutputStream fos = new FileOutputStream(new File(filename));
+ fos = new FileOutputStream(new File(filename), false);
fos.write(value.getBytes());
fos.flush();
- fos.getFD().sync();
- fos.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ // fos.getFD().sync();
+ } catch (FileNotFoundException ex) {
+ Log.w(TAG, "file " + filename + " not found: " + ex);
+ } catch (SyncFailedException ex) {
+ Log.w(TAG, "file " + filename + " sync failed: " + ex);
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException trying to sync " + filename + ": " + ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while syncing file: ", ex);
+ } finally {
+ if (fos != null) {
+ try {
+ Log.w(TAG_WRITE, "file " + filename + ": " + value);
+ fos.close();
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException while closing synced file: ", ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while closing file: ", ex);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Write a string value to the specified file.
+ *
+ * @param filename The filename
+ * @param value The value
+ */
+ public static void writeValue(String filename, Boolean value) {
+ FileOutputStream fos = null;
+ String sEnvia;
+ try {
+ fos = new FileOutputStream(new File(filename), false);
+ if (value)
+ sEnvia = "1";
+ else
+ sEnvia = "0";
+ fos.write(sEnvia.getBytes());
+ fos.flush();
+ // fos.getFD().sync();
+ } catch (FileNotFoundException ex) {
+ Log.w(TAG, "file " + filename + " not found: " + ex);
+ } catch (SyncFailedException ex) {
+ Log.w(TAG, "file " + filename + " sync failed: " + ex);
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException trying to sync " + filename + ": " + ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while syncing file: ", ex);
+ } finally {
+ if (fos != null) {
+ try {
+ Log.w(TAG_WRITE, "file " + filename + ": " + value);
+ fos.close();
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException while closing synced file: ", ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while closing file: ", ex);
+ }
+ }
}
}
diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp
index a605b08..9154216 100644
--- a/camera/CameraWrapper.cpp
+++ b/camera/CameraWrapper.cpp
@@ -96,6 +96,8 @@ const static char * video_preview_sizes[] = {
"640x480,352x288,320x240,176x144"
};
+const static char * iso_values[] = {"auto,ISO50,ISO100,ISO200,ISO400,ISO800","auto"};
+
static char * camera_fixup_getparams(int id, const char * settings)
{
android::CameraParameters params;
@@ -110,6 +112,8 @@ static char * camera_fixup_getparams(int id, const char * settings)
params.set(android::CameraParameters::KEY_PREVIEW_SIZE, videoSize);
}
+ params.set(android::CameraParameters::KEY_SUPPORTED_ISO_MODES, iso_values[id]);
+
android::String8 strParams = params.flatten();
char *ret = strdup(strParams.string());
@@ -129,6 +133,20 @@ char * camera_fixup_setparams(int id, const char * settings)
params.set(android::CameraParameters::KEY_SUPPORTED_VIDEO_SIZES, video_preview_sizes[id]);
}
+ if(params.get("iso")) {
+ const char* isoMode = params.get(android::CameraParameters::KEY_ISO_MODE);
+ if(strcmp(isoMode, "ISO50") == 0)
+ params.set(android::CameraParameters::KEY_ISO_MODE, "50");
+ else if(strcmp(isoMode, "ISO100") == 0)
+ params.set(android::CameraParameters::KEY_ISO_MODE, "100");
+ else if(strcmp(isoMode, "ISO200") == 0)
+ params.set(android::CameraParameters::KEY_ISO_MODE, "200");
+ else if(strcmp(isoMode, "ISO400") == 0)
+ params.set(android::CameraParameters::KEY_ISO_MODE, "400");
+ else if(strcmp(isoMode, "ISO800") == 0)
+ params.set(android::CameraParameters::KEY_ISO_MODE, "800");
+ }
+
android::String8 strParams = params.flatten();
char *ret = strdup(strParams.string());
diff --git a/extract-files.sh b/extract-files.sh
index 1ce1fdd..f93aac0 100755
--- a/extract-files.sh
+++ b/extract-files.sh
@@ -111,7 +111,6 @@ adb pull /system/cameradata/datapattern_front_420sp.yuv ../../../vendor/$MANUFAC
# SENSORS
adb pull /system/lib/libakm.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/libakm.so
-adb pull /system/lib/hw/sensors.exynos4.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/sensors.exynos4.so
# GPS
adb pull /system/lib/hw/gps.exynos4.so ../../../vendor/$MANUFACTURER/$DEVICE/proprietary/gps.exynos4.so
@@ -255,8 +254,7 @@ PRODUCT_COPY_FILES += \\
# SENSORS
PRODUCT_COPY_FILES += \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/libakm.so:system/lib/libakm.so \\
- vendor/__MANUFACTURER__/__DEVICE__/proprietary/sensors.exynos4.so:system/lib/hw/sensors.exynos4.so
+ vendor/__MANUFACTURER__/__DEVICE__/proprietary/libakm.so:system/lib/libakm.so
# GPS
PRODUCT_COPY_FILES += \\
diff --git a/init.smdk4210.rc b/init.smdk4210.rc
index 0acd613..dc48af8 100644
--- a/init.smdk4210.rc
+++ b/init.smdk4210.rc
@@ -176,7 +176,7 @@ on post-fs-data
# Permissions for input devices
chown system radio /sys/devices/virtual/sec/sec_key/sec_key_pressed
- chown system radio /sys/devices/virtual/sec/sec_touchkey/enable_disable
+ chown system radio /sys/devices/virtual/sec/sec_touchkey/force_disable
chown system radio /sys/devices/virtual/sec/sec_touchkey/recommended_version
chown system radio /sys/devices/virtual/sec/sec_touchkey/touch_sensitivity
chown system radio /sys/devices/virtual/sec/sec_touchkey/brightness
@@ -188,6 +188,7 @@ on post-fs-data
chown system radio /sys/devices/virtual/sec/sec_touchkey/touchkey_firm_update_status
chown system radio /sys/devices/virtual/sec/sec_touchkey/touchkey_firm_update
chown system radio /sys/devices/virtual/sec/sec_touchkey/updated_version
+ chown system radio /sys/devices/virtual/sec/sec_touchkey/led_timeout
chown system radio /sys/devices/virtual/sec/tsp_noise_test/set_firm_version
chown system radio /sys/devices/virtual/sec/tsp_noise_test/set_threshould
diff --git a/libsensors/AkmSensor.cpp b/libsensors/AkmSensor.cpp
new file mode 100644
index 0000000..98a17cb
--- /dev/null
+++ b/libsensors/AkmSensor.cpp
@@ -0,0 +1,331 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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 <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+#include <dlfcn.h>
+
+#include "ak8973b.h"
+
+#include <cutils/log.h>
+#include "AkmSensor.h"
+
+//#define LOG_NDEBUG 0
+
+/*****************************************************************************/
+
+int (*akm_is_sensor_enabled)(uint32_t sensor_type);
+int (*akm_enable_sensor)(uint32_t sensor_type);
+int (*akm_disable_sensor)(uint32_t sensor_type);
+int (*akm_set_delay)(uint32_t sensor_type, uint64_t delay);
+
+int stub_is_sensor_enabled(uint32_t sensor_type) {
+ return 0;
+}
+
+int stub_enable_disable_sensor(uint32_t sensor_type) {
+ return -ENODEV;
+}
+
+int stub_set_delay(uint32_t sensor_type, uint64_t delay) {
+ return -ENODEV;
+}
+
+AkmSensor::AkmSensor()
+: SensorBase(NULL, NULL),
+ mEnabled(0),
+ mPendingMask(0),
+ mInputReader(32)
+{
+ /* Open the library before opening the input device. The library
+ * creates a uinput device.
+ */
+ if (loadAKMLibrary() == 0) {
+ data_name = "compass_sensor";
+ data_fd = openInput("compass_sensor");
+ }
+
+ memset(mPendingEvents, 0, sizeof(mPendingEvents));
+
+ mPendingEvents[Accelerometer].version = sizeof(sensors_event_t);
+ mPendingEvents[Accelerometer].sensor = ID_A;
+ mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER;
+ mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH;
+
+ mPendingEvents[MagneticField].version = sizeof(sensors_event_t);
+ mPendingEvents[MagneticField].sensor = ID_M;
+ mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD;
+ mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH;
+
+ mPendingEvents[Orientation ].version = sizeof(sensors_event_t);
+ mPendingEvents[Orientation ].sensor = ID_O;
+ mPendingEvents[Orientation ].type = SENSOR_TYPE_ORIENTATION;
+ mPendingEvents[Orientation ].orientation.status = SENSOR_STATUS_ACCURACY_HIGH;
+
+ // read the actual value of all sensors if they're enabled already
+ struct input_absinfo absinfo;
+ short flags = 0;
+
+ if (akm_is_sensor_enabled(SENSOR_TYPE_ACCELEROMETER)) {
+ mEnabled |= 1<<Accelerometer;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) {
+ mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Y), &absinfo)) {
+ mPendingEvents[Accelerometer].acceleration.y = absinfo.value * CONVERT_A_Y;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Z), &absinfo)) {
+ mPendingEvents[Accelerometer].acceleration.z = absinfo.value * CONVERT_A_Z;
+ }
+ }
+ if (akm_is_sensor_enabled(SENSOR_TYPE_MAGNETIC_FIELD)) {
+ mEnabled |= 1<<MagneticField;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_X), &absinfo)) {
+ mPendingEvents[MagneticField].magnetic.x = absinfo.value * CONVERT_M_X;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Y), &absinfo)) {
+ mPendingEvents[MagneticField].magnetic.y = absinfo.value * CONVERT_M_Y;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Z), &absinfo)) {
+ mPendingEvents[MagneticField].magnetic.z = absinfo.value * CONVERT_M_Z;
+ }
+ }
+ if (akm_is_sensor_enabled(SENSOR_TYPE_ORIENTATION)) {
+ mEnabled |= 1<<Orientation;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_YAW), &absinfo)) {
+ mPendingEvents[Orientation].orientation.azimuth = absinfo.value;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PITCH), &absinfo)) {
+ mPendingEvents[Orientation].orientation.pitch = absinfo.value;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ROLL), &absinfo)) {
+ mPendingEvents[Orientation].orientation.roll = -absinfo.value;
+ }
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ORIENT_STATUS), &absinfo)) {
+ mPendingEvents[Orientation].orientation.status = uint8_t(absinfo.value & SENSOR_STATE_MASK);
+ }
+ }
+
+ // disable temperature sensor, since it is not supported
+ akm_disable_sensor(SENSOR_TYPE_TEMPERATURE);
+}
+
+AkmSensor::~AkmSensor()
+{
+ if (mLibAKM) {
+ unsigned ref = ::dlclose(mLibAKM);
+ }
+}
+
+int AkmSensor::enable(int32_t handle, int en)
+{
+ int what = -1;
+
+ switch (handle) {
+ case ID_A: what = Accelerometer; break;
+ case ID_M: what = MagneticField; break;
+ case ID_O: what = Orientation; break;
+ }
+
+ if (uint32_t(what) >= numSensors)
+ return -EINVAL;
+
+ int newState = en ? 1 : 0;
+ int err = 0;
+
+ if ((uint32_t(newState)<<what) != (mEnabled & (1<<what))) {
+ uint32_t sensor_type;
+ switch (what) {
+ case Accelerometer: sensor_type = SENSOR_TYPE_ACCELEROMETER; break;
+ case MagneticField: sensor_type = SENSOR_TYPE_MAGNETIC_FIELD; break;
+ case Orientation: sensor_type = SENSOR_TYPE_ORIENTATION; break;
+ }
+ short flags = newState;
+ if (en)
+ err = akm_enable_sensor(sensor_type);
+ else
+ err = akm_disable_sensor(sensor_type);
+
+ LOGE_IF(err, "Could not change sensor state (%s)", strerror(-err));
+ if (!err) {
+ mEnabled &= ~(1<<what);
+ mEnabled |= (uint32_t(flags)<<what);
+ }
+ }
+ return err;
+}
+
+int AkmSensor::setDelay(int32_t handle, int64_t ns)
+{
+ int what = -1;
+ uint32_t sensor_type = 0;
+
+ if (ns < 0)
+ return -EINVAL;
+
+ switch (handle) {
+ case ID_A: sensor_type = SENSOR_TYPE_ACCELEROMETER; break;
+ case ID_M: sensor_type = SENSOR_TYPE_MAGNETIC_FIELD; break;
+ case ID_O: sensor_type = SENSOR_TYPE_ORIENTATION; break;
+ }
+
+ if (sensor_type == 0)
+ return -EINVAL;
+
+ mDelays[what] = ns;
+ return update_delay();
+}
+
+int AkmSensor::update_delay()
+{
+ if (mEnabled) {
+ uint64_t wanted = -1LLU;
+ for (int i=0 ; i<numSensors ; i++) {
+ if (mEnabled & (1<<i)) {
+ uint64_t ns = mDelays[i];
+ wanted = wanted < ns ? wanted : ns;
+ }
+ }
+ short delay = int64_t(wanted) / 1000000;
+ if (ioctl(dev_fd, ECS_IOCTL_APP_SET_DELAY, &delay)) {
+ return -errno;
+ }
+ }
+ return 0;
+}
+
+
+int AkmSensor::loadAKMLibrary()
+{
+ mLibAKM = dlopen("libakm.so", RTLD_NOW);
+
+ if (!mLibAKM) {
+ akm_is_sensor_enabled = stub_is_sensor_enabled;
+ akm_enable_sensor = stub_enable_disable_sensor;
+ akm_disable_sensor = stub_enable_disable_sensor;
+ akm_set_delay = stub_set_delay;
+ LOGE("AkmSensor: unable to load AKM Library, %s", dlerror());
+ return -ENOENT;
+ }
+
+ *(void **)&akm_is_sensor_enabled = dlsym(mLibAKM, "akm_is_sensor_enabled");
+ *(void **)&akm_enable_sensor = dlsym(mLibAKM, "akm_enable_sensor");
+ *(void **)&akm_disable_sensor = dlsym(mLibAKM, "akm_disable_sensor");
+ *(void **)&akm_set_delay = dlsym(mLibAKM, "akm_set_delay");
+
+ return 0;
+}
+
+int AkmSensor::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_REL) {
+ processEvent(event->code, event->value);
+ mInputReader.next();
+ } else if (type == EV_SYN) {
+ int64_t time = timevalToNano(event->time);
+ for (int j=0 ; count && mPendingMask && j<numSensors ; j++) {
+ if (mPendingMask & (1<<j)) {
+ mPendingMask &= ~(1<<j);
+ mPendingEvents[j].timestamp = time;
+ if (mEnabled & (1<<j)) {
+ *data++ = mPendingEvents[j];
+ count--;
+ numEventReceived++;
+ }
+ }
+ }
+ if (!mPendingMask) {
+ mInputReader.next();
+ }
+ } else {
+ LOGE("AkmSensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ mInputReader.next();
+ }
+ }
+ return numEventReceived;
+}
+
+void AkmSensor::processEvent(int code, int value)
+{
+ switch (code) {
+ case EVENT_TYPE_ACCEL_X:
+ mPendingMask |= 1<<Accelerometer;
+ mPendingEvents[Accelerometer].acceleration.x = value * CONVERT_A_X;
+ break;
+ case EVENT_TYPE_ACCEL_Y:
+ mPendingMask |= 1<<Accelerometer;
+ mPendingEvents[Accelerometer].acceleration.y = value * CONVERT_A_Y;
+ break;
+ case EVENT_TYPE_ACCEL_Z:
+ mPendingMask |= 1<<Accelerometer;
+ mPendingEvents[Accelerometer].acceleration.z = value * CONVERT_A_Z;
+ break;
+
+ case EVENT_TYPE_MAGV_X:
+ LOGV("AkmSensor: EVENT_TYPE_MAGV_X value =%d", value);
+ mPendingMask |= 1<<MagneticField;
+ mPendingEvents[MagneticField].magnetic.x = value * CONVERT_M_X;
+ break;
+ case EVENT_TYPE_MAGV_Y:
+ LOGV("AkmSensor: EVENT_TYPE_MAGV_Y value =%d", value);
+ mPendingMask |= 1<<MagneticField;
+ mPendingEvents[MagneticField].magnetic.y = value * CONVERT_M_Y;
+ break;
+ case EVENT_TYPE_MAGV_Z:
+ LOGV("AkmSensor: EVENT_TYPE_MAGV_Z value =%d", value);
+ mPendingMask |= 1<<MagneticField;
+ mPendingEvents[MagneticField].magnetic.z = value * CONVERT_M_Z;
+ break;
+
+ case EVENT_TYPE_YAW:
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.azimuth = value * CONVERT_O_A;
+ break;
+ case EVENT_TYPE_PITCH:
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.pitch = value * CONVERT_O_P;
+ break;
+ case EVENT_TYPE_ROLL:
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.roll = value * CONVERT_O_R;
+ break;
+ case EVENT_TYPE_ORIENT_STATUS:
+ uint8_t status = uint8_t(value & SENSOR_STATE_MASK);
+ if (status == 4)
+ status = 0;
+ mPendingMask |= 1<<Orientation;
+ mPendingEvents[Orientation].orientation.status = status;
+ break;
+ }
+}
diff --git a/libsensors/AkmSensor.h b/libsensors/AkmSensor.h
new file mode 100644
index 0000000..c155ec2
--- /dev/null
+++ b/libsensors/AkmSensor.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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_AKM_SENSOR_H
+#define ANDROID_AKM_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"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class AkmSensor : public SensorBase {
+public:
+ AkmSensor();
+ virtual ~AkmSensor();
+
+ enum {
+ Accelerometer = 0,
+ MagneticField = 1,
+ Orientation = 2,
+ numSensors
+ };
+
+ virtual int setDelay(int32_t handle, int64_t ns);
+ virtual int enable(int32_t handle, int enabled);
+ virtual int readEvents(sensors_event_t* data, int count);
+ void processEvent(int code, int value);
+
+private:
+ int loadAKMLibrary();
+ int update_delay();
+ void *mLibAKM;
+ uint32_t mEnabled;
+ uint32_t mPendingMask;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvents[numSensors];
+ uint64_t mDelays[numSensors];
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_AKM_SENSOR_H
diff --git a/libsensors/Android.mk b/libsensors/Android.mk
new file mode 100644
index 0000000..15c29a2
--- /dev/null
+++ b/libsensors/Android.mk
@@ -0,0 +1,45 @@
+# Copyright (C) 2008 The Android Open Source Project
+#
+# 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.
+
+
+LOCAL_PATH := $(call my-dir)
+
+ifneq ($(TARGET_SIMULATOR),true)
+
+# HAL module implemenation, not prelinked, and stored in
+# hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.product.board>.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := sensors.$(TARGET_BOARD_PLATFORM)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\"
+LOCAL_SRC_FILES := \
+ sensors.cpp \
+ SensorBase.cpp \
+ LightSensor.cpp \
+ ProximitySensor.cpp \
+ AkmSensor.cpp \
+ GyroSensor.cpp \
+ InputEventReader.cpp
+
+LOCAL_SHARED_LIBRARIES := liblog libcutils libdl
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # !TARGET_SIMULATOR
diff --git a/libsensors/GyroSensor.cpp b/libsensors/GyroSensor.cpp
new file mode 100644
index 0000000..ef0c01c
--- /dev/null
+++ b/libsensors/GyroSensor.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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 <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+#include <cutils/log.h>
+
+#include "GyroSensor.h"
+
+#define FETCH_FULL_EVENT_BEFORE_RETURN 1
+#define IGNORE_EVENT_TIME 350000000
+/*****************************************************************************/
+
+GyroSensor::GyroSensor()
+ : SensorBase(NULL, "gyro_sensor"),
+ mEnabled(0),
+ mInputReader(4),
+ mHasPendingEvent(false),
+ mEnabledTime(0)
+{
+ mPendingEvent.version = sizeof(sensors_event_t);
+ mPendingEvent.sensor = ID_GY;
+ mPendingEvent.type = SENSOR_TYPE_GYROSCOPE;
+ memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
+
+ if (data_fd) {
+ strcpy(input_sysfs_path, "/sys/class/input/");
+ strcat(input_sysfs_path, input_name);
+ strcat(input_sysfs_path, "/device/");
+ input_sysfs_path_len = strlen(input_sysfs_path);
+ enable(0, 1);
+ }
+}
+
+GyroSensor::~GyroSensor() {
+ if (mEnabled) {
+ enable(0, 0);
+ }
+}
+
+int GyroSensor::setInitialState() {
+ struct input_absinfo absinfo_x;
+ struct input_absinfo absinfo_y;
+ struct input_absinfo absinfo_z;
+ float value;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_x) &&
+ !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_y) &&
+ !ioctl(data_fd, EVIOCGABS(EVENT_TYPE_GYRO_X), &absinfo_z)) {
+ value = absinfo_x.value;
+ mPendingEvent.data[0] = value * CONVERT_GYRO_X;
+ value = absinfo_x.value;
+ mPendingEvent.data[1] = value * CONVERT_GYRO_Y;
+ value = absinfo_x.value;
+ mPendingEvent.data[2] = value * CONVERT_GYRO_Z;
+ mHasPendingEvent = true;
+ }
+ return 0;
+}
+
+int GyroSensor::enable(int32_t, int en) {
+ int flags = en ? 1 : 0;
+ if (flags != mEnabled) {
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "enable");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[2];
+ int err;
+ buf[1] = 0;
+ if (flags) {
+ buf[0] = '1';
+ mEnabledTime = getTimestamp() + IGNORE_EVENT_TIME;
+ } else {
+ buf[0] = '0';
+ }
+ err = write(fd, buf, sizeof(buf));
+ close(fd);
+ mEnabled = flags;
+ setInitialState();
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+bool GyroSensor::hasPendingEvents() const {
+ return mHasPendingEvent;
+}
+
+int GyroSensor::setDelay(int32_t handle, int64_t delay_ns)
+{
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[80];
+ sprintf(buf, "%lld", delay_ns);
+ write(fd, buf, strlen(buf)+1);
+ close(fd);
+ return 0;
+ }
+ return -1;
+}
+
+int GyroSensor::readEvents(sensors_event_t* data, int count)
+{
+ if (count < 1)
+ return -EINVAL;
+
+ if (mHasPendingEvent) {
+ mHasPendingEvent = false;
+ mPendingEvent.timestamp = getTimestamp();
+ *data = mPendingEvent;
+ return mEnabled ? 1 : 0;
+ }
+
+ ssize_t n = mInputReader.fill(data_fd);
+ if (n < 0)
+ return n;
+
+ int numEventReceived = 0;
+ input_event const* event;
+
+#if FETCH_FULL_EVENT_BEFORE_RETURN
+again:
+#endif
+ while (count && mInputReader.readEvent(&event)) {
+ int type = event->type;
+ if (type == EV_REL) {
+ float value = event->value;
+ if (event->code == EVENT_TYPE_GYRO_X) {
+ mPendingEvent.data[0] = value * CONVERT_GYRO_X;
+ } else if (event->code == EVENT_TYPE_GYRO_Y) {
+ mPendingEvent.data[1] = value * CONVERT_GYRO_Y;
+ } else if (event->code == EVENT_TYPE_GYRO_Z) {
+ mPendingEvent.data[2] = value * CONVERT_GYRO_Z;
+ }
+ } else if (type == EV_SYN) {
+ mPendingEvent.timestamp = timevalToNano(event->time);
+ if (mEnabled) {
+ if (mPendingEvent.timestamp >= mEnabledTime) {
+ *data++ = mPendingEvent;
+ numEventReceived++;
+ }
+ count--;
+ }
+ } else {
+ LOGE("GyroSensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ }
+ mInputReader.next();
+ }
+
+#if FETCH_FULL_EVENT_BEFORE_RETURN
+ /* if we didn't read a complete event, see if we can fill and
+ try again instead of returning with nothing and redoing poll. */
+ if (numEventReceived == 0 && mEnabled == 1) {
+ n = mInputReader.fill(data_fd);
+ if (n)
+ goto again;
+ }
+#endif
+
+ return numEventReceived;
+}
+
diff --git a/libsensors/GyroSensor.h b/libsensors/GyroSensor.h
new file mode 100644
index 0000000..e8997de
--- /dev/null
+++ b/libsensors/GyroSensor.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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_GYRO_SENSOR_H
+#define ANDROID_GYRO_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"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class GyroSensor : public SensorBase {
+ int mEnabled;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvent;
+ bool mHasPendingEvent;
+ char input_sysfs_path[PATH_MAX];
+ int input_sysfs_path_len;
+ int64_t mEnabledTime;
+
+ int setInitialState();
+
+public:
+ GyroSensor();
+ virtual ~GyroSensor();
+ virtual int readEvents(sensors_event_t* data, int count);
+ virtual bool hasPendingEvents() const;
+ virtual int setDelay(int32_t handle, int64_t ns);
+ virtual int enable(int32_t handle, int enabled);
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_GYRO_SENSOR_H
diff --git a/libsensors/InputEventReader.cpp b/libsensors/InputEventReader.cpp
new file mode 100644
index 0000000..1014f29
--- /dev/null
+++ b/libsensors/InputEventReader.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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 <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)
+{
+}
+
+InputEventCircularReader::~InputEventCircularReader()
+{
+ delete [] mBuffer;
+}
+
+ssize_t InputEventCircularReader::fill(int fd)
+{
+ size_t numEventsRead = 0;
+ if (mFreeSpace) {
+ const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event));
+ if (nread<0 || nread % sizeof(input_event)) {
+ // we got a partial event!!
+ 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;
+ }
+ }
+ }
+
+ return numEventsRead;
+}
+
+ssize_t InputEventCircularReader::readEvent(input_event const** events)
+{
+ *events = mCurr;
+ ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace;
+ return available ? 1 : 0;
+}
+
+void InputEventCircularReader::next()
+{
+ mCurr++;
+ mFreeSpace++;
+ if (mCurr >= mBufferEnd) {
+ mCurr = mBuffer;
+ }
+}
diff --git a/libsensors/InputEventReader.h b/libsensors/InputEventReader.h
new file mode 100644
index 0000000..180aade
--- /dev/null
+++ b/libsensors/InputEventReader.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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>
+
+/*****************************************************************************/
+
+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;
+
+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/libsensors/LightSensor.cpp b/libsensors/LightSensor.cpp
new file mode 100644
index 0000000..c278cd9
--- /dev/null
+++ b/libsensors/LightSensor.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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 <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+
+#include <linux/lightsensor.h>
+
+#include <cutils/log.h>
+
+#include "LightSensor.h"
+
+// #define LOG_NDEBUG 0
+
+/*****************************************************************************/
+
+LightSensor::LightSensor()
+ : SensorBase(NULL, "light_sensor"),
+ mEnabled(0),
+ mInputReader(4),
+ mHasPendingEvent(false)
+{
+ mPendingEvent.version = sizeof(sensors_event_t);
+ mPendingEvent.sensor = ID_L;
+ mPendingEvent.type = SENSOR_TYPE_LIGHT;
+ memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
+
+ if (data_fd) {
+ strcpy(input_sysfs_path, "/sys/class/input/");
+ strcat(input_sysfs_path, input_name);
+ strcat(input_sysfs_path, "/device/");
+ input_sysfs_path_len = strlen(input_sysfs_path);
+ enable(0, 1);
+ }
+}
+
+LightSensor::~LightSensor() {
+ if (mEnabled) {
+ enable(0, 0);
+ }
+}
+
+int LightSensor::setInitialState() {
+ struct input_absinfo absinfo;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_LIGHT), &absinfo)) {
+ // make sure to report an event immediately
+ mHasPendingEvent = true;
+ mPendingEvent.light = absinfo.value;
+ }
+ return 0;
+}
+
+int LightSensor::setDelay(int32_t handle, int64_t ns)
+{
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "poll_delay");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[80];
+ sprintf(buf, "%lld", ns);
+ write(fd, buf, strlen(buf)+1);
+ close(fd);
+ return 0;
+ }
+ return -1;
+}
+
+int LightSensor::enable(int32_t handle, int en)
+{
+ int flags = en ? 1 : 0;
+ if (flags != mEnabled) {
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "enable");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[2];
+ int err;
+ buf[1] = 0;
+ if (flags) {
+ buf[0] = '1';
+ } else {
+ buf[0] = '0';
+ }
+ err = write(fd, buf, sizeof(buf));
+ close(fd);
+ mEnabled = flags;
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+bool LightSensor::hasPendingEvents() const {
+ return mHasPendingEvent;
+}
+
+int LightSensor::readEvents(sensors_event_t* data, int count)
+{
+ if (count < 1)
+ return -EINVAL;
+
+ if (mHasPendingEvent) {
+ mHasPendingEvent = false;
+ mPendingEvent.timestamp = getTimestamp();
+ *data = mPendingEvent;
+ return mEnabled ? 1 : 0;
+ }
+
+ 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_ABS) {
+ if (event->code == EVENT_TYPE_LIGHT) {
+ // Convert adc value to lux assuming:
+ // I = 10 * log(Ev) uA
+ // R = 47kOhm
+ // Max adc value 4095 = 3.3V
+ // 1/4 of light reaches sensor
+ mPendingEvent.light = powf(10, event->value * (330.0f / 4095.0f / 47.0f)) * 4;
+ }
+ } else if (type == EV_SYN) {
+ mPendingEvent.timestamp = timevalToNano(event->time);
+ if (mEnabled) {
+ *data++ = mPendingEvent;
+ count--;
+ numEventReceived++;
+ }
+ } else {
+ LOGE("LightSensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ }
+ mInputReader.next();
+ }
+
+ return numEventReceived;
+}
diff --git a/libsensors/LightSensor.h b/libsensors/LightSensor.h
new file mode 100644
index 0000000..85e65d9
--- /dev/null
+++ b/libsensors/LightSensor.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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_LIGHT_SENSOR_H
+#define ANDROID_LIGHT_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"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class LightSensor : public SensorBase {
+ int mEnabled;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvent;
+ bool mHasPendingEvent;
+ char input_sysfs_path[PATH_MAX];
+ int input_sysfs_path_len;
+
+ float indexToValue(size_t index) const;
+ int setInitialState();
+
+public:
+ LightSensor();
+ virtual ~LightSensor();
+ virtual int readEvents(sensors_event_t* data, int count);
+ virtual bool hasPendingEvents() const;
+ virtual int setDelay(int32_t handle, int64_t ns);
+ virtual int enable(int32_t handle, int enabled);
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_LIGHT_SENSOR_H
diff --git a/libsensors/MODULE_LICENSE_APACHE2 b/libsensors/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libsensors/MODULE_LICENSE_APACHE2
diff --git a/libsensors/ProximitySensor.cpp b/libsensors/ProximitySensor.cpp
new file mode 100644
index 0000000..cdc6d2a
--- /dev/null
+++ b/libsensors/ProximitySensor.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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 <unistd.h>
+#include <dirent.h>
+#include <sys/select.h>
+
+#include <linux/capella_cm3602.h>
+
+#include <cutils/log.h>
+
+#include "ProximitySensor.h"
+
+/*****************************************************************************/
+
+ProximitySensor::ProximitySensor()
+ : SensorBase(NULL, "proximity_sensor"),
+ mEnabled(0),
+ mInputReader(4),
+ mHasPendingEvent(false)
+{
+ mPendingEvent.version = sizeof(sensors_event_t);
+ mPendingEvent.sensor = ID_P;
+ mPendingEvent.type = SENSOR_TYPE_PROXIMITY;
+ memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
+
+ if (data_fd) {
+ strcpy(input_sysfs_path, "/sys/class/input/");
+ strcat(input_sysfs_path, input_name);
+ strcat(input_sysfs_path, "/device/");
+ input_sysfs_path_len = strlen(input_sysfs_path);
+ enable(0, 1);
+ }
+}
+
+ProximitySensor::~ProximitySensor() {
+ if (mEnabled) {
+ enable(0, 0);
+ }
+}
+
+int ProximitySensor::setInitialState() {
+ struct input_absinfo absinfo;
+ if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PROXIMITY), &absinfo)) {
+ // make sure to report an event immediately
+ mHasPendingEvent = true;
+ mPendingEvent.distance = indexToValue(absinfo.value);
+ }
+ return 0;
+}
+
+int ProximitySensor::enable(int32_t, int en) {
+ int flags = en ? 1 : 0;
+ if (flags != mEnabled) {
+ int fd;
+ strcpy(&input_sysfs_path[input_sysfs_path_len], "enable");
+ fd = open(input_sysfs_path, O_RDWR);
+ if (fd >= 0) {
+ char buf[2];
+ buf[1] = 0;
+ if (flags) {
+ buf[0] = '1';
+ } else {
+ buf[0] = '0';
+ }
+ write(fd, buf, sizeof(buf));
+ close(fd);
+ mEnabled = flags;
+ setInitialState();
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
+}
+
+bool ProximitySensor::hasPendingEvents() const {
+ return mHasPendingEvent;
+}
+
+int ProximitySensor::readEvents(sensors_event_t* data, int count)
+{
+ if (count < 1)
+ return -EINVAL;
+
+ if (mHasPendingEvent) {
+ mHasPendingEvent = false;
+ mPendingEvent.timestamp = getTimestamp();
+ *data = mPendingEvent;
+ return mEnabled ? 1 : 0;
+ }
+
+ 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_ABS) {
+ if (event->code == EVENT_TYPE_PROXIMITY) {
+ if (event->value != -1) {
+ // FIXME: not sure why we're getting -1 sometimes
+ mPendingEvent.distance = indexToValue(event->value);
+ }
+ }
+ } else if (type == EV_SYN) {
+ mPendingEvent.timestamp = timevalToNano(event->time);
+ if (mEnabled) {
+ *data++ = mPendingEvent;
+ count--;
+ numEventReceived++;
+ }
+ } else {
+ LOGE("ProximitySensor: unknown event (type=%d, code=%d)",
+ type, event->code);
+ }
+ mInputReader.next();
+ }
+
+ return numEventReceived;
+}
+
+float ProximitySensor::indexToValue(size_t index) const
+{
+ return index * PROXIMITY_THRESHOLD_GP2A;
+}
diff --git a/libsensors/ProximitySensor.h b/libsensors/ProximitySensor.h
new file mode 100644
index 0000000..08ea49c
--- /dev/null
+++ b/libsensors/ProximitySensor.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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_PROXIMITY_SENSOR_H
+#define ANDROID_PROXIMITY_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"
+
+/*****************************************************************************/
+
+struct input_event;
+
+class ProximitySensor : public SensorBase {
+ int mEnabled;
+ InputEventCircularReader mInputReader;
+ sensors_event_t mPendingEvent;
+ bool mHasPendingEvent;
+ char input_sysfs_path[PATH_MAX];
+ int input_sysfs_path_len;
+
+ int setInitialState();
+ float indexToValue(size_t index) const;
+
+public:
+ ProximitySensor();
+ virtual ~ProximitySensor();
+ virtual int readEvents(sensors_event_t* data, int count);
+ virtual bool hasPendingEvents() const;
+ virtual int enable(int32_t handle, int enabled);
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_PROXIMITY_SENSOR_H
diff --git a/libsensors/SensorBase.cpp b/libsensors/SensorBase.cpp
new file mode 100644
index 0000000..d448eb2
--- /dev/null
+++ b/libsensors/SensorBase.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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 <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)
+{
+ if (data_name) {
+ data_fd = openInput(data_name);
+ }
+}
+
+SensorBase::~SensorBase() {
+ if (data_fd >= 0) {
+ close(data_fd);
+ }
+ if (dev_fd >= 0) {
+ close(dev_fd);
+ }
+}
+
+int SensorBase::open_device() {
+ 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() {
+ if (dev_fd >= 0) {
+ close(dev_fd);
+ dev_fd = -1;
+ }
+ return 0;
+}
+
+int SensorBase::getFd() const {
+ if (!data_name) {
+ return dev_fd;
+ }
+ return data_fd;
+}
+
+int SensorBase::setDelay(int32_t handle, int64_t ns) {
+ return 0;
+}
+
+bool SensorBase::hasPendingEvents() const {
+ return false;
+}
+
+int64_t SensorBase::getTimestamp() {
+ 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) {
+ 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);
+ if (fd>=0) {
+ char name[80];
+ if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
+ name[0] = '\0';
+ }
+ 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;
+}
diff --git a/libsensors/SensorBase.h b/libsensors/SensorBase.h
new file mode 100644
index 0000000..bb4d055
--- /dev/null
+++ b/libsensors/SensorBase.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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>
+
+
+/*****************************************************************************/
+
+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) = 0;
+};
+
+/*****************************************************************************/
+
+#endif // ANDROID_SENSOR_BASE_H
diff --git a/libsensors/ak8973b.h b/libsensors/ak8973b.h
new file mode 100644
index 0000000..9b7ab60
--- /dev/null
+++ b/libsensors/ak8973b.h
@@ -0,0 +1,51 @@
+/*
+ * Definitions for akm8973 compass chip.
+ */
+#ifndef AKM8973_H
+#define AKM8973_H
+
+#include <linux/ioctl.h>
+
+#define AKM8973_I2C_NAME "ak8973b"
+
+#define AKMIO 0xA1
+
+/* IOCTLs for AKM library */
+#define ECS_IOCTL_WRITE _IOW(AKMIO, 0x01, char*)
+#define ECS_IOCTL_READ _IOWR(AKMIO, 0x02, char*)
+#define ECS_IOCTL_RESET _IO(AKMIO, 0x03)
+#define ECS_IOCTL_SET_MODE _IOW(AKMIO, 0x04, short)
+#define ECS_IOCTL_GETDATA _IOR(AKMIO, 0x05, char[SENSOR_DATA_SIZE])
+#define ECS_IOCTL_SET_YPR _IOW(AKMIO, 0x06, short[12])
+#define ECS_IOCTL_GET_OPEN_STATUS _IOR(AKMIO, 0x07, int)
+#define ECS_IOCTL_GET_CLOSE_STATUS _IOR(AKMIO, 0x08, int)
+#define ECS_IOCTL_GET_DELAY _IOR(AKMIO, 0x30, int64_t)
+#define ECS_IOCTL_GET_PROJECT_NAME _IOR(AKMIO, 0x0D, char[64])
+#define ECS_IOCTL_GET_MATRIX _IOR(AKMIO, 0x0E, short [4][3][3])
+
+/* IOCTLs for APPs */
+#define ECS_IOCTL_APP_SET_MODE _IOW(AKMIO, 0x10, short)
+#define ECS_IOCTL_APP_SET_MFLAG _IOW(AKMIO, 0x11, short)
+#define ECS_IOCTL_APP_GET_MFLAG _IOW(AKMIO, 0x12, short)
+#define ECS_IOCTL_APP_SET_AFLAG _IOW(AKMIO, 0x13, short)
+#define ECS_IOCTL_APP_GET_AFLAG _IOR(AKMIO, 0x14, short)
+#define ECS_IOCTL_APP_SET_TFLAG _IOR(AKMIO, 0x15, short)
+#define ECS_IOCTL_APP_GET_TFLAG _IOR(AKMIO, 0x16, short)
+#define ECS_IOCTL_APP_RESET_PEDOMETER _IO(AKMIO, 0x17)
+#define ECS_IOCTL_APP_SET_DELAY _IOW(AKMIO, 0x18, int64_t)
+#define ECS_IOCTL_APP_GET_DELAY ECS_IOCTL_GET_DELAY
+
+/* Set raw magnetic vector flag */
+#define ECS_IOCTL_APP_SET_MVFLAG _IOW(AKMIO, 0x19, short)
+
+/* Get raw magnetic vector flag */
+#define ECS_IOCTL_APP_GET_MVFLAG _IOR(AKMIO, 0x1A, short)
+
+struct akm8973_platform_data {
+ short layouts[4][3][3];
+ char project_name[64];
+ int gpio_RST;
+ int gpio_INT;
+};
+
+#endif
diff --git a/libsensors/sensors.cpp b/libsensors/sensors.cpp
new file mode 100644
index 0000000..24ce66a
--- /dev/null
+++ b/libsensors/sensors.cpp
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#define LOG_TAG "Sensors"
+
+#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 <linux/input.h>
+
+#include <utils/Atomic.h>
+#include <utils/Log.h>
+
+#include "sensors.h"
+
+#include "LightSensor.h"
+#include "ProximitySensor.h"
+#include "AkmSensor.h"
+#include "GyroSensor.h"
+
+/*****************************************************************************/
+
+#define DELAY_OUT_TIME 0x7FFFFFFF
+
+#define LIGHT_SENSOR_POLLTIME 2000000000
+
+
+#define SENSORS_ACCELERATION (1<<ID_A)
+#define SENSORS_MAGNETIC_FIELD (1<<ID_M)
+#define SENSORS_ORIENTATION (1<<ID_O)
+#define SENSORS_LIGHT (1<<ID_L)
+#define SENSORS_PROXIMITY (1<<ID_P)
+#define SENSORS_GYROSCOPE (1<<ID_GY)
+
+#define SENSORS_ACCELERATION_HANDLE 0
+#define SENSORS_MAGNETIC_FIELD_HANDLE 1
+#define SENSORS_ORIENTATION_HANDLE 2
+#define SENSORS_LIGHT_HANDLE 3
+#define SENSORS_PROXIMITY_HANDLE 4
+#define SENSORS_GYROSCOPE_HANDLE 5
+
+#define AKM_FTRACE 0
+#define AKM_DEBUG 0
+#define AKM_DATA 0
+
+/*****************************************************************************/
+
+/* The SENSORS Module */
+static const struct sensor_t sSensorList[] = {
+ { "KR3DM 3-axis Accelerometer",
+ "STMicroelectronics",
+ 1, SENSORS_ACCELERATION_HANDLE,
+ SENSOR_TYPE_ACCELEROMETER, RANGE_A, CONVERT_A, 0.23f, 20000, { } },
+ { "AK8975 3-axis Magnetic field sensor",
+ "Asahi Kasei Microdevices",
+ 1, SENSORS_MAGNETIC_FIELD_HANDLE,
+ SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, CONVERT_M, 6.8f, 16667, { } },
+ { "AK8973 Orientation sensor",
+ "Asahi Kasei Microdevices",
+ 1, SENSORS_ORIENTATION_HANDLE,
+ SENSOR_TYPE_ORIENTATION, 360.0f, CONVERT_O, 7.8f, 16667, { } },
+ { "GP2A Light sensor",
+ "Sharp",
+ 1, SENSORS_LIGHT_HANDLE,
+ SENSOR_TYPE_LIGHT, 10240.0f, 1.0f, 0.75f, 0, { } },
+ { "GP2A Proximity sensor",
+ "Sharp",
+ 1, SENSORS_PROXIMITY_HANDLE,
+ SENSOR_TYPE_PROXIMITY, 5.0f, 5.0f, 0.75f, 0, { } },
+ { "K3G Gyroscope sensor",
+ "STMicroelectronics",
+ 1, SENSORS_GYROSCOPE_HANDLE,
+ SENSOR_TYPE_GYROSCOPE, RANGE_GYRO, CONVERT_GYRO, 6.1f, 1190, { } },
+};
+
+
+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: "Samsung Sensor module",
+ author: "Samsung Electronic Company",
+ methods: &sensors_module_methods,
+ },
+ get_sensors_list: sensors__get_sensors_list,
+};
+
+struct sensors_poll_context_t {
+ struct sensors_poll_device_t device; // must be first
+
+ sensors_poll_context_t();
+ ~sensors_poll_context_t();
+ int activate(int handle, int enabled);
+ int setDelay(int handle, int64_t ns);
+ int pollEvents(sensors_event_t* data, int count);
+
+private:
+ enum {
+ light = 0,
+ proximity = 1,
+ akm = 2,
+ gyro = 3,
+ numSensorDrivers,
+ numFds,
+ };
+
+ static const size_t wake = numFds - 1;
+ static const char WAKE_MESSAGE = 'W';
+ struct pollfd mPollFds[numFds];
+ int mWritePipeFd;
+ SensorBase* mSensors[numSensorDrivers];
+
+ int handleToDriver(int handle) const {
+ switch (handle) {
+ case ID_A:
+ case ID_M:
+ case ID_O:
+ return akm;
+ case ID_P:
+ return proximity;
+ case ID_L:
+ return light;
+ case ID_GY:
+ return gyro;
+ }
+ return -EINVAL;
+ }
+};
+
+/*****************************************************************************/
+
+sensors_poll_context_t::sensors_poll_context_t()
+{
+ mSensors[light] = new LightSensor();
+ mPollFds[light].fd = mSensors[light]->getFd();
+ mPollFds[light].events = POLLIN;
+ mPollFds[light].revents = 0;
+
+ mSensors[proximity] = new ProximitySensor();
+ mPollFds[proximity].fd = mSensors[proximity]->getFd();
+ mPollFds[proximity].events = POLLIN;
+ mPollFds[proximity].revents = 0;
+
+ mSensors[akm] = new AkmSensor();
+ mPollFds[akm].fd = mSensors[akm]->getFd();
+ mPollFds[akm].events = POLLIN;
+ mPollFds[akm].revents = 0;
+
+ mSensors[gyro] = new GyroSensor();
+ mPollFds[gyro].fd = mSensors[gyro]->getFd();
+ mPollFds[gyro].events = POLLIN;
+ mPollFds[gyro].revents = 0;
+
+ int wakeFds[2];
+ int result = pipe(wakeFds);
+ LOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno));
+ fcntl(wakeFds[0], F_SETFL, O_NONBLOCK);
+ fcntl(wakeFds[1], F_SETFL, O_NONBLOCK);
+ mWritePipeFd = wakeFds[1];
+
+ mPollFds[wake].fd = wakeFds[0];
+ mPollFds[wake].events = POLLIN;
+ mPollFds[wake].revents = 0;
+}
+
+sensors_poll_context_t::~sensors_poll_context_t() {
+ for (int i=0 ; i<numSensorDrivers ; i++) {
+ delete mSensors[i];
+ }
+ close(mPollFds[wake].fd);
+ close(mWritePipeFd);
+}
+
+int sensors_poll_context_t::activate(int handle, int enabled) {
+ int index = handleToDriver(handle);
+ if (index < 0) return index;
+ int err = mSensors[index]->enable(handle, enabled);
+ if (enabled && !err) {
+ const char wakeMessage(WAKE_MESSAGE);
+ int result = write(mWritePipeFd, &wakeMessage, 1);
+ LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno));
+ }
+ return err;
+}
+
+int sensors_poll_context_t::setDelay(int handle, int64_t ns) {
+
+ int index = handleToDriver(handle);
+ if (index < 0) return index;
+ return mSensors[index]->setDelay(handle, ns);
+}
+
+int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
+{
+ int nbEvents = 0;
+ int n = 0;
+
+ do {
+ // see if we have some leftover from the last poll()
+ for (int i=0 ; count && i<numSensorDrivers ; i++) {
+ SensorBase* const sensor(mSensors[i]);
+ if ((mPollFds[i].revents & POLLIN) || (sensor->hasPendingEvents())) {
+ int nb = sensor->readEvents(data, count);
+ if (nb < count) {
+ // no more data for this sensor
+ mPollFds[i].revents = 0;
+ }
+ count -= nb;
+ nbEvents += nb;
+ data += nb;
+ }
+ }
+
+ if (count) {
+ // we still have some room, so try to see if we can get
+ // some events immediately or just wait if we don't have
+ // anything to return
+ n = poll(mPollFds, numFds, nbEvents ? 0 : -1);
+ if (n<0) {
+ LOGE("poll() failed (%s)", strerror(errno));
+ return -errno;
+ }
+ if (mPollFds[wake].revents & POLLIN) {
+ char msg;
+ int result = read(mPollFds[wake].fd, &msg, 1);
+ LOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno));
+ LOGE_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)
+{
+ 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) {
+ 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) {
+ sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
+ return ctx->setDelay(handle, ns);
+}
+
+static int poll__poll(struct sensors_poll_device_t *dev,
+ sensors_event_t* data, int count) {
+ 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)
+{
+ int status = -EINVAL;
+ sensors_poll_context_t *dev = new sensors_poll_context_t();
+
+ memset(&dev->device, 0, sizeof(sensors_poll_device_t));
+
+ dev->device.common.tag = HARDWARE_DEVICE_TAG;
+ dev->device.common.version = 0;
+ 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;
+ dev->device.poll = poll__poll;
+
+ *device = &dev->device.common;
+ status = 0;
+
+ return status;
+}
+
diff --git a/libsensors/sensors.h b/libsensors/sensors.h
new file mode 100644
index 0000000..5eb6291
--- /dev/null
+++ b/libsensors/sensors.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * 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_SENSORS_H
+#define ANDROID_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_A (0)
+#define ID_M (1)
+#define ID_O (2)
+#define ID_L (3)
+#define ID_P (4)
+#define ID_GY (5)
+
+/*****************************************************************************/
+
+/*
+ * The SENSORS Module
+ */
+
+/* the GP2A is a binary proximity sensor that triggers around 5 cm on
+ * this hardware */
+#define PROXIMITY_THRESHOLD_GP2A 5.0f
+
+/*****************************************************************************/
+
+#define AKM_DEVICE_NAME "/dev/akm8975"
+
+// for akm8975
+#define EVENT_TYPE_ACCEL_X ABS_Y //1
+#define EVENT_TYPE_ACCEL_Y ABS_X //0
+#define EVENT_TYPE_ACCEL_Z ABS_Z //2
+//#define EVENT_TYPE_ACCEL_STATUS ABS_WHEEL //8
+
+#define EVENT_TYPE_YAW ABS_RX //3
+#define EVENT_TYPE_PITCH ABS_RY //4
+#define EVENT_TYPE_ROLL ABS_RZ //5
+#define EVENT_TYPE_ORIENT_STATUS ABS_WHEEL //8
+
+#define EVENT_TYPE_MAGV_X ABS_THROTTLE // 7
+#define EVENT_TYPE_MAGV_Y ABS_RUDDER // 6
+#define EVENT_TYPE_MAGV_Z ABS_GAS // 9
+
+#define EVENT_TYPE_TEMPERATURE ABS_THROTTLE
+#define EVENT_TYPE_STEP_COUNT ABS_GAS
+#define EVENT_TYPE_PROXIMITY ABS_DISTANCE
+#define EVENT_TYPE_LIGHT ABS_MISC
+
+#define EVENT_TYPE_GYRO_X REL_RY
+#define EVENT_TYPE_GYRO_Y REL_RX
+#define EVENT_TYPE_GYRO_Z REL_RZ
+
+// 90 LSB = 1G for KR3DM
+#define LSB (90.0f)
+#define NUMOFACCDATA (8.0f)
+
+// conversion of acceleration data to SI units (m/s^2)
+#define RANGE_A (2*GRAVITY_EARTH)
+#define CONVERT_A (GRAVITY_EARTH / LSB / NUMOFACCDATA)
+#define CONVERT_A_X (CONVERT_A)
+#define CONVERT_A_Y (-CONVERT_A)
+#define CONVERT_A_Z (-CONVERT_A)
+
+// conversion of magnetic data to uT units
+#define CONVERT_M (1.0f/16.0f)
+#define CONVERT_M_X (-CONVERT_M)
+#define CONVERT_M_Y (-CONVERT_M)
+#define CONVERT_M_Z (CONVERT_M)
+
+/* conversion of orientation data to degree units */
+#define CONVERT_O (1.0f/1000.0f)
+#define CONVERT_O_A (CONVERT_O)
+#define CONVERT_O_P (CONVERT_O)
+#define CONVERT_O_R (CONVERT_O)
+
+// conversion of gyro data to SI units (radian/sec)
+#define RANGE_GYRO (500.0f*(float)M_PI/180.0f)
+#define CONVERT_GYRO ((70.0f / 4000.0f) * ((float)M_PI / 180.0f))
+#define CONVERT_GYRO_X (-CONVERT_GYRO)
+#define CONVERT_GYRO_Y (-CONVERT_GYRO)
+#define CONVERT_GYRO_Z (-CONVERT_GYRO)
+
+#define SENSOR_STATE_MASK (0x7FFF)
+
+/*****************************************************************************/
+
+__END_DECLS
+
+#endif // ANDROID_SENSORS_H
diff --git a/overlay/frameworks/base/core/res/res/values/config.xml b/overlay/frameworks/base/core/res/res/values/config.xml
index 85a09aa..78d8e98 100755
--- a/overlay/frameworks/base/core/res/res/values/config.xml
+++ b/overlay/frameworks/base/core/res/res/values/config.xml
@@ -64,11 +64,23 @@
Must be overridden in platform specific overlays -->
<integer-array name="config_autoBrightnessLevels">
- <item>100</item>
- <item>200</item>
- <item>400</item>
- <item>1000</item>
- <item>3000</item>
+ <item>14</item>
+ <item>20</item>
+ <item>30</item>
+ <item>46</item>
+ <item>68</item>
+ <item>103</item>
+ <item>154</item>
+ <item>231</item>
+ <item>346</item>
+ <item>519</item>
+ <item>778</item>
+ <item>1168</item>
+ <item>1752</item>
+ <item>2627</item>
+ <item>3941</item>
+ <item>5912</item>
+ <item>8867</item>
</integer-array>
<!-- Array of output values for LCD backlight corresponding to the LUX values
@@ -76,11 +88,23 @@
than the size of the config_autoBrightnessLevels array.
-->
<integer-array name="config_autoBrightnessLcdBacklightValues">
- <item>16</item>
- <item>40</item>
- <item>60</item>
- <item>70</item>
- <item>70</item>
+ <item>26</item>
+ <item>30</item>
+ <item>34</item>
+ <item>39</item>
+ <item>45</item>
+ <item>51</item>
+ <item>59</item>
+ <item>67</item>
+ <item>77</item>
+ <item>88</item>
+ <item>101</item>
+ <item>116</item>
+ <item>133</item>
+ <item>152</item>
+ <item>174</item>
+ <item>199</item>
+ <item>228</item>
<item>250</item>
</integer-array>
@@ -95,6 +119,18 @@
<item>0</item>
<item>0</item>
<item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
</integer-array>
<!-- Array of output values for keyboard backlight corresponding to the LUX values
@@ -109,17 +145,25 @@
<item>0</item>
<item>0</item>
<item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
+ <item>0</item>
</integer-array>
<!-- Minimum screen brightness allowed by the power manager. -->
- <integer name="config_screenBrightnessDim">10</integer>
+ <integer name="config_screenBrightnessDim">29</integer>
- <!-- Set additional audio parameters for incall audio
- Usage: parameter=onstring=offstring
- Examples: <item>realcall=on=off</item> <item>dualmic_enabled=true=false</item> <item>mic_boost=yes=no</item> -->
- <string-array name="config_telephony_set_audioparameters" translatable="false">
- <item>dualmic_enabled=true=false</item>
- </string-array>
+ <!--Boolean to enable stk functionality on Samsung phones-->
+ <bool name="config_samsung_stk">true</bool>
<!-- XXXXX NOTE THE FOLLOWING RESOURCES USE THE WRONG NAMING CONVENTION.
Please don't copy them, copy anything else. -->
diff --git a/overlay/packages/apps/Camera/res/values/config.xml b/overlay/packages/apps/Camera/res/values/config.xml
index 472a0b2..788a977 100644
--- a/overlay/packages/apps/Camera/res/values/config.xml
+++ b/overlay/packages/apps/Camera/res/values/config.xml
@@ -24,4 +24,6 @@
<bool name="needsSamsungCamMode">true</bool>
<!-- Samsung Camera Settings -->
<bool name="hasSamsungCamSettings">true</bool>
+ <!-- Restart the preview on picture taken -->
+ <bool name="restartPreviewOnPictureTaken">true</bool>
</resources>
diff --git a/overlay/packages/apps/Phone/res/values/config.xml b/overlay/packages/apps/Phone/res/values/config.xml
index 00f2f7b..48d1ffc 100755
--- a/overlay/packages/apps/Phone/res/values/config.xml
+++ b/overlay/packages/apps/Phone/res/values/config.xml
@@ -20,4 +20,9 @@
<!-- Flag indicating if the tty is enabled -->
<bool name="tty_enabled">false</bool>
+ <!-- Determines if device implements a noise suppression device for in call audio-->
+ <bool name="has_in_call_noise_suppression">true</bool>
+
+ <!-- Audio parameter for setting noise suppression-->
+ <string name="in_call_noise_suppression_audioparameter">dualmic_enabled=true=false</string>
</resources>
diff --git a/releasetools/n7000_ota_from_target_files b/releasetools/n7000_ota_from_target_files
index 53a2893..f19f059 100755
--- a/releasetools/n7000_ota_from_target_files
+++ b/releasetools/n7000_ota_from_target_files
@@ -61,7 +61,9 @@ def WriteFullOTAPackage(input_zip, output_zip):
AppendAssertions(script, input_zip)
device_specific.FullOTA_Assertions()
if OPTIONS.backuptool:
+ script.Mount("/system")
script.RunBackup("backup")
+ script.Unmount("/system")
script.ShowProgress(0.5, 0)