summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-10-07 08:07:02 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-10-07 08:07:02 +0000
commit7481601e27bf6946c03378a3c1fbf56b959caea2 (patch)
tree755510f6c441b9eaa33148d5e8212b80f9bc3404
parentb4109229a4012206cdbc6d6d8241ff0b183021ac (diff)
parent668ad7e1af8d3b66db75afc5f232a4b5de80b3d2 (diff)
downloaddevice_google_contexthub-7481601e27bf6946c03378a3c1fbf56b959caea2.tar.gz
device_google_contexthub-7481601e27bf6946c03378a3c1fbf56b959caea2.tar.bz2
device_google_contexthub-7481601e27bf6946c03378a3c1fbf56b959caea2.zip
Snap for 4383207 from 668ad7e1af8d3b66db75afc5f232a4b5de80b3d2 to pi-release
Change-Id: I7004138992af3cf1220247c746d698cdc39405d7
-rw-r--r--sensorhal/Android.mk6
-rw-r--r--sensorhal/hubconnection.cpp54
-rw-r--r--sensorhal/hubconnection.h8
3 files changed, 6 insertions, 62 deletions
diff --git a/sensorhal/Android.mk b/sensorhal/Android.mk
index 6a625db1..385a7622 100644
--- a/sensorhal/Android.mk
+++ b/sensorhal/Android.mk
@@ -133,9 +133,6 @@ LOCAL_MODULE_OWNER := google
LOCAL_PROPRIETARY_MODULE := true
LOCAL_CFLAGS += $(COMMON_CFLAGS)
-ifeq ($(PRODUCT_FULL_TREBLE),true)
-LOCAL_CFLAGS += -DUSE_SENSORSERVICE_TO_GET_FIFO
-endif
ifeq ($(NANOHUB_SENSORHAL_LID_STATE_ENABLED), true)
LOCAL_CFLAGS += -DLID_STATE_REPORTING_ENABLED
@@ -164,12 +161,9 @@ LOCAL_STATIC_LIBRARIES := \
libhubutilcommon
LOCAL_SHARED_LIBRARIES := \
- android.frameworks.schedulerservice@1.0 \
libcutils \
libhardware \
libhardware_legacy \
- libhidlbase \
- libhidltransport \
liblog \
libstagefright_foundation \
libutils \
diff --git a/sensorhal/hubconnection.cpp b/sensorhal/hubconnection.cpp
index ba87c152..4231e221 100644
--- a/sensorhal/hubconnection.cpp
+++ b/sensorhal/hubconnection.cpp
@@ -18,10 +18,6 @@
#include "hubconnection.h"
-// TODO: remove the includes that introduce LIKELY and UNLIKELY (firmware/os/inc/toolchain.h)
-#undef LIKELY
-#undef UNLIKELY
-
#include "file.h"
#include "JSONObject.h"
@@ -35,13 +31,10 @@
#include <linux/input.h>
#include <linux/uinput.h>
-#include <android/frameworks/schedulerservice/1.0/ISchedulingPolicyService.h>
#include <cutils/ashmem.h>
#include <cutils/properties.h>
#include <hardware_legacy/power.h>
#include <media/stagefright/foundation/ADebug.h>
-#include <utils/Log.h>
-#include <utils/SystemClock.h>
#include <algorithm>
#include <cmath>
@@ -83,15 +76,11 @@ const char LID_STATE_OPEN[] = "open";
const char LID_STATE_CLOSED[] = "closed";
#endif // LID_STATE_REPORTING_ENABLED
+constexpr int HUBCONNECTION_SCHED_FIFO_PRIORITY = 3;
+
static const uint32_t delta_time_encoded = 1;
static const uint32_t delta_time_shift_table[2] = {9, 0};
-#ifdef USE_SENSORSERVICE_TO_GET_FIFO
-// TODO(b/35219747): retain sched_fifo before eval is done to avoid
-// performance regression.
-const char SCHED_FIFO_PRIOIRTY[] = "sensor.hubconnection.sched_fifo";
-#endif
-
namespace android {
// static
@@ -318,49 +307,16 @@ HubConnection::~HubConnection()
void HubConnection::onFirstRef()
{
run("HubConnection", PRIORITY_URGENT_DISPLAY);
-#ifdef USE_SENSORSERVICE_TO_GET_FIFO
- if (property_get_bool(SCHED_FIFO_PRIOIRTY, true)) {
- ALOGV("Try activate sched-fifo priority for HubConnection thread");
- mEnableSchedFifoThread = std::thread(enableSchedFifoMode, this);
- }
-#else
- enableSchedFifoMode(this);
-#endif
+ enableSchedFifoMode();
}
// Set main thread to SCHED_FIFO to lower sensor event latency when system is under load
-void HubConnection::enableSchedFifoMode(sp<HubConnection> hub) {
-#ifdef USE_SENSORSERVICE_TO_GET_FIFO
- using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService;
- using ::android::hardware::Return;
-
- // SchedulingPolicyService will not start until system server start.
- // Thus, cannot block on this.
- sp<ISchedulingPolicyService> scheduler = ISchedulingPolicyService::getService();
-
- if (scheduler == nullptr) {
- ALOGW("Couldn't get scheduler scheduler to set SCHED_FIFO.");
- } else {
- Return<int32_t> max = scheduler->getMaxAllowedPriority();
- if (!max.isOk()) {
- ALOGW("Failed to retrieve maximum allowed priority for HubConnection.");
- return;
- }
- Return<bool> ret = scheduler->requestPriority(::getpid(), hub->getTid(), max);
- if (!ret.isOk() || !ret) {
- ALOGW("Failed to set SCHED_FIFO for HubConnection.");
- } else {
- ALOGV("Enabled sched fifo thread mode (prio %d)", static_cast<int32_t>(max));
- }
- }
-#else
-#define HUBCONNECTION_SCHED_FIFO_PRIORITY 10
+void HubConnection::enableSchedFifoMode() {
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) {
+ if (sched_setscheduler(getTid(), SCHED_FIFO | SCHED_RESET_ON_FORK, &param) != 0) {
ALOGW("Couldn't set SCHED_FIFO for HubConnection thread");
}
-#endif
}
status_t HubConnection::initCheck() const
diff --git a/sensorhal/hubconnection.h b/sensorhal/hubconnection.h
index 388660cf..558ece34 100644
--- a/sensorhal/hubconnection.h
+++ b/sensorhal/hubconnection.h
@@ -36,9 +36,6 @@
#include "hubdefs.h"
#include "ring.h"
-#ifdef USE_SENSORSERVICE_TO_GET_FIFO
-#include <thread>
-#endif
#include <unordered_map>
#define WAKELOCK_NAME "sensorHal"
@@ -298,11 +295,8 @@ private:
void restoreSensorState();
void sendCalibrationOffsets();
-#ifdef USE_SENSORSERVICE_TO_GET_FIFO
// Enable SCHED_FIFO priority for main thread
- std::thread mEnableSchedFifoThread;
-#endif
- static void enableSchedFifoMode(sp<HubConnection> hub);
+ void enableSchedFifoMode();
#ifdef LID_STATE_REPORTING_ENABLED
int mUinputFd;