Sensor related changes for NDK.

   i) ASensorManager_getDefaultSensor returns a wake-up/non wake-up sensor
      depending on the type.
   ii) Add ASensor_isWakeUpSensor and ASensorManager_getDefaultSensorEx
       methods.
Bug : 16399898
Change-Id: I1a86fb8d9de23039fdf41679d1487e1cd761a9d0
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp
index b80da56..7b4fa2f 100644
--- a/libs/gui/SensorManager.cpp
+++ b/libs/gui/SensorManager.cpp
@@ -116,12 +116,23 @@
 {
     Mutex::Autolock _l(mLock);
     if (assertStateLocked() == NO_ERROR) {
+        bool wakeUpSensor = false;
+        // For the following sensor types, return a wake-up sensor. These types are by default
+        // defined as wake-up sensors. For the rest of the sensor types defined in sensors.h return
+        // a non_wake-up version.
+        if (type == SENSOR_TYPE_PROXIMITY || type == SENSOR_TYPE_SIGNIFICANT_MOTION ||
+            type == SENSOR_TYPE_TILT_DETECTOR || type == SENSOR_TYPE_WAKE_GESTURE ||
+            type == SENSOR_TYPE_GLANCE_GESTURE || type == SENSOR_TYPE_PICK_UP_GESTURE) {
+            wakeUpSensor = true;
+        }
         // For now we just return the first sensor of that type we find.
         // in the future it will make sense to let the SensorService make
         // that decision.
         for (size_t i=0 ; i<mSensors.size() ; i++) {
-            if (mSensorList[i]->getType() == type)
+            if (mSensorList[i]->getType() == type &&
+                mSensorList[i]->isWakeUpSensor() == wakeUpSensor) {
                 return mSensorList[i];
+            }
         }
     }
     return NULL;