release-request-49d3fda6-f7aa-4b8d-aeeb-eed9adb96e3c-for-git_oc-release-4053943 snap-temp-L63500000069017893

Change-Id: I5f2100c40b59510ff3c1995e7b2b391a68f3fde4
diff --git a/sensorhal/hubconnection.cpp b/sensorhal/hubconnection.cpp
index 8b57bbe..b57a334 100644
--- a/sensorhal/hubconnection.cpp
+++ b/sensorhal/hubconnection.cpp
@@ -15,6 +15,7 @@
  */
 
 #define LOG_TAG "nanohub"
+#define LOG_NDEBUG 1
 
 #include "hubconnection.h"
 
@@ -244,7 +245,7 @@
 
     // set initial lid state
     if (property_set(LID_STATE_PROPERTY, LID_STATE_UNKNOWN) < 0) {
-        ALOGE("could not set lid_state property");
+        ALOGW("could not set lid_state property");
     }
 
     // enable hall sensor for folio
@@ -271,7 +272,7 @@
     run("HubConnection", PRIORITY_URGENT_DISPLAY);
 #ifdef USE_SENSORSERVICE_TO_GET_FIFO
     if (property_get_bool(SCHED_FIFO_PRIOIRTY, true)) {
-        ALOGI("Try activate sched-fifo priority for HubConnection thread");
+        ALOGV("Try activate sched-fifo priority for HubConnection thread");
         mEnableSchedFifoThread = std::thread(enableSchedFifoMode, this);
     }
 #else
@@ -290,18 +291,18 @@
     sp<ISchedulingPolicyService> scheduler = ISchedulingPolicyService::getService();
 
     if (scheduler == nullptr) {
-        ALOGE("Couldn't get scheduler scheduler to set SCHED_FIFO.");
+        ALOGW("Couldn't get scheduler scheduler to set SCHED_FIFO.");
     } else {
         Return<int32_t> max = scheduler->getMaxAllowedPriority();
         if (!max.isOk()) {
-            ALOGE("Failed to retrieve maximum allowed priority for HubConnection.");
+            ALOGW("Failed to retrieve maximum allowed priority for HubConnection.");
             return;
         }
         Return<bool> ret = scheduler->requestPriority(::getpid(), hub->getTid(), max);
         if (!ret.isOk() || !ret) {
-            ALOGE("Failed to set SCHED_FIFO for HubConnection.");
+            ALOGW("Failed to set SCHED_FIFO for HubConnection.");
         } else {
-            ALOGI("Enabled sched fifo thread mode (prio %d)", static_cast<int32_t>(max));
+            ALOGV("Enabled sched fifo thread mode (prio %d)", static_cast<int32_t>(max));
         }
     }
 #else
@@ -309,7 +310,7 @@
     struct sched_param param = {0};
     param.sched_priority = HUBCONNECTION_SCHED_FIFO_PRIORITY;
     if (sched_setscheduler(hub->getTid(), SCHED_FIFO | SCHED_RESET_ON_FORK, &param) != 0) {
-        ALOGE("Couldn't set SCHED_FIFO for HubConnection thread");
+        ALOGW("Couldn't set SCHED_FIFO for HubConnection thread");
     }
 #endif
 }
