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

Commit b08a47e5 authored by Ramakant Singh's avatar Ramakant Singh Committed by Linux Build Service Account
Browse files

PhoneWindowManager: Changes for WFD and UIBC

This change includes the below gerrits:

    # This is a combination of 3 commits

    # The first commit's message is:
    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: I446ab768200f9b9f59759e52071bcaca7d6f836c

    # This is the 2nd commit message:
    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

    # This is the 3rd commit message:
    PhoneWindowManager: Changes for WiFi Display to comply with Android CDD
    Remove definition of Intent action for ACTION_WIFI_DISPLAY_VIDEO from
    Intent.java and make it local to PhoneWindowManager.

    Change-Id: I91a6d302e19705080ccc109ee6532c6d43f58165

Change-Id: I03e2ca995c520519b29eb30a1a52959c0992f77e
parent 70918513
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
@@ -216,6 +216,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
            .build();

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

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


    // The panic gesture may become active only after the keyguard is dismissed and the immersive
    // app shows again. If that doesn't happen for 30s we drop the gesture.
    private static final long PANIC_GESTURE_EXPIRATION = 30000;
@@ -635,6 +648,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private static final int MSG_POWER_DELAYED_PRESS = 13;
    private static final int MSG_POWER_LONG_PRESS = 14;
    private static final int MSG_UPDATE_DREAMING_SLEEP_TOKEN = 15;
    boolean mWifiDisplayConnected = false;
    int mWifiDisplayCustomRotation = -1;

    private class PolicyHandler extends Handler {
        @Override
@@ -1508,6 +1523,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mWindowManagerFuncs.registerPointerEventListener(mSystemGestures);

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

        /* Register for WIFI Display Intents */
        IntentFilter wifiDisplayFilter = new IntentFilter(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(),
@@ -5452,6 +5472,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }


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

    // Called on the PowerManager's Notifier thread.
    @Override
    public void startedGoingToSleep(int why) {
@@ -5823,10 +5861,13 @@ 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;
            } 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