Merge remote-tracking branch 'goog/ics-aah'
diff --git a/libsensors/MPLSensor.cpp b/libsensors/MPLSensor.cpp
index 314acfb..a36a565 100644
--- a/libsensors/MPLSensor.cpp
+++ b/libsensors/MPLSensor.cpp
@@ -59,9 +59,9 @@
 #include "sensor_params.h"
 
 #define EXTRA_VERBOSE (0)
-//#define FUNC_LOG LOGV("%s", __PRETTY_FUNCTION__)
+//#define FUNC_LOG ALOGV("%s", __PRETTY_FUNCTION__)
 #define FUNC_LOG
-#define VFUNC_LOG LOGV_IF(EXTRA_VERBOSE, "%s", __PRETTY_FUNCTION__)
+#define VFUNC_LOG ALOGV_IF(EXTRA_VERBOSE, "%s", __PRETTY_FUNCTION__)
 /* this mask must turn on only the sensors that are present and managed by the MPL */
 #define ALL_MPL_SENSORS_NP (INV_THREE_AXIS_ACCEL | INV_THREE_AXIS_COMPASS | INV_THREE_AXIS_GYRO)
 
@@ -156,7 +156,7 @@
     int mpu_int_fd, i;
     char *port = NULL;
 
-    LOGV_IF(EXTRA_VERBOSE, "MPLSensor constructor: numSensors = %d", numSensors);
+    ALOGV_IF(EXTRA_VERBOSE, "MPLSensor constructor: numSensors = %d", numSensors);
 
     pthread_mutex_init(&mMplMutex, NULL);
 
