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

Commit e72c1869 authored by Jimmy Chen's avatar Jimmy Chen Committed by Etan Cohen
Browse files

p2p: add new API to indicate Content Protection support status

Bug: 147929113
Test: atest FrameworksWifiApiTests
Change-Id: I88b48b4a0a0bd5c80b920104bcb15dfd89ba1763
parent ece12a89
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31462,8 +31462,10 @@ package android.net.wifi.p2p {
    method public int getControlPort();
    method public int getDeviceType();
    method public int getMaxThroughput();
    method public boolean isContentProtectionSupported();
    method public boolean isSessionAvailable();
    method public boolean isWfdEnabled();
    method public void setContentProtectionSupported(boolean);
    method public void setControlPort(int);
    method public boolean setDeviceType(int);
    method public void setMaxThroughput(int);
+25 −0
Original line number Diff line number Diff line
@@ -61,6 +61,9 @@ public final class WifiP2pWfdInfo implements Parcelable {
     * {@link #mDeviceInfo} & {@link #DEVICE_TYPE} is one of {@link #DEVICE_TYPE_WFD_SOURCE},
     * {@link #DEVICE_TYPE_PRIMARY_SINK}, {@link #DEVICE_TYPE_SECONDARY_SINK} or
     * {@link #DEVICE_TYPE_SOURCE_OR_PRIMARY_SINK}.
     *
     * The bit definition is listed in 5.1.2 WFD Device Information Subelement in
     * Wi-Fi Display Technical Specification.
     */
    private static final int DEVICE_TYPE                            = 1 << 1 | 1 << 0;
    private static final int COUPLED_SINK_SUPPORT_AT_SOURCE         = 1 << 2;
@@ -69,6 +72,8 @@ public final class WifiP2pWfdInfo implements Parcelable {
    private static final int SESSION_AVAILABLE_BIT2                 = 1 << 5;
    private static final int SESSION_AVAILABLE                      =
            SESSION_AVAILABLE_BIT2 | SESSION_AVAILABLE_BIT1;
    /* The support of Content Protection using the HDCP system 2.0/2.1. */
    private static final int CONTENT_PROTECTION_SUPPORT             = 1 << 8;

    private int mCtrlPort;

@@ -146,6 +151,26 @@ public final class WifiP2pWfdInfo implements Parcelable {
        }
    }

    /**
     * @return true if Content Protection using the HDCP system 2.0/2.1 is supported.
     */
    public boolean isContentProtectionSupported() {
        return (mDeviceInfo & CONTENT_PROTECTION_SUPPORT) != 0;
    }

    /**
     * Sets whether Content Protection using the HDCP system 2.0/2.1 is supported.
     *
     * @param enabled true to indicate that Content Protection is supported, false otherwise.
     */
    public void setContentProtectionSupported(boolean enabled) {
        if (enabled) {
            mDeviceInfo |= CONTENT_PROTECTION_SUPPORT;
        } else {
            mDeviceInfo &= ~CONTENT_PROTECTION_SUPPORT;
        }
    }

    /** Returns the TCP port at which the WFD Device listens for RTSP messages. */
    public int getControlPort() {
        return mCtrlPort;
+5 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public class WifiP2pWfdInfoTest {
        // initialize device info flags.
        mSourceInfo.setDeviceType(WifiP2pWfdInfo.DEVICE_TYPE_WFD_SOURCE);
        mSourceInfo.setSessionAvailable(true);
        mSourceInfo.setContentProtectionSupported(true);
    }

    /**
@@ -63,13 +64,16 @@ public class WifiP2pWfdInfoTest {
        info.setSessionAvailable(true);
        assertTrue(info.isSessionAvailable());

        info.setContentProtectionSupported(true);
        assertTrue(info.isContentProtectionSupported());

        info.setControlPort(TEST_CTRL_PORT);
        assertEquals(TEST_CTRL_PORT, info.getControlPort());

        info.setMaxThroughput(TEST_MAX_TPUT);
        assertEquals(TEST_MAX_TPUT, info.getMaxThroughput());

        assertEquals("0010270f0400", info.getDeviceInfoHex());
        assertEquals("0110270f0400", info.getDeviceInfoHex());
    }

    /**