framework: update WFD session orientation based on UIBC rotation

User Input Back Channel (UIBC) support in Wifi Display stack
allows the sink to send control/commands/preferences to the source
e.g. touch, keyboard/mouse entry, or orientation/rotation.

PhoneWindowManager needs to listen for UIBC rotation
intents and update the preferred rotation when WFD is active.

Note: HDMI rotation lock overrides WiFi Display UIBC rotation.

Change-Id: I1869b21c3c03b5b36c5381933b50dfbfeca88db6
Conflicts:
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index a37123e..92bb71a 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -556,7 +556,8 @@
     private static final int MSG_DISPATCH_SHOW_GLOBAL_ACTIONS = 10;
     private static final int MSG_HIDE_BOOT_MESSAGE = 11;
     private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12;
-    boolean mWifiDisplayConnected;
+    boolean mWifiDisplayConnected = false;
+    int     mWifiDisplayCustomRotation = -1;
 
     private class PolicyHandler extends Handler {
         @Override
@@ -4872,6 +4873,8 @@
                 } else {
                     mWifiDisplayConnected = false;
                 }
+                mWifiDisplayCustomRotation =
+                        intent.getIntExtra("wfd_UIBC_rot", -1);
                 updateRotation(true);
             }
         }
@@ -5203,6 +5206,9 @@
                 // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled.
                 // Note that the dock orientation overrides the HDMI orientation.
                 preferredRotation = mDemoHdmiRotation;
+            } else if ( mWifiDisplayConnected && (mWifiDisplayCustomRotation > -1)) {
+                // Ignore sensor when WFD is active and UIBC rotation is enabled
+                preferredRotation = mWifiDisplayCustomRotation;
             } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED
                     && mUndockedHdmiRotation >= 0) {
                 // Ignore sensor when plugged into HDMI and an undocked orientation has