@@ -421,7 +422,7 @@
 
     status_t err;
     if ((err = settings_file.initCheck()) != OK) {
-        ALOGE("settings file open failed: %d (%s)",
+        ALOGW("settings file open failed: %d (%s)",
               err,
               strerror(-err));
 
@@ -431,7 +432,7 @@
     }
 
     if ((err = saved_settings_file.initCheck()) != OK) {
-        ALOGE("saved settings file open failed: %d (%s)",
+        ALOGW("saved settings file open failed: %d (%s)",
               err,
               strerror(-err));
         *saved_settings = new JSONObject;
@@ -446,7 +447,7 @@
 
     status_t err;
     if ((err = saved_settings_file.initCheck()) != OK) {
-        ALOGE("saved settings file open failed %d (%s)",
+        ALOGW("saved settings file open failed %d (%s)",
               err,
               strerror(-err));
         return;
@@ -491,7 +492,7 @@
     AString serializedSettings = settingsObject->toString();
     size_t size = serializedSettings.size();
     if ((err = saved_settings_file.write(serializedSettings.c_str(), size)) != (ssize_t)size) {
-        ALOGE("saved settings file write failed %d (%s)",
+        ALOGW("saved settings file write failed %d (%s)",
               err,
               strerror(-err));
     }
@@ -871,7 +872,7 @@
     if (mInotifyPollIndex >= 0) {
         char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
         int ret = ::read(mPollFds[mInotifyPollIndex].fd, buf, sizeof(buf));
-        ALOGD("Discarded %d bytes of inotify data", ret);
+        ALOGV("Discarded %d bytes of inotify data", ret);
     }
 }
 
@@ -903,13 +904,13 @@
 
             initConfigCmd(&cmd, i);
 
-            ALOGI("restoring: sensor=%d, handle=%d, enable=%d, period=%" PRId64 ", latency=%" PRId64,
+            ALOGV("restoring: sensor=%d, handle=%d, enable=%d, period=%" PRId64 ", latency=%" PRId64,
                   cmd.sensorType, i, mSensorState[i].enable, frequency_q10_to_period_ns(mSensorState[i].rate),
                   mSensorState[i].latency);
 
             int ret = TEMP_FAILURE_RETRY(::write(mFd, &cmd, sizeof(cmd)));
             if (ret != sizeof(cmd)) {
-                ALOGE("failed to send config command to restore sensor %d\n", cmd.sensorType);
+                ALOGW("failed to send config command to restore sensor %d\n", cmd.sensorType);
             }
 
             cmd.cmd = CONFIG_CMD_FLUSH;
@@ -917,7 +918,7 @@
             for (int j = 0; j < mSensorState[i].flushCnt; j++) {
                 int ret = TEMP_FAILURE_RETRY(::write(mFd, &cmd, sizeof(cmd)));
                 if (ret != sizeof(cmd)) {
-                    ALOGE("failed to send flush command to sensor %d\n", cmd.sensorType);
+                    ALOGW("failed to send flush command to sensor %d\n", cmd.sensorType);
                 }
             }
         }
@@ -945,10 +946,12 @@
         ALOGW("osLog: %s", &buf[5]);
         break;
     case 'I':
-        ALOGI("osLog: %s", &buf[5]);
+        // The other side of this is too chatty, reducing the priority to VERBOSE
+        ALOGV("osLog: %s", &buf[5]);
         break;
     case 'D':
-        ALOGD("osLog: %s", &buf[5]);
+        // The other side of this is too chatty, reducing the priority to VERBOSE
+        ALOGV("osLog: %s", &buf[5]);
         break;
     default:
         break;
@@ -962,21 +965,21 @@
     AppToSensorHalDataPayload *data =
             &(reinterpret_cast<AppToSensorHalDataBuffer *>(buf)->payload);
     if (data->size + sizeof(AppToSensorHalDataBuffer) != len) {
-        ALOGE("Received corrupted data update packet, len %zd, size %u", len, data->size);
+        ALOGW("Received corrupted data update packet, len %zd, size %u", len, data->size);
         return;
     }
 
     switch (data->type & APP_TO_SENSOR_HAL_TYPE_MASK) {
     case HALINTF_TYPE_GYRO_OTC_DATA:
         if (data->size != sizeof(GyroOtcData)) {
-            ALOGE("Corrupted HALINTF_TYPE_GYRO_OTC_DATA with size %u", data->size);
+            ALOGW("Corrupted HALINTF_TYPE_GYRO_OTC_DATA with size %u", data->size);
             return;
         }
         mGyroOtcData = data->gyroOtcData[0];
         saveSensorSettings();
         break;
     default:
-        ALOGE("Unknown app to hal data type 0x%04x", data->type);
+        ALOGW("Unknown app to hal data type 0x%04x", data->type);
         break;
     }
 }
@@ -1219,11 +1222,11 @@
             restoreSensorState();
             return 0;
         default:
-            ALOGE("unknown evtType: 0x%08x len: %zu\n", data->evtType, len);
+            ALOGW("unknown evtType: 0x%08x len: %zu\n", data->evtType, len);
             return -1;
         }
     } else {
-        ALOGE("too little data: len=%zu\n", len);
+        ALOGW("too little data: len=%zu\n", len);
         return -1;
     }
 
@@ -1239,7 +1242,7 @@
 
             if (one) {
                 if (ret + sizeof(data->oneSamples[i]) > len) {
-                    ALOGE("sensor %d (one): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
+                    ALOGW("sensor %d (one): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
                     return -1;
                 }
                 if (i > 0)
@@ -1248,7 +1251,7 @@
                 ret += sizeof(data->oneSamples[i]);
             } else if (rawThree) {
                 if (ret + sizeof(data->rawThreeSamples[i]) > len) {
-                    ALOGE("sensor %d (rawThree): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
+                    ALOGW("sensor %d (rawThree): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
                     return -1;
                 }
                 if (i > 0)
@@ -1257,7 +1260,7 @@
                 ret += sizeof(data->rawThreeSamples[i]);
             } else if (three) {
                 if (ret + sizeof(data->threeSamples[i]) > len) {
-                    ALOGE("sensor %d (three): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
+                    ALOGW("sensor %d (three): ret=%zd, numSamples=%d, i=%d\n", currSensor, ret, numSamples, i);
                     return -1;
                 }
                 if (i > 0)
@@ -1265,7 +1268,7 @@
                 processSample(timestamp, type, currSensor, &data->threeSamples[i], data->firstSample.highAccuracy);
                 ret += sizeof(data->threeSamples[i]);
             } else {
-                ALOGE("sensor %d (unknown): cannot processSample\n", currSensor);
+                ALOGW("sensor %d (unknown): cannot processSample\n", currSensor);
                 return -1;
             }
         }
@@ -1292,11 +1295,11 @@
                 }
 
                 write(&ev, 1);
-                ALOGI("flushing %d", ev.meta_data.sensor);
+                ALOGV("flushing %d", ev.meta_data.sensor);
             }
         }
     } else {
-        ALOGE("too little data for sensor %d: len=%zu\n", sensor, len);
+        ALOGW("too little data for sensor %d: len=%zu\n", sensor, len);
         return -1;
     }
 
@@ -1329,7 +1332,7 @@
         queueDataInternal(COMMS_SENSOR_ACCEL, &accel, sizeof(accel));
     }
 
-    ALOGI("Use new configuration format");
+    ALOGV("Use new configuration format");
     std::vector<int32_t> hardwareGyroBias = getInt32Setting(settings, GYRO_BIAS_TAG);
     std::vector<float> softwareGyroBias = getFloatSetting(saved_settings, GYRO_SW_BIAS_TAG);
     if (hardwareGyroBias.size() == 3 || softwareGyroBias.size() == 3) {
@@ -1375,7 +1378,7 @@
         // send it to hub
         queueDataInternal(COMMS_SENSOR_GYRO, &packet, sizeof(packet));
     } else {
-        ALOGE("Illegal otc_gyro data size = %zu", gyroOtcData.size());
+        ALOGW("Illegal otc_gyro data size = %zu", gyroOtcData.size());
     }
 
     std::vector<float> magBiasData = getFloatSetting(saved_settings, MAG_BIAS_TAG);
@@ -1412,10 +1415,10 @@
 }
 
 bool HubConnection::threadLoop() {
-    ALOGI("threadLoop: starting");
+    ALOGV("threadLoop: starting");
 
     if (mFd < 0) {
-        ALOGE("threadLoop: exiting prematurely: nanohub is unavailable");
+        ALOGW("threadLoop: exiting prematurely: nanohub is unavailable");
         return false;
     }
     waitOnNanohubLock();
@@ -1472,7 +1475,7 @@
                         break;
                 }
             } else {
-                ALOGE("read -1: errno=%d\n", errno);
+                ALOGW("read -1: errno=%d\n", errno);
             }
         }
     }