@@ -176,7 +176,7 @@
 
     mpu_int_fd = open("/dev/mpuirq", O_RDWR);
     if (mpu_int_fd == -1) {
-        LOGE("could not open the mpu irq device node");
+        ALOGE("could not open the mpu irq device node");
     } else {
         fcntl(mpu_int_fd, F_SETFL, O_NONBLOCK);
         //ioctl(mpu_int_fd, MPUIRQ_SET_TIMEOUT, 0);
@@ -187,7 +187,7 @@
 
     accel_fd = open("/dev/accelirq", O_RDWR);
     if (accel_fd == -1) {
-        LOGE("could not open the accel irq device node");
+        ALOGE("could not open the accel irq device node");
     } else {
         fcntl(accel_fd, F_SETFL, O_NONBLOCK);
         //ioctl(accel_fd, SLAVEIRQ_SET_TIMEOUT, 0);
@@ -198,7 +198,7 @@
 
     timer_fd = open("/dev/timerirq", O_RDWR);
     if (timer_fd == -1) {
-        LOGE("could not open the timer irq device node");
+        ALOGE("could not open the timer irq device node");
     } else {
         fcntl(timer_fd, F_SETFL, O_NONBLOCK);
         //ioctl(timer_fd, TIMERIRQ_SET_TIMEOUT, 0);
@@ -212,7 +212,7 @@
     if ((accel_fd == -1) && (timer_fd != -1)) {
         //no accel irq and timer available
         mUseTimerIrqAccel = true;
-        //LOGD("MPLSensor falling back to timerirq for accel data");
+        //ALOGD("MPLSensor falling back to timerirq for accel data");
     }
 
     memset(mPendingEvents, 0, sizeof(mPendingEvents));
@@ -268,7 +268,7 @@
         mDelays[i] = 30000000LLU; // 30 ms by default
 
     if (inv_serial_start(port) != INV_SUCCESS) {
-        LOGE("Fatal Error : could not open MPL serial interface");
+        ALOGE("Fatal Error : could not open MPL serial interface");
     }
 
     //initialize library parameters
@@ -279,7 +279,7 @@
 
     //we start the motion processing only when a sensor is enabled...
     //rv = inv_dmp_start();
-    //LOGE_IF(rv != INV_SUCCESS, "Fatal error: could not start the DMP correctly. (code = %d)\n", rv);
+    //ALOGE_IF(rv != INV_SUCCESS, "Fatal error: could not start the DMP correctly. (code = %d)\n", rv);
     //dmp_started = true;
 
     pthread_mutex_unlock(&mMplMutex);
@@ -291,15 +291,15 @@
     FUNC_LOG;
     pthread_mutex_lock(&mMplMutex);
     if (inv_dmp_stop() != INV_SUCCESS) {
-        LOGW("Error: could not stop the DMP correctly.\n");
+        ALOGW("Error: could not stop the DMP correctly.\n");
     }
 
     if (inv_dmp_close() != INV_SUCCESS) {
-        LOGW("Error: could not close the DMP");
+        ALOGW("Error: could not close the DMP");
     }
 
     if (inv_serial_stop() != INV_SUCCESS) {
-        LOGW("Error : could not close the serial port");
+        ALOGW("Error : could not close the serial port");
     }
     pthread_mutex_unlock(&mMplMutex);
     pthread_mutex_destroy(&mMplMutex);
@@ -322,7 +322,7 @@
             if (nread > 0) {
                 irq_set[i] = true;
                 irq_timestamp = irqdata.irqtime;
-                //LOGV_IF(EXTRA_VERBOSE, "irq: %d %d (%d)", i, irqdata.interruptcount, j++);
+                //ALOGV_IF(EXTRA_VERBOSE, "irq: %d %d (%d)", i, irqdata.interruptcount, j++);
             }
         }
         mPollFds[i].revents = 0;
@@ -337,7 +337,7 @@
     FUNC_LOG;
     bool irq_set[5] = { false, false, false, false, false };
 
-    //LOGV(" setPowerStates: %d dmp_started: %d", enabled_sensors, mDmpStarted);
+    //ALOGV(" setPowerStates: %d dmp_started: %d", enabled_sensors, mDmpStarted);
 
     do {
 
@@ -382,7 +382,7 @@
 
     if (changing_sensors || restart) {
 
-        LOGV_IF(EXTRA_VERBOSE, "cs:%d rs:%d ", changing_sensors, restart);
+        ALOGV_IF(EXTRA_VERBOSE, "cs:%d rs:%d ", changing_sensors, restart);
 
         if (mDmpStarted) {
             inv_dmp_stop();
@@ -391,9 +391,9 @@
         }
 
         if (sen_mask != inv_get_dl_config()->requested_sensors) {
-            //LOGV("setPowerStates: %lx", sen_mask);
+            //ALOGV("setPowerStates: %lx", sen_mask);
             rv = inv_set_mpu_sensors(sen_mask);
-            LOGE_IF(rv != INV_SUCCESS,
+            ALOGE_IF(rv != INV_SUCCESS,
                     "error: unable to set MPL sensor power states (sens=%ld retcode = %d)",
                     sen_mask, rv);
         }
@@ -401,37 +401,37 @@
         if (((mUsetimerIrqCompass && (sen_mask == INV_THREE_AXIS_COMPASS))
                 || (mUseTimerIrqAccel && (sen_mask & INV_THREE_AXIS_ACCEL)))
                 && ((sen_mask & INV_DMP_PROCESSOR) == 0)) {
-            LOGV_IF(EXTRA_VERBOSE, "Allowing TimerIRQ");
+            ALOGV_IF(EXTRA_VERBOSE, "Allowing TimerIRQ");
             mUseTimerirq = true;
         } else {
             if (mUseTimerirq) {
                 ioctl(mIrqFds.valueFor(TIMERIRQ_FD), TIMERIRQ_STOP, 0);
                 clearIrqData(irq_set);
             }
-            LOGV_IF(EXTRA_VERBOSE, "Not allowing TimerIRQ");
+            ALOGV_IF(EXTRA_VERBOSE, "Not allowing TimerIRQ");
             mUseTimerirq = false;
         }
 
         if (!mDmpStarted) {
             if (mHaveGoodMpuCal || mHaveGoodCompassCal) {
                 rv = inv_store_calibration();
-                LOGE_IF(rv != INV_SUCCESS,
+                ALOGE_IF(rv != INV_SUCCESS,
                         "error: unable to store MPL calibration file");
                 mHaveGoodMpuCal = false;
                 mHaveGoodCompassCal = false;
             }
-            //LOGV("Starting DMP");
+            //ALOGV("Starting DMP");
             rv = inv_dmp_start();
-            LOGE_IF(rv != INV_SUCCESS, "unable to start dmp");
+            ALOGE_IF(rv != INV_SUCCESS, "unable to start dmp");
             mDmpStarted = true;
         }
     }
 
     //check if we should stop the DMP
     if (mDmpStarted && (sen_mask == 0)) {
-        //LOGV("Stopping DMP");
+        //ALOGV("Stopping DMP");
         rv = inv_dmp_stop();
-        LOGE_IF(rv != INV_SUCCESS, "error: unable to stop DMP (retcode = %d)",
+        ALOGE_IF(rv != INV_SUCCESS, "error: unable to stop DMP (retcode = %d)",
                 rv);
         if (mUseTimerirq) {
             ioctl(mIrqFds.valueFor(TIMERIRQ_FD), TIMERIRQ_STOP, 0);
@@ -456,15 +456,15 @@
     struct mldl_cfg *mldl_cfg;
 
     if (inv_dmp_open() != INV_SUCCESS) {
-        LOGE("Fatal Error : could not open DMP correctly.\n");
+        ALOGE("Fatal Error : could not open DMP correctly.\n");
     }
 
     result = inv_set_mpu_sensors(ALL_MPL_SENSORS_NP); //default to all sensors, also makes 9axis enable work
-    LOGE_IF(result != INV_SUCCESS,
+    ALOGE_IF(result != INV_SUCCESS,
             "Fatal Error : could not set enabled sensors.");
 
     if (inv_load_calibration() != INV_SUCCESS) {
-        LOGE("could not open MPL calibration file");
+        ALOGE("could not open MPL calibration file");
     }
 
     //check for the 9axis fusion library: if available load it and start 9x
@@ -475,9 +475,9 @@
         inv_error_t (*fp_inv_enable_9x_fusion)() =
               (inv_error_t(*)()) dlsym(h_dmp_lib, "inv_enable_9x_fusion");
         if((error = dlerror()) != NULL) {
-            LOGE("%s %s", error, "inv_enable_9x_fusion");
+            ALOGE("%s %s", error, "inv_enable_9x_fusion");
         } else if ((*fp_inv_enable_9x_fusion)() != INV_SUCCESS) {
-            LOGE( "Warning : 9 axis sensor fusion not available "
+            ALOGE( "Warning : 9 axis sensor fusion not available "
                   "- No compass detected.\n");
         } else {
             /*  9axis is loaded and enabled                            */
@@ -486,26 +486,26 @@
         }
     } else {
         const char* error = dlerror();
-        LOGE("libinvensense_mpl.so not found, 9x sensor fusion disabled (%s)",error);
+        ALOGE("libinvensense_mpl.so not found, 9x sensor fusion disabled (%s)",error);
     }
 
     mldl_cfg = inv_get_dl_config();
 
     if (inv_set_bias_update(bias_update_mask) != INV_SUCCESS) {
-        LOGE("Error : Bias update function could not be set.\n");
+        ALOGE("Error : Bias update function could not be set.\n");
     }
 
     if (inv_set_motion_interrupt(1) != INV_SUCCESS) {
-        LOGE("Error : could not set motion interrupt");
+        ALOGE("Error : could not set motion interrupt");
     }
 
     if (inv_set_fifo_interrupt(1) != INV_SUCCESS) {
-        LOGE("Error : could not set fifo interrupt");
+        ALOGE("Error : could not set fifo interrupt");
     }
 
     result = inv_set_fifo_rate(6);
     if (result != INV_SUCCESS) {
-        LOGE("Fatal error: inv_set_fifo_rate returned %d\n", result);
+        ALOGE("Fatal error: inv_set_fifo_rate returned %d\n", result);
     }
 
     mMpuAccuracy = SENSOR_STATUS_ACCURACY_MEDIUM;
@@ -522,33 +522,33 @@
 
     result = inv_send_accel(INV_ALL, INV_32_BIT);
     if (result != INV_SUCCESS) {
-        LOGE("Fatal error: inv_send_accel returned %d\n", result);
+        ALOGE("Fatal error: inv_send_accel returned %d\n", result);
     }
 
     result = inv_send_quaternion(INV_32_BIT);
     if (result != INV_SUCCESS) {
-        LOGE("Fatal error: inv_send_quaternion returned %d\n", result);
+        ALOGE("Fatal error: inv_send_quaternion returned %d\n", result);
     }
 
     result = inv_send_linear_accel(INV_ALL, INV_32_BIT);
     if (result != INV_SUCCESS) {
-        LOGE("Fatal error: inv_send_linear_accel returned %d\n", result);
+        ALOGE("Fatal error: inv_send_linear_accel returned %d\n", result);
     }
 
     result = inv_send_linear_accel_in_world(INV_ALL, INV_32_BIT);
     if (result != INV_SUCCESS) {
-        LOGE("Fatal error: inv_send_linear_accel_in_world returned %d\n",
+        ALOGE("Fatal error: inv_send_linear_accel_in_world returned %d\n",
              result);
     }
 
     result = inv_send_gravity(INV_ALL, INV_32_BIT);
     if (result != INV_SUCCESS) {
-        LOGE("Fatal error: inv_send_gravity returned %d\n", result);
+        ALOGE("Fatal error: inv_send_gravity returned %d\n", result);
     }
 
     result = inv_send_gyro(INV_ALL, INV_32_BIT);
     if (result != INV_SUCCESS) {
-        LOGE("Fatal error: inv_send_gyro returned %d\n", result);
+        ALOGE("Fatal error: inv_send_gyro returned %d\n", result);
     }
 
 }
@@ -560,12 +560,12 @@
 {
     FUNC_LOG;
     if (inv_set_motion_callback(mot_cb_wrapper) != INV_SUCCESS) {
-        LOGE("Error : Motion callback could not be set.\n");
+        ALOGE("Error : Motion callback could not be set.\n");
 
     }
 
     if (inv_set_fifo_processed_callback(procData_cb_wrapper) != INV_SUCCESS) {
-        LOGE("Error : Processed data callback could not be set.");
+        ALOGE("Error : Processed data callback could not be set.");
 
     }
 }
@@ -594,7 +594,7 @@
 {
     mNewData = 1;
     mSampleCount++;
-    //LOGV_IF(EXTRA_VERBOSE, "new data (%d)", sampleCount);
+    //ALOGV_IF(EXTRA_VERBOSE, "new data (%d)", sampleCount);
 }
 
 //these handlers transform mpl data into one of the Android sensor types
@@ -624,7 +624,7 @@
     s->acceleration.v[0] = s->acceleration.v[0] * 9.81;
     s->acceleration.v[1] = s->acceleration.v[1] * 9.81;
     s->acceleration.v[2] = s->acceleration.v[2] * 9.81;
-    //LOGV_IF(EXTRA_VERBOSE, "accel data: %f %f %f", s->acceleration.v[0], s->acceleration.v[1], s->acceleration.v[2]);
+    //ALOGV_IF(EXTRA_VERBOSE, "accel data: %f %f %f", s->acceleration.v[0], s->acceleration.v[1], s->acceleration.v[2]);
     s->acceleration.status = SENSOR_STATUS_ACCURACY_HIGH;
     if (res == INV_SUCCESS)
         *pending_mask |= (1 << index);
@@ -639,7 +639,7 @@
     if(rv >= SENSOR_STATUS_ACCURACY_MEDIUM) {
          mHaveGoodCompassCal = true;	 
     }
-    LOGE_IF(res != INV_SUCCESS, "error returned from inv_get_compass_accuracy");
+    ALOGE_IF(res != INV_SUCCESS, "error returned from inv_get_compass_accuracy");
 
     return rv;
 }
@@ -656,7 +656,7 @@
     res = inv_get_float_array(INV_MAGNETOMETER, s->magnetic.v);
 
     if (res != INV_SUCCESS) {
-        LOGW(
+        ALOGW(
              "compass_handler inv_get_float_array(INV_MAGNETOMETER) returned %d",
              res);
     }
@@ -802,14 +802,14 @@
     if (res == INV_SUCCESS)
         *pending_mask |= (1 << index);
     else
-        LOGW("orienHandler: data not valid (%d)", (int) res);
+        ALOGW("orienHandler: data not valid (%d)", (int) res);
 
 }
 
 int MPLSensor::enable(int32_t handle, int en)
 {
     FUNC_LOG;
-    //LOGV("handle : %d en: %d", handle, en);
+    //ALOGV("handle : %d en: %d", handle, en);
 
     int what = -1;
 
@@ -845,7 +845,7 @@
 
     int newState = en ? 1 : 0;
     int err = 0;
-    //LOGV_IF((uint32_t(newState) << what) != (mEnabled & (1 << what)),
+    //ALOGV_IF((uint32_t(newState) << what) != (mEnabled & (1 << what)),
     //        "sensor state change what=%d", what);
 
     pthread_mutex_lock(&mMplMutex);
@@ -854,7 +854,7 @@
         short flags = newState;
         mEnabled &= ~(1 << what);
         mEnabled |= (uint32_t(flags) << what);
-        LOGV_IF(EXTRA_VERBOSE, "mEnabled = %x", mEnabled);
+        ALOGV_IF(EXTRA_VERBOSE, "mEnabled = %x", mEnabled);
         setPowerStates(mEnabled);
         pthread_mutex_unlock(&mMplMutex);
         if (!newState)
@@ -868,7 +868,7 @@
 int MPLSensor::setDelay(int32_t handle, int64_t ns)
 {
     FUNC_LOG;
-    LOGV_IF(EXTRA_VERBOSE,
+    ALOGV_IF(EXTRA_VERBOSE,
             " setDelay handle: %d rate %d", handle, (int) (ns / 1000000LL));
     int what = -1;
     switch (handle) {
@@ -938,13 +938,13 @@
             rate = 1;
 
         if (rate != mCurFifoRate) {
-            //LOGD("set fifo rate: %d %llu", rate, wanted);
+            //ALOGD("set fifo rate: %d %llu", rate, wanted);
             inv_error_t res; // = inv_dmp_stop();
             res = inv_set_fifo_rate(rate);
-            LOGE_IF(res != INV_SUCCESS, "error setting FIFO rate");
+            ALOGE_IF(res != INV_SUCCESS, "error setting FIFO rate");
 
             //res = inv_dmp_start();
-            //LOGE_IF(res != INV_SUCCESS, "error re-starting DMP");
+            //ALOGE_IF(res != INV_SUCCESS, "error re-starting DMP");
 
             mCurFifoRate = rate;
             rv = (res == INV_SUCCESS);
@@ -958,12 +958,12 @@
                         == INV_THREE_AXIS_COMPASS) {
                     ioctl(mIrqFds.valueFor(TIMERIRQ_FD), TIMERIRQ_START,
                           (unsigned long) (wanted / 1000000LLU));
-                    LOGV_IF(EXTRA_VERBOSE, "updated timerirq period to %d",
+                    ALOGV_IF(EXTRA_VERBOSE, "updated timerirq period to %d",
                             (int) (wanted / 1000000LLU));
                 } else {
                     ioctl(mIrqFds.valueFor(TIMERIRQ_FD), TIMERIRQ_START,
                           (unsigned long) inv_get_sample_step_size_ms());
-                    LOGV_IF(EXTRA_VERBOSE, "updated timerirq period to %d",
+                    ALOGV_IF(EXTRA_VERBOSE, "updated timerirq period to %d",
                             (int) inv_get_sample_step_size_ms());
                 }
             }
@@ -981,7 +981,7 @@
     struct timespec ts;
 
     clock_gettime(CLOCK_MONOTONIC, &ts);
-    //LOGV("Time %lld", (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec);
+    //ALOGV("Time %lld", (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec);
     return (int64_t) ts.tv_sec * 1000000000 + ts.tv_nsec;
 }
 
@@ -999,21 +999,21 @@
 
     pthread_mutex_lock(&mMplMutex);
     if (mDmpStarted) {
-        //LOGV_IF(EXTRA_VERBOSE, "Update Data");
+        //ALOGV_IF(EXTRA_VERBOSE, "Update Data");
         rv = inv_update_data();
-        LOGE_IF(rv != INV_SUCCESS, "inv_update_data error (code %d)", (int) rv);
+        ALOGE_IF(rv != INV_SUCCESS, "inv_update_data error (code %d)", (int) rv);
     }
 
     else {
         //probably just one extra read after shutting down
-        LOGV_IF(EXTRA_VERBOSE,
+        ALOGV_IF(EXTRA_VERBOSE,
                 "MPLSensor::readEvents called, but there's nothing to do.");
     }
 
     pthread_mutex_unlock(&mMplMutex);
 
     if (!mNewData) {
-        LOGV_IF(EXTRA_VERBOSE, "no new data");
+        ALOGV_IF(EXTRA_VERBOSE, "no new data");
         return 0;
     }
     mNewData = 0;
@@ -1046,26 +1046,26 @@
 
 int MPLSensor::getFd() const
 {
-    //LOGV("MPLSensor::getFd returning %d", data_fd);
+    //ALOGV("MPLSensor::getFd returning %d", data_fd);
     return data_fd;
 }
 
 int MPLSensor::getAccelFd() const
 {
-    //LOGV("MPLSensor::getAccelFd returning %d", accel_fd);
+    //ALOGV("MPLSensor::getAccelFd returning %d", accel_fd);
     return accel_fd;
 }
 
 int MPLSensor::getTimerFd() const
 {
-    //LOGV("MPLSensor::getTimerFd returning %d", timer_fd);
+    //ALOGV("MPLSensor::getTimerFd returning %d", timer_fd);
     return timer_fd;
 }
 
 int MPLSensor::getPowerFd() const
 {
     int hdl = (int) inv_get_serial_handle();
-    //LOGV("MPLSensor::getPowerFd returning %d", hdl);
+    //ALOGV("MPLSensor::getPowerFd returning %d", hdl);
     return hdl;
 }
 
@@ -1133,7 +1133,7 @@
     int numsensors;
 
     if(len < 7*sizeof(sensor_t)) {
-        LOGE("sensor list too small, not populating.");
+        ALOGE("sensor list too small, not populating.");
         return 0;
     }
 
@@ -1146,7 +1146,7 @@
     unsigned short accelId = inv_get_accel_id();
     if(accelId == 0)
     {
-	LOGE("Can not get accel id");
+	ALOGE("Can not get accel id");
     }   
     fillAccel(accelId, list);
 
@@ -1154,7 +1154,7 @@
     unsigned short compassId = inv_get_compass_id();
     if(compassId == 0)
     {
-	LOGE("Can not get compass id");
+	ALOGE("Can not get compass id");
     }  
     fillCompass(compassId, list);
 
@@ -1254,7 +1254,7 @@
         list[Accelerometer].power = ACCEL_MPU6050_POWER;
         break;
     default:
-        LOGE("unknown accel id -- accel params will be wrong.");
+        ALOGE("unknown accel id -- accel params will be wrong.");
         break;
     }
 }
@@ -1308,7 +1308,7 @@
         list[MagneticField].power = COMPASS_HSCDTD004A_POWER;
         break;
     default:
-        LOGE("unknown compass id -- compass parameters will be wrong");
+        ALOGE("unknown compass id -- compass parameters will be wrong");
     }
 }
 
diff --git a/libsensors/SensorBase.cpp b/libsensors/SensorBase.cpp
index d448eb2..79b1ee2 100644
--- a/libsensors/SensorBase.cpp
+++ b/libsensors/SensorBase.cpp
@@ -53,7 +53,7 @@
 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));
+        ALOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno));
     }
     return 0;
 }
@@ -123,6 +123,6 @@
         }
     }
     closedir(dir);
-    LOGE_IF(fd<0, "couldn't find '%s' input device", inputName);
+    ALOGE_IF(fd<0, "couldn't find '%s' input device", inputName);
     return fd;
 }
diff --git a/mlsdk/platform/include/log.h b/mlsdk/platform/include/log.h
index 2c36e55..8485074 100644
--- a/mlsdk/platform/include/log.h
+++ b/mlsdk/platform/include/log.h
@@ -284,7 +284,7 @@
 #ifndef MPL_LOG_PRI
 #ifdef ANDROID
 #define MPL_LOG_PRI(priority, tag, fmt, ...) \
-	LOG(priority, tag, fmt, ##__VA_ARGS__)
+        ALOG(priority, tag, fmt, ##__VA_ARGS__)
 #elif defined __KERNEL__
 #define MPL_LOG_PRI(priority, tag, fmt, ...) \
 	pr_debug(MPL_##priority tag fmt, ##__VA_ARGS__)