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

Commit 0008fa8d authored by Ahmed ElArabawy's avatar Ahmed ElArabawy
Browse files

Support of Low Latency mode for WifiLocks



This commit is part of adding the support for low latency mode
wakelocks. It adds the new WifiLock for low latency
This commit also deprecates the FULL, and SCAN_ONLY wifilocks.

Bug: 34905427
Test: No Test- This commit is just the api definition

Change-Id: Id47294867d8000517601dd48a2fcf5a345779ddb
Signed-off-by: default avatarAhmed ElArabawy <arabawy@google.com>
parent ff9d6ab6
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -29061,7 +29061,7 @@ package android.net.wifi {
    method public static int compareSignalLevel(int, int);
    method public static int compareSignalLevel(int, int);
    method public android.net.wifi.WifiManager.MulticastLock createMulticastLock(java.lang.String);
    method public android.net.wifi.WifiManager.MulticastLock createMulticastLock(java.lang.String);
    method public android.net.wifi.WifiManager.WifiLock createWifiLock(int, java.lang.String);
    method public android.net.wifi.WifiManager.WifiLock createWifiLock(int, java.lang.String);
    method public android.net.wifi.WifiManager.WifiLock createWifiLock(java.lang.String);
    method public deprecated android.net.wifi.WifiManager.WifiLock createWifiLock(java.lang.String);
    method public deprecated boolean disableNetwork(int);
    method public deprecated boolean disableNetwork(int);
    method public deprecated boolean disconnect();
    method public deprecated boolean disconnect();
    method public deprecated boolean enableNetwork(int, boolean);
    method public deprecated boolean enableNetwork(int, boolean);
@@ -29117,9 +29117,10 @@ package android.net.wifi {
    field public static final java.lang.String SCAN_RESULTS_AVAILABLE_ACTION = "android.net.wifi.SCAN_RESULTS";
    field public static final java.lang.String SCAN_RESULTS_AVAILABLE_ACTION = "android.net.wifi.SCAN_RESULTS";
    field public static final deprecated java.lang.String SUPPLICANT_CONNECTION_CHANGE_ACTION = "android.net.wifi.supplicant.CONNECTION_CHANGE";
    field public static final deprecated java.lang.String SUPPLICANT_CONNECTION_CHANGE_ACTION = "android.net.wifi.supplicant.CONNECTION_CHANGE";
    field public static final deprecated java.lang.String SUPPLICANT_STATE_CHANGED_ACTION = "android.net.wifi.supplicant.STATE_CHANGE";
    field public static final deprecated java.lang.String SUPPLICANT_STATE_CHANGED_ACTION = "android.net.wifi.supplicant.STATE_CHANGE";
    field public static final int WIFI_MODE_FULL = 1; // 0x1
    field public static final deprecated int WIFI_MODE_FULL = 1; // 0x1
    field public static final int WIFI_MODE_FULL_HIGH_PERF = 3; // 0x3
    field public static final int WIFI_MODE_FULL_HIGH_PERF = 3; // 0x3
    field public static final int WIFI_MODE_SCAN_ONLY = 2; // 0x2
    field public static final int WIFI_MODE_FULL_LOW_LATENCY = 4; // 0x4
    field public static final deprecated int WIFI_MODE_SCAN_ONLY = 2; // 0x2
    field public static final java.lang.String WIFI_STATE_CHANGED_ACTION = "android.net.wifi.WIFI_STATE_CHANGED";
    field public static final java.lang.String WIFI_STATE_CHANGED_ACTION = "android.net.wifi.WIFI_STATE_CHANGED";
    field public static final int WIFI_STATE_DISABLED = 1; // 0x1
    field public static final int WIFI_STATE_DISABLED = 1; // 0x1
    field public static final int WIFI_STATE_DISABLING = 0; // 0x0
    field public static final int WIFI_STATE_DISABLING = 0; // 0x0
+55 −16
Original line number Original line Diff line number Diff line
@@ -903,8 +903,12 @@ public class WifiManager {
     * establish a connection to a remembered access point that is
     * establish a connection to a remembered access point that is
     * within range, and will do periodic scans if there are remembered
     * within range, and will do periodic scans if there are remembered
     * access points but none are in range.
     * access points but none are in range.
     *
     * @deprecated This API is non-functional and will have no impact.
     */
     */
    @Deprecated
    public static final int WIFI_MODE_FULL = 1;
    public static final int WIFI_MODE_FULL = 1;

    /**
    /**
     * In this Wi-Fi lock mode, Wi-Fi will be kept active,
     * In this Wi-Fi lock mode, Wi-Fi will be kept active,
     * but the only operation that will be supported is initiation of
     * but the only operation that will be supported is initiation of
@@ -913,28 +917,62 @@ public class WifiManager {
     * nor will periodic scans be automatically performed looking for
     * nor will periodic scans be automatically performed looking for
     * remembered access points. Scans must be explicitly requested by
     * remembered access points. Scans must be explicitly requested by
     * an application in this mode.
     * an application in this mode.
     *
     * @deprecated This API is non-functional and will have no impact.
     */
     */
    @Deprecated
    public static final int WIFI_MODE_SCAN_ONLY = 2;
    public static final int WIFI_MODE_SCAN_ONLY = 2;

    /**
    /**
     * In this Wi-Fi lock mode, Wi-Fi will be kept active as in mode
     * In this Wi-Fi lock mode, Wi-Fi will not go to power save.
     * {@link #WIFI_MODE_FULL} but it operates at high performance
     * This results in operating with low packet latency.
     * with minimum packet loss and low packet latency even when
     * The lock is active  even when the device screen is off or
     * the device screen is off. This mode will consume more power
     * the acquiring application is running in the background.
     * and hence should be used only when there is a need for such
     * This mode will consume more power and hence should be used only
     * an active connection.
     * when there is a need for this tradeoff.
     * <p>
     * <p>
     * An example use case is when a voice connection needs to be
     * An example use case is when a voice connection needs to be
     * kept active even after the device screen goes off. Holding the
     * kept active even after the device screen goes off.
     * regular {@link #WIFI_MODE_FULL} lock will keep the wifi
     * connection active, but the connection can be lossy.
     * Holding a {@link #WIFI_MODE_FULL_HIGH_PERF} lock for the
     * Holding a {@link #WIFI_MODE_FULL_HIGH_PERF} lock for the
     * duration of the voice call will improve the call quality.
     * duration of the voice call may improve the call quality.
     * <p>
     * <p>
     * When there is no support from the hardware, this lock mode
     * When there is no support from the hardware, the {@link #WIFI_MODE_FULL_HIGH_PERF}
     * will have the same behavior as {@link #WIFI_MODE_FULL}
     * lock will have no impact.
     */
     */
    public static final int WIFI_MODE_FULL_HIGH_PERF = 3;
    public static final int WIFI_MODE_FULL_HIGH_PERF = 3;


    /**
     * In this Wi-Fi lock mode, Wi-Fi will operate with a priority to achieve low latency.
     * {@link #WIFI_MODE_FULL_LOW_LATENCY} lock has the following limitations:
     * <ol>
     * <li>The lock is only active when the screen is on.</li>
     * <li>The lock is only active when the acquiring app is running in the foreground.</li>
     * </ol>
     * Low latency mode optimizes for reduced packet latency,
     * and as a result other performance measures may suffer when there are trade-offs to make:
     * <ol>
     * <li>Battery life may be reduced.</li>
     * <li>Throughput may be reduced.</li>
     * <li>Frequency of Wi-Fi scanning may be reduced. This may result in: </li>
     * <ul>
     * <li>The device may not roam or switch to the AP with highest signal quality.</li>
     * <li>Location accuracy may be reduced.</li>
     * </ul>
     * </ol>
     * <p>
     * Example use cases are real time gaming or virtual reality applications where
     * low latency is a key factor for user experience.
     * <p>
     * When there is no support from the hardware, the {@link #WIFI_MODE_FULL_LOW_LATENCY}
     * lock will cause the device not to go power save.
     * <p>
     * Note: For an app which acquires both {@link #WIFI_MODE_FULL_LOW_LATENCY} and
     * {@link #WIFI_MODE_FULL_HIGH_PERF} locks, {@link #WIFI_MODE_FULL_LOW_LATENCY}
     * lock will be effective when app is running in foreground and screen is on,
     * while the {@link #WIFI_MODE_FULL_HIGH_PERF} lock will take effect otherwise.
     */
    public static final int WIFI_MODE_FULL_LOW_LATENCY = 4;

    /** Anything worse than or equal to this will show 0 bars. */
    /** Anything worse than or equal to this will show 0 bars. */
    @UnsupportedAppUsage
    @UnsupportedAppUsage
    private static final int MIN_RSSI = -100;
    private static final int MIN_RSSI = -100;
@@ -3772,9 +3810,8 @@ public class WifiManager {
    /**
    /**
     * Creates a new WifiLock.
     * Creates a new WifiLock.
     *
     *
     * @param lockType the type of lock to create. See {@link #WIFI_MODE_FULL},
     * @param lockType the type of lock to create. See {@link #WIFI_MODE_FULL_HIGH_PERF}
     * {@link #WIFI_MODE_FULL_HIGH_PERF} and {@link #WIFI_MODE_SCAN_ONLY} for
     * and {@link #WIFI_MODE_FULL_LOW_LATENCY} for descriptions of the types of Wi-Fi locks.
     * descriptions of the types of Wi-Fi locks.
     * @param tag a tag for the WifiLock to identify it in debugging messages.  This string is
     * @param tag a tag for the WifiLock to identify it in debugging messages.  This string is
     *            never shown to the user under normal conditions, but should be descriptive
     *            never shown to the user under normal conditions, but should be descriptive
     *            enough to identify your application and the specific WifiLock within it, if it
     *            enough to identify your application and the specific WifiLock within it, if it
@@ -3799,12 +3836,14 @@ public class WifiManager {
     * @return a new, unacquired WifiLock with the given tag.
     * @return a new, unacquired WifiLock with the given tag.
     *
     *
     * @see WifiLock
     * @see WifiLock
     *
     * @deprecated This API is non-functional.
     */
     */
    @Deprecated
    public WifiLock createWifiLock(String tag) {
    public WifiLock createWifiLock(String tag) {
        return new WifiLock(WIFI_MODE_FULL, tag);
        return new WifiLock(WIFI_MODE_FULL, tag);
    }
    }



    /**
    /**
     * Create a new MulticastLock
     * Create a new MulticastLock
     *
     *