@@ -1537,13 +1540,13 @@
 
         ret = TEMP_FAILURE_RETRY(::write(mFd, &cmd, sizeof(cmd)));
         if (ret == sizeof(cmd))
-            ALOGI("queueActivate: sensor=%d, handle=%d, enable=%d",
+            ALOGV("queueActivate: sensor=%d, handle=%d, enable=%d",
                     cmd.sensorType, handle, enable);
         else
-            ALOGE("queueActivate: failed to send command: sensor=%d, handle=%d, enable=%d",
+            ALOGW("queueActivate: failed to send command: sensor=%d, handle=%d, enable=%d",
                     cmd.sensorType, handle, enable);
     } else {
-        ALOGI("queueActivate: unhandled handle=%d, enable=%d", handle, enable);
+        ALOGV("queueActivate: unhandled handle=%d, enable=%d", handle, enable);
     }
 }
 
@@ -1565,13 +1568,13 @@
 
         ret = TEMP_FAILURE_RETRY(::write(mFd, &cmd, sizeof(cmd)));
         if (ret == sizeof(cmd))
-            ALOGI("queueSetDelay: sensor=%d, handle=%d, period=%" PRId64,
+            ALOGV("queueSetDelay: sensor=%d, handle=%d, period=%" PRId64,
                     cmd.sensorType, handle, sampling_period_ns);
         else
-            ALOGE("queueSetDelay: failed to send command: sensor=%d, handle=%d, period=%" PRId64,
+            ALOGW("queueSetDelay: failed to send command: sensor=%d, handle=%d, period=%" PRId64,
                     cmd.sensorType, handle, sampling_period_ns);
     } else {
-        ALOGI("queueSetDelay: unhandled handle=%d, period=%" PRId64, handle, sampling_period_ns);
+        ALOGV("queueSetDelay: unhandled handle=%d, period=%" PRId64, handle, sampling_period_ns);
     }
 }
 
