OSDN Git Service

Bluetooth: Remove scheduler-service dependency
authorMyles Watson <mylesgw@google.com>
Fri, 26 May 2017 17:09:07 +0000 (10:09 -0700)
committerMyles Watson <mylesgw@google.com>
Fri, 26 May 2017 20:34:12 +0000 (20:34 +0000)
Bug: 38178265
Test: Bluetooth enable/disable
      adb shell stop && adb shell VtsHalBluetoothV1_TargetTest

Change-Id: I7f892bad73f72b46b7b1720bda267fdddad21948

bluetooth/1.0/default/Android.bp
bluetooth/1.0/default/Android.mk
bluetooth/1.0/default/async_fd_watcher.cc
bluetooth/1.0/default/service.cpp

index 46a4987..31a2641 100644 (file)
@@ -24,7 +24,6 @@ cc_library_shared {
         "vendor_interface.cc",
     ],
     shared_libs: [
-        "android.frameworks.schedulerservice@1.0",
         "android.hardware.bluetooth@1.0",
         "libbase",
         "libcutils",
@@ -49,7 +48,6 @@ cc_library_static {
     ],
     export_include_dirs: ["."],
     shared_libs: [
-        "android.frameworks.schedulerservice@1.0",
         "liblog",
     ],
 }
@@ -86,7 +84,6 @@ cc_test {
         "test",
     ],
     shared_libs: [
-        "android.frameworks.schedulerservice@1.0",
         "libbase",
         "libhidlbase",
         "liblog",
index 2dcb067..38294c7 100644 (file)
@@ -35,6 +35,5 @@ LOCAL_SHARED_LIBRARIES += \
   libhidlbase \
   libhidltransport \
   android.hardware.bluetooth@1.0 \
-  android.frameworks.schedulerservice@1.0\
 
 include $(BUILD_EXECUTABLE)
index ab8d555..bc0bc92 100644 (file)
@@ -30,8 +30,6 @@
 #include "sys/select.h"
 #include "unistd.h"
 
-#include <android/frameworks/schedulerservice/1.0/ISchedulingPolicyService.h>
-
 static const int INVALID_FD = -1;
 
 static const int BT_RT_PRIORITY = 1;
@@ -119,19 +117,12 @@ int AsyncFdWatcher::notifyThread() {
 }
 
 void AsyncFdWatcher::ThreadRoutine() {
-  using ::android::frameworks::schedulerservice::V1_0::ISchedulingPolicyService;
-  using ::android::hardware::Return;
-  sp<ISchedulingPolicyService> manager = ISchedulingPolicyService::getService();
-  if (manager == nullptr) {
-    ALOGE("%s: Couldn't get scheduler manager to set SCHED_FIFO.", __func__);
-  } else {
-    Return<bool> ret = manager->requestPriority(getpid(),
-                                                gettid(),
-                                                BT_RT_PRIORITY);
-    if (!ret.isOk() || !ret) {
-      ALOGE("%s unable to set SCHED_FIFO for pid %d, tid %d", __func__,
-            getpid(), gettid());
-    }
+  // Make watching thread RT.
+  struct sched_param rt_params;
+  rt_params.sched_priority = BT_RT_PRIORITY;
+  if (sched_setscheduler(gettid(), SCHED_FIFO, &rt_params)) {
+    ALOGE("%s unable to set SCHED_FIFO for pid %d, tid %d, error %s", __func__,
+          getpid(), gettid(), strerror(errno));
   }
 
   while (running_) {
index a588c37..3a7aad0 100644 (file)
@@ -20,8 +20,8 @@
 
 #include <hidl/LegacySupport.h>
 
-// Add an extra thread for calls to the scheduler service.
-static const size_t kMaxThreads = 2;
+// Extra threads make priority inheritance faster.
+static const size_t kMaxThreads = 5;
 
 // Generated HIDL files
 using android::hardware::bluetooth::V1_0::IBluetoothHci;