hidl: touch: Add binderized service implementation

* Change default ::implementation namespace to ::samsung
* Fill in required methods for used impls
* Cleanup passthrough code for used impls
* Add and setup binderized service

Change-Id: Iadc3b6e385233d103c3349ce31a08d6d040886c7
diff --git a/lineagehw/hidl/touch/StylusMode.cpp b/lineagehw/hidl/touch/StylusMode.cpp
index 5f5a33a..aa86e7a 100644
--- a/lineagehw/hidl/touch/StylusMode.cpp
+++ b/lineagehw/hidl/touch/StylusMode.cpp
@@ -14,28 +14,49 @@
  * limitations under the License.
  */
 
+#include <fstream>
+
 #include "StylusMode.h"
 
 namespace vendor {
 namespace lineage {
 namespace touch {
 namespace V1_0 {
-namespace implementation {
+namespace samsung {
 
-// Methods from ::vendor::lineage::touch::V1_0::IStylusMode follow.
-Return<void> StylusMode::setEnabled(bool enabled) {
-    // TODO implement
-    return Void();
+bool StylusMode::isSupported() {
+    std::ifstream file("/sys/class/sec/tsp/cmd_list");
+    if (file.is_open()) {
+        std::string line;
+        while (getline(file, line)) {
+            if (!line.compare("hover_enable"))
+                return true;
+        }
+        file.close();
+    }
+    return false;
 }
 
+// Methods from ::vendor::lineage::touch::V1_0::IStylusMode follow.
+Return<bool> StylusMode::isEnabled() {
+    std::ifstream file("/sys/class/sec/tsp/cmd_result");
+    if (file.is_open()) {
+        std::string line;
+        getline(file, line);
+        if (!line.compare("hover_enable,1:OK"))
+            return true;
+        file.close();
+    }
+    return false;
+}
 
-// Methods from ::android::hidl::base::V1_0::IBase follow.
+Return<bool> StylusMode::setEnabled(bool enabled) {
+    std::ofstream file("/sys/class/sec/tsp/cmd");
+    file << "hover_enable," << (enabled ? "1" : "0");
+    return true;
+}
 
-//IStylusMode* HIDL_FETCH_IStylusMode(const char* /* name */) {
-    //return new StylusMode();
-//}
-//
-}  // namespace implementation
+}  // namespace samsung
 }  // namespace V1_0
 }  // namespace touch
 }  // namespace lineage