@@ -1597,13 +1600,13 @@
 
         ret = TEMP_FAILURE_RETRY(::write(mFd, &cmd, sizeof(cmd)));
         if (ret == sizeof(cmd))
-            ALOGI("queueBatch: sensor=%d, handle=%d, period=%" PRId64 ", latency=%" PRId64,
+            ALOGV("queueBatch: sensor=%d, handle=%d, period=%" PRId64 ", latency=%" PRId64,
                     cmd.sensorType, handle, sampling_period_ns, max_report_latency_ns);
         else
-            ALOGE("queueBatch: failed to send command: sensor=%d, handle=%d, period=%" PRId64 ", latency=%" PRId64,
+            ALOGW("queueBatch: failed to send command: sensor=%d, handle=%d, period=%" PRId64 ", latency=%" PRId64,
                     cmd.sensorType, handle, sampling_period_ns, max_report_latency_ns);
     } else {
-        ALOGI("queueBatch: unhandled handle=%d, period=%" PRId64 ", latency=%" PRId64,
+        ALOGV("queueBatch: unhandled handle=%d, period=%" PRId64 ", latency=%" PRId64,
                 handle, sampling_period_ns, max_report_latency_ns);
     }
 }
@@ -1623,14 +1626,14 @@
 
         ret = TEMP_FAILURE_RETRY(::write(mFd, &cmd, sizeof(cmd)));
         if (ret == sizeof(cmd)) {
-            ALOGI("queueFlush: sensor=%d, handle=%d",
+            ALOGV("queueFlush: sensor=%d, handle=%d",
                     cmd.sensorType, handle);
         } else {
-            ALOGE("queueFlush: failed to send command: sensor=%d, handle=%d"
+            ALOGW("queueFlush: failed to send command: sensor=%d, handle=%d"
                   " with error %s", cmd.sensorType, handle, strerror(errno));
         }
     } else {
-        ALOGI("queueFlush: unhandled handle=%d", handle);
+        ALOGV("queueFlush: unhandled handle=%d", handle);
     }
 }
 
@@ -1646,13 +1649,13 @@
 
         ret = TEMP_FAILURE_RETRY(::write(mFd, cmd, sizeof(*cmd) + length));
         if (ret == sizeof(*cmd) + length)
-            ALOGI("queueData: sensor=%d, length=%zu",
+            ALOGV("queueData: sensor=%d, length=%zu",
                     cmd->sensorType, length);
         else
-            ALOGE("queueData: failed to send command: sensor=%d, length=%zu",
+            ALOGW("queueData: failed to send command: sensor=%d, length=%zu",
                     cmd->sensorType, length);
     } else {
-        ALOGI("queueData: unhandled handle=%d", handle);
+        ALOGV("queueData: unhandled handle=%d", handle);
     }
     free(cmd);
 }
@@ -1694,16 +1697,16 @@
 void HubConnection::initNanohubLock() {
     // Create the lock directory (if it doesn't already exist)
     if (mkdir(NANOHUB_LOCK_DIR, NANOHUB_LOCK_DIR_PERMS) < 0 && errno != EEXIST) {
-        ALOGE("Couldn't create Nanohub lock directory: %s", strerror(errno));
+        ALOGW("Couldn't create Nanohub lock directory: %s", strerror(errno));
         return;
     }
 
     mInotifyPollIndex = -1;
     int inotifyFd = inotify_init1(IN_NONBLOCK);
     if (inotifyFd < 0) {
-        ALOGE("Couldn't initialize inotify: %s", strerror(errno));
+        ALOGW("Couldn't initialize inotify: %s", strerror(errno));
     } else if (inotify_add_watch(inotifyFd, NANOHUB_LOCK_DIR, IN_CREATE | IN_DELETE) < 0) {
-        ALOGE("Couldn't add inotify watch: %s", strerror(errno));
+        ALOGW("Couldn't add inotify watch: %s", strerror(errno));
         close(inotifyFd);
     } else {
         mPollFds[mNumPollFds].fd = inotifyFd;
@@ -1732,9 +1735,9 @@
 
         ret = TEMP_FAILURE_RETRY(::write(mFd, cmd, sizeof(*cmd) + sizeof(float)));
         if (ret == sizeof(*cmd) + sizeof(float))
-            ALOGI("queueUsbMagBias: bias=%f\n", mUsbMagBias);
+            ALOGV("queueUsbMagBias: bias=%f\n", mUsbMagBias);
         else
-            ALOGE("queueUsbMagBias: failed to send command: bias=%f\n", mUsbMagBias);
+            ALOGW("queueUsbMagBias: failed to send command: bias=%f\n", mUsbMagBias);
         free(cmd);
     }
 }
@@ -1748,7 +1751,7 @@
     // Open uinput dev node
     mUinputFd = TEMP_FAILURE_RETRY(open("/dev/uinput", O_WRONLY | O_NONBLOCK));
     if (mUinputFd < 0) {
-        ALOGE("could not open uinput node: %s", strerror(errno));
+        ALOGW("could not open uinput node: %s", strerror(errno));
         return UNKNOWN_ERROR;
     }
 
@@ -1757,7 +1760,7 @@
     ret |= TEMP_FAILURE_RETRY(ioctl(mUinputFd, UI_SET_EVBIT, EV_SYN));
     ret |= TEMP_FAILURE_RETRY(ioctl(mUinputFd, UI_SET_SWBIT, SW_LID));
     if (ret < 0) {
-        ALOGE("could not send ioctl to uinput node: %s", strerror(errno));
+        ALOGW("could not send ioctl to uinput node: %s", strerror(errno));
         return UNKNOWN_ERROR;
     }
 
@@ -1772,13 +1775,13 @@
 
     ret = TEMP_FAILURE_RETRY(::write(mUinputFd, &uidev, sizeof(uidev)));
     if (ret < 0) {
-        ALOGE("write to uinput node failed: %s", strerror(errno));
+        ALOGW("write to uinput node failed: %s", strerror(errno));
         return UNKNOWN_ERROR;
     }
 
     ret = TEMP_FAILURE_RETRY(ioctl(mUinputFd, UI_DEV_CREATE));
     if (ret < 0) {
-        ALOGE("could not send ioctl to uinput node: %s", strerror(errno));
+        ALOGW("could not send ioctl to uinput node: %s", strerror(errno));
         return UNKNOWN_ERROR;
     }
 
@@ -1796,7 +1799,7 @@
     ev.value =  data;
     ret = TEMP_FAILURE_RETRY(::write(mUinputFd, &ev, sizeof(ev)));
     if (ret < 0) {
-        ALOGE("write to uinput node failed: %s", strerror(errno));
+        ALOGW("write to uinput node failed: %s", strerror(errno));
         return;
     }
 
@@ -1806,14 +1809,14 @@
     ev.value =  0;
     ret = TEMP_FAILURE_RETRY(::write(mUinputFd, &ev, sizeof(ev)));
     if (ret < 0) {
-        ALOGE("write to uinput node failed: %s", strerror(errno));
+        ALOGW("write to uinput node failed: %s", strerror(errno));
         return;
     }
 
     // Set lid state property
     if (property_set(LID_STATE_PROPERTY,
                      (data ? LID_STATE_CLOSED : LID_STATE_OPEN)) < 0) {
-        ALOGE("could not set lid_state property");
+        ALOGW("could not set lid_state property");
     }
 }
 #endif  // LID_STATE_REPORTING_ENABLED
@@ -1896,7 +1899,7 @@
             mDirectChannel.insert(std::make_pair(ret, std::move(ch)));
         } else {
             ret = ch->getError();
-            ALOGE("Direct channel object(type:%d) has error %d upon init", mem->type, ret);
+            ALOGW("Direct channel object(type:%d) has error %d upon init", mem->type, ret);
         }
     }
 
@@ -1914,7 +1917,7 @@
         std::stringstream ss;
         std::copy(activeSensorList.begin(), activeSensorList.end(),
                 std::ostream_iterator<int32_t>(ss, ","));
-        ALOGE("Removing channel %d when sensors (%s) are not stopped.",
+        ALOGW("Removing channel %d when sensors (%s) are not stopped.",
                 channel_handle, ss.str().c_str());
     }
 
diff --git a/sensorhal/sensors.cpp b/sensorhal/sensors.cpp
index 50610b5..65b881c 100644
--- a/sensorhal/sensors.cpp
+++ b/sensorhal/sensors.cpp
@@ -15,7 +15,7 @@
  */
 
 #define LOG_TAG "sensors"
-// #defined LOG_NDEBUG  1
+#define LOG_NDEBUG  1
 #include <utils/Log.h>
 
 #include "hubconnection.h"
@@ -66,7 +66,7 @@
 }
 
 int SensorContext::close() {
-    ALOGI("close");
+    ALOGV("close");
 
     delete this;
 
@@ -74,7 +74,7 @@
 }
 
 int SensorContext::activate(int handle, int enabled) {
-    ALOGI("activate");
+    ALOGV("activate");
 
     for (auto &h : mOperationHandler) {
         if (h->owns(handle)) {
@@ -85,7 +85,7 @@
 }
 
 int SensorContext::setDelay(int handle, int64_t delayNs) {
-    ALOGI("setDelay");
+    ALOGV("setDelay");
 
     for (auto &h: mOperationHandler) {
         if (h->owns(handle)) {
@@ -129,7 +129,7 @@
         int handle,
         int64_t sampling_period_ns,
         int64_t max_report_latency_ns) {
-    ALOGI("batch");
+    ALOGV("batch");
 
     for (auto &h : mOperationHandler) {
         if (h->owns(handle)) {
@@ -140,7 +140,7 @@
 }
 
 int SensorContext::flush(int handle) {
-    ALOGI("flush");
+    ALOGV("flush");
 
     for (auto &h : mOperationHandler) {
         if (h->owns(handle)) {
@@ -400,7 +400,7 @@
         const struct hw_module_t *module,
         const char *,
         struct hw_device_t **dev) {
-    ALOGI("open_sensors");
+    ALOGV("open_sensors");
 
     SensorContext *ctx = new SensorContext(module);
     n_sensor = ctx->getSensorList(&sensor_list);
@@ -417,7 +417,7 @@
 static int get_sensors_list(
         struct sensors_module_t *,
         struct sensor_t const **list) {
-    ALOGI("get_sensors_list");
+    ALOGV("get_sensors_list");
     if (gHubAlive && sensor_list != nullptr) {
         *list = sensor_list;
         return n_sensor;
@@ -428,7 +428,7 @@
 }
 
 static int set_operation_mode(unsigned int mode) {
-    ALOGI("set_operation_mode");
+    ALOGV("set_operation_mode");
 
     // This is no-op because there is no sensor in the hal that system can
     // inject events. Only operation parameter injection is implemented, which