Merge "SurfaceFlinger: add support for secure displays" into jb-mr1-dev
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index d9bda11..31d731e 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -128,6 +128,11 @@
         abort();
     }
 
+    // these display IDs are always reserved
+    for (size_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) {
+        mAllocatedDisplayIDs.markBit(i);
+    }
+
     if (mHwc) {
         ALOGI("Using %s version %u.%u", HWC_HARDWARE_COMPOSER,
               (hwcApiVersion(mHwc) >> 24) & 0xff,
@@ -149,11 +154,6 @@
         // always turn vsync off when we start
         eventControl(HWC_DISPLAY_PRIMARY, HWC_EVENT_VSYNC, 0);
 
-        // these IDs are always reserved
-        for (size_t i=0 ; i<HWC_NUM_DISPLAY_TYPES ; i++) {
-            mAllocatedDisplayIDs.markBit(i);
-        }
-
         // the number of displays we actually have depends on the
         // hw composer version
         if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_2)) {
@@ -445,6 +445,13 @@
 
 void HWComposer::eventControl(int disp, int event, int enabled) {
     if (uint32_t(disp)>31 || !mAllocatedDisplayIDs.hasBit(disp)) {
+        ALOGD("eventControl ignoring event %d on unallocated disp %d (en=%d)",
+              event, disp, enabled);
+        return;
+    }
+    if (event != EVENT_VSYNC) {
+        ALOGW("eventControl got unexpected event %d (disp=%d en=%d)",
+              event, disp, enabled);
         return;
     }
     status_t err = NO_ERROR;