Add IScheduleTest for VTS libhwbinder scheduler test

Add IScheduleTest.hal:
    send(cfg, callerSta)
cfg: 1 for verbose output
caller_status:  (caller_rt_priority <<16 )| caller_cpu

with the return value defined as:
((1 if no priority inheritance)<<16) | (1 if no cpu sync)
The implementation is in ScheduleTest.cpp

Bug:36705188
Test: sailfish/prebuilt kernel/oc-dev with the libhwbinder_latency
  vts test case
Change-Id: Ie2a837c8d0d4fa95c6fd0ebd50e76412cb808df8
diff --git a/tests/libhwbinder/1.0/default/ScheduleTest.cpp b/tests/libhwbinder/1.0/default/ScheduleTest.cpp
new file mode 100644
index 0000000..6356953
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/ScheduleTest.cpp
@@ -0,0 +1,84 @@
+#include "ScheduleTest.h"
+#include <pthread.h>
+#include <iomanip>
+#include <iostream>
+
+using namespace std;
+
+#define ASSERT(cond)                                                      \
+    do {                                                                  \
+        if (!(cond)) {                                                    \
+            cerr << __func__ << ":" << __LINE__ << " condition:" << #cond \
+                 << " failed\n"                                           \
+                 << endl;                                                 \
+            exit(EXIT_FAILURE);                                           \
+        }                                                                 \
+    } while (0)
+
+static int threadPri() {
+    struct sched_param param;
+    int policy;
+    ASSERT(!pthread_getschedparam(pthread_self(), &policy, &param));
+    return param.sched_priority;
+}
+
+static void threadDump(const char* prefix, int verbose) {
+    struct sched_param param;
+    int policy;
+    if (!verbose) return;
+    cout << "--------------------------------------------------" << endl;
+    cout << setw(12) << left << prefix << " pid: " << getpid()
+         << " tid: " << gettid() << " cpu: " << sched_getcpu() << endl;
+    ASSERT(!pthread_getschedparam(pthread_self(), &policy, &param));
+    string s = (policy == SCHED_OTHER)
+                   ? "SCHED_OTHER"
+                   : (policy == SCHED_FIFO)
+                         ? "SCHED_FIFO"
+                         : (policy == SCHED_RR) ? "SCHED_RR" : "???";
+    cout << setw(12) << left << s << param.sched_priority << endl;
+    return;
+}
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::libhwbinder::V1_0::IScheduleTest
+// follow.
+Return<uint32_t> ScheduleTest::send(uint32_t cfg, uint32_t callerSta) {
+    // TODO implement
+    int priority = threadPri();
+    int priority_caller = (callerSta >> 16) & 0xffff;
+    int verbose = cfg & 1;
+    threadDump("hwbinder", verbose);
+    uint32_t h = 0, s = 0;
+    if (priority_caller != priority) {
+        h++;
+        if (verbose) {
+            cout << "err priority_caller:" << priority_caller
+                 << ", priority:" << priority << endl;
+        }
+    }
+    int cpu = sched_getcpu();
+    int cpu_caller = (callerSta)&0xffff;
+    if (cpu != cpu_caller) {
+        s++;
+    }
+    return (h << 16) | (s & 0xffff);
+}
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
+IScheduleTest* HIDL_FETCH_IScheduleTest(const char* /* name */) {
+    return new ScheduleTest();
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace libhwbinder
+}  // namespace tests
+}  // namespace hardware
+}  // namespace android