merge in jb-mr1-release history after reset to jb-mr1-dev
diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h
index bae3886..581ec8d 100644
--- a/include/gui/SurfaceComposerClient.h
+++ b/include/gui/SurfaceComposerClient.h
@@ -67,6 +67,12 @@
     // Get information about a display
     static status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info);
 
+    /* triggers screen off and waits for it to complete */
+    static void blankDisplay(const sp<IBinder>& display);
+
+    /* triggers screen on and waits for it to complete */
+    static void unblankDisplay(const sp<IBinder>& display);
+
     // ------------------------------------------------------------------------
     // surface creation / destruction
 
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 4165d01..3efd086 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -552,6 +552,14 @@
     return ComposerService::getComposerService()->getDisplayInfo(display, info);
 }
 
+void SurfaceComposerClient::blankDisplay(const sp<IBinder>& token) {
+    ComposerService::getComposerService()->blank(token);
+}
+
+void SurfaceComposerClient::unblankDisplay(const sp<IBinder>& token) {
+    ComposerService::getComposerService()->unblank(token);
+}
+
 // ----------------------------------------------------------------------------
 
 ScreenshotClient::ScreenshotClient()
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index dd9a762..be4af51 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -901,14 +901,16 @@
     return getLayerIterator(id, numLayers);
 }
 
-void HWComposer::dump(String8& result, char* buffer, size_t SIZE,
-        const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const {
+void HWComposer::dump(String8& result, char* buffer, size_t SIZE) const {
     if (mHwc) {
         result.appendFormat("Hardware Composer state (version %8x):\n", hwcApiVersion(mHwc));
         result.appendFormat("  mDebugForceFakeVSync=%d\n", mDebugForceFakeVSync);
         for (size_t i=0 ; i<mNumDisplays ; i++) {
             const DisplayData& disp(mDisplayData[i]);
 
+            const Vector< sp<LayerBase> >& visibleLayersSortedByZ =
+                    mFlinger->getLayerSortedByZForHwcDisplay(i);
+
             if (disp.connected) {
                 result.appendFormat(
                         "  Display[%d] : %ux%u, xdpi=%f, ydpi=%f, refresh=%lld\n",
@@ -928,6 +930,7 @@
                     const hwc_layer_1_t&l = disp.list->hwLayers[i];
                     int32_t format = -1;
                     String8 name("unknown");
+
                     if (i < visibleLayersSortedByZ.size()) {
                         const sp<LayerBase>& layer(visibleLayersSortedByZ[i]);
                         if (layer->getLayer() != NULL) {
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index 269e147..a78ffac 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -258,8 +258,7 @@
     friend class VSyncThread;
 
     // for debugging ----------------------------------------------------------
-    void dump(String8& out, char* scratch, size_t SIZE,
-            const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const;
+    void dump(String8& out, char* scratch, size_t SIZE) const;
 
 private:
     void loadHwcModule();
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 1103175..8367417 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2333,7 +2333,7 @@
             hwc.initCheck()==NO_ERROR ? "present" : "not present",
                     (mDebugDisableHWC || mDebugRegion) ? "disabled" : "enabled");
     result.append(buffer);
-    hwc.dump(result, buffer, SIZE, hw->getVisibleLayersSortedByZ());
+    hwc.dump(result, buffer, SIZE);
 
     /*
      * Dump gralloc state
@@ -2342,6 +2342,11 @@
     alloc.dump(result);
 }
 
+const Vector< sp<LayerBase> >&
+SurfaceFlinger::getLayerSortedByZForHwcDisplay(int disp) {
+    return getDisplayDevice( getBuiltInDisplay(disp) )->getVisibleLayersSortedByZ();
+}
+
 bool SurfaceFlinger::startDdmConnection()
 {
     void* libddmconnection_dso =
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 5bb3703..6d36719 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -130,6 +130,10 @@
     // TODO: this should be made accessible only to MessageQueue
     void onMessageReceived(int32_t what);
 
+    // for debugging only
+    // TODO: this should be made accessible only to HWComposer
+    const Vector< sp<LayerBase> >& getLayerSortedByZForHwcDisplay(int disp);
+
 private:
     friend class Client;
     friend class DisplayEventConnection;