libqservice: Add a client interface.

Add a client interface which interfaces with hwc.
qservice upon receiving IPC, provides a callback notification to the qclient
which does appropriate stuff in hwc.

In future, qservice can safely be even made a separate process with no changes
to exisiting code. This was not true earlier owing to the hwc pointer held by
qservice forcing it to be in the same process that hwc is in.

CRs-fixed: 452977
Change-Id: I05838c213f5d4606a6573693de1bacbc5876107e
diff --git a/libqservice/QService.cpp b/libqservice/QService.cpp
index 1c9f165..8fc7319 100644
--- a/libqservice/QService.cpp
+++ b/libqservice/QService.cpp
@@ -1,5 +1,5 @@
 /*
- *  Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ *  Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -28,7 +28,6 @@
  */
 
 #include <QService.h>
-#include <hwc_utils.h>
 
 #define QSERVICE_DEBUG 0
 
@@ -38,7 +37,7 @@
 
 QService* QService::sQService = NULL;
 // ----------------------------------------------------------------------------
-QService::QService(hwc_context_t *ctx):mHwcContext(ctx)
+QService::QService()
 {
     ALOGD_IF(QSERVICE_DEBUG, "QService Constructor invoked");
 }
@@ -49,27 +48,25 @@
 }
 
 void QService::securing(uint32_t startEnd) {
-    mHwcContext->mSecuring = startEnd;
-    //We're done securing
-    if(startEnd == END)
-        mHwcContext->mSecureMode = true;
-    if(mHwcContext->proc)
-        mHwcContext->proc->invalidate(mHwcContext->proc);
+    if(mClient.get()) {
+        mClient->notifyCallback(SECURING, startEnd);
+    }
 }
 
 void QService::unsecuring(uint32_t startEnd) {
-    mHwcContext->mSecuring = startEnd;
-    //We're done unsecuring
-    if(startEnd == END)
-        mHwcContext->mSecureMode = false;
-    if(mHwcContext->proc)
-        mHwcContext->proc->invalidate(mHwcContext->proc);
+    if(mClient.get()) {
+        mClient->notifyCallback(UNSECURING, startEnd);
+    }
 }
 
-QService* QService::getInstance(hwc_context_t *ctx)
+void QService::connect(const sp<qClient::IQClient>& client) {
+    mClient = client;
+}
+
+void QService::init()
 {
     if(!sQService) {
-        sQService = new QService(ctx);
+        sQService = new QService();
         sp<IServiceManager> sm = defaultServiceManager();
         sm->addService(String16("display.qservice"), sQService);
         if(sm->checkService(String16("display.qservice")) != NULL)
@@ -77,7 +74,6 @@
         else
             ALOGD_IF(QSERVICE_DEBUG, "adding display.qservice failed");
     }
-    return sQService;
 }
 
 }