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

Commit d49398c2 authored by Sachin Shah's avatar Sachin Shah Committed by Steve Kondik
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

Change-Id: Id4d26526a858bd302dec5fc6e699e8b01afc2709
parent 814f46b4
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2190,6 +2190,19 @@ public class Intent implements Parcelable, Cloneable {
    public static final String ACTION_HEADSET_PLUG =
            "android.intent.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";

    /**
     * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
     *
+24 −2
Original line number Diff line number Diff line
@@ -565,6 +565,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4;
    private static final int MSG_DISPATCH_VOLKEY_WITH_WAKE_LOCK = 5;

    boolean mWifiDisplayConnected;

    private class PolicyHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
@@ -1305,6 +1307,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        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(),
@@ -5144,6 +5152,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);
            }
        }
    };

    @Override
    public void screenTurnedOff(int why) {
        EventLog.writeEvent(70000, 0);
@@ -5368,8 +5391,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;