Bug 746728 - Add sensor index fallback for qemu, r=gal a=b2g-only
authorMichael Wu <mwu@mozilla.com>
Wed, 18 Apr 2012 17:18:08 -0400
changeset 91925 e4a3b7619f4dae3044d0878a6e2ab3e106310e98
parent 91924 6a6c9764a3a2050bd4c715d9983b27c453f57bb7
child 91926 5c21a9ce79c723298e16c068d54a17e1d02b8264
push id8465
push usermwu@mozilla.com
push dateWed, 18 Apr 2012 21:18:45 +0000
treeherdermozilla-inbound@e4a3b7619f4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal, b2g-only
bugs746728
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 746728 - Add sensor index fallback for qemu, r=gal a=b2g-only
hal/gonk/GonkSensor.cpp
--- a/hal/gonk/GonkSensor.cpp
+++ b/hal/gonk/GonkSensor.cpp
@@ -89,16 +89,24 @@ SensorseventStatus(const sensors_event_t
 }
 
 class SensorRunnable : public nsRunnable
 {
 public:
   SensorRunnable(const sensors_event_t& data)
   {
     mSensorData.sensor() = HardwareSensorToHalSensor(data.type);
+    if (mSensorData.sensor() == SENSOR_UNKNOWN) {
+      // Emulator is broken and gives us events without types set
+      const sensor_t* sensors = NULL;
+      SensorDevice& device = SensorDevice::getInstance();
+      size_t size = device.getSensorList(&sensors);
+      if (data.sensor < size)
+        mSensorData.sensor() = HardwareSensorToHalSensor(sensors[data.sensor].type);
+    }
     mSensorData.accuracy() = HardwareStatusToHalAccuracy(SensorseventStatus(data));
     mSensorData.timestamp() = data.timestamp;
     if (mSensorData.sensor() == SENSOR_GYROSCOPE) {
       // libhardware returns gyro as rad.  convert.
       mSensorValues.AppendElement(radToDeg(data.data[0]));
       mSensorValues.AppendElement(radToDeg(data.data[1]));
       mSensorValues.AppendElement(radToDeg(data.data[2]));
     } else {