Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b11476f authored by Sachin Shah's avatar Sachin Shah Committed by Ricardo Cerqueira
Browse files

PhoneWindowManager: Changes for WFD.

- WFD now sends WIFI_DISPLAY_VIDEO intent to set UI orientation.
- PhoneWindowManager to listen for WFD intents.
- Display on WFD should be same as seen on the HDMI, so set the
  orientation to HDMI orientation

Conflicts:
core/java/android/content/Intent.java
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Change-Id: I446ab768200f9b9f59759e52071bcaca7d6f836c
parent 5e983fe2
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2232,6 +2232,19 @@ public class Intent implements Parcelable, Cloneable {
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;

    /**
     * Broadcast Action: WiFi Display video is enabled or disabled
     *
     * <p>The intent will have the following extra values:
     * <ul>
     *   <li><em>state</em> - 0 for disabled, 1 for enabled. </li>
     * </ul>
     * @hide
     */

    public static final String ACTION_WIFI_DISPLAY_VIDEO =
            "org.codeaurora.intent.action.WIFI_DISPLAY_VIDEO";

    /**
     * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
     * <ul>
+24 −1
Original line number Diff line number Diff line
@@ -556,6 +556,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    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;

    private class PolicyHandler extends Handler {
        @Override
@@ -1126,6 +1127,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mWindowManagerFuncs.registerPointerEventListener(mSystemGestures);

        mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);

        // register for WIFI Display intents
        IntentFilter wifiDisplayFilter = new IntentFilter(
                                                Intent.ACTION_WIFI_DISPLAY_VIDEO);
        Intent wifidisplayIntent = context.registerReceiver(
                                      mWifiDisplayReceiver, wifiDisplayFilter);

        mLongPressVibePattern = getLongIntArray(mContext.getResources(),
                com.android.internal.R.array.config_longPressVibePattern);
        mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(),
@@ -4854,6 +4862,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    BroadcastReceiver mWifiDisplayReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
            if (action.equals(Intent.ACTION_WIFI_DISPLAY_VIDEO)) {
                int state = intent.getIntExtra("state", 0);
                if(state == 1) {
                    mWifiDisplayConnected = true;
                } else {
                    mWifiDisplayConnected = false;
                }
                updateRotation(true);
            }
        }
    };

    // Called on the PowerManager's Notifier thread.
    @Override
    public void goingToSleep(int why) {
@@ -5176,7 +5199,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                // enable 180 degree rotation while docked.
                preferredRotation = mDeskDockEnablesAccelerometer
                        ? sensorRotation : mDeskDockRotation;
            } else if (mHdmiPlugged && mDemoHdmiRotationLock) {
            } else if ((mHdmiPlugged || mWifiDisplayConnected) && mDemoHdmiRotationLock) {
                // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled.
                // Note that the dock orientation overrides the HDMI orientation.
                preferredRotation = mDemoHdmiRotation;