display: Add setSecondaryDisplayStatus API

- Clients(SecureUI/WFD FW) will use this API to set status of the
  Secondary display
- Status can be offline/pause/resume
- Secondary display will be hdmi/wfd, HWC will free up pipes for
  these displays

Change-Id: I25d5e070b60c38daeb102349bed14bb6de0a5684
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index e541dcd..3eec011 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -2635,15 +2635,46 @@
 }
 
 void handle_pause(hwc_context_t* ctx, int dpy) {
-    if(ctx->mHWCVirtual) {
-        ctx->mHWCVirtual->pause(ctx, dpy);
+    if(ctx->dpyAttr[dpy].connected) {
+        ctx->mDrawLock.lock();
+        ctx->dpyAttr[dpy].isActive = true;
+        ctx->dpyAttr[dpy].isPause = true;
+        ctx->mDrawLock.unlock();
+        ctx->proc->invalidate(ctx->proc);
+
+        usleep(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period
+               * 2 / 1000);
+
+        // At this point all the pipes used by External have been
+        // marked as UNSET.
+        ctx->mDrawLock.lock();
+        // Perform commit to unstage the pipes.
+        if (!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) {
+            ALOGE("%s: display commit fail! for %d dpy",
+                  __FUNCTION__, dpy);
+        }
+        ctx->mDrawLock.unlock();
+        ctx->proc->invalidate(ctx->proc);
     }
     return;
 }
 
 void handle_resume(hwc_context_t* ctx, int dpy) {
-    if(ctx->mHWCVirtual) {
-        ctx->mHWCVirtual->resume(ctx, dpy);
+    if(ctx->dpyAttr[dpy].connected) {
+        ctx->mDrawLock.lock();
+        ctx->dpyAttr[dpy].isConfiguring = true;
+        ctx->dpyAttr[dpy].isActive = true;
+        ctx->mDrawLock.unlock();
+        ctx->proc->invalidate(ctx->proc);
+
+        usleep(ctx->dpyAttr[HWC_DISPLAY_PRIMARY].vsync_period
+               * 2 / 1000);
+
+        //At this point external has all the pipes it would need.
+        ctx->mDrawLock.lock();
+        ctx->dpyAttr[dpy].isPause = false;
+        ctx->mDrawLock.unlock();
+        ctx->proc->invalidate(ctx->proc);
     }
     return;
 }