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

Commit cdbffa98 authored by Wei Wang's avatar Wei Wang
Browse files

Throttle wifi scan requests from background apps (1/2).

Bug: 37320631

Test: Manual test on Sailfish. Unit tests using runtest.sh.

Change-Id: If7c0206df29aea15089eba335d5b4e82f066eed9
parent 4f3ba1ae
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -7768,6 +7768,21 @@ public final class Settings {
        public static final String LOCATION_BACKGROUND_THROTTLE_PACKAGE_WHITELIST =
            "location_background_throttle_package_whitelist";

        /**
         * The interval in milliseconds at which wifi scan requests will be throttled when they are
         * coming from the background.
         * @hide
         */
        public static final String WIFI_SCAN_BACKGROUND_THROTTLE_INTERVAL_MS =
                "wifi_scan_background_throttle_interval_ms";

        /**
         * Packages that are whitelisted to be exempt for wifi background throttling.
         * @hide
         */
        public static final String WIFI_SCAN_BACKGROUND_THROTTLE_PACKAGE_WHITELIST =
                "wifi_scan_background_throttle_package_whitelist";

        /**
        * Whether TV will switch to MHL port when a mobile device is plugged in.
        * (0 = false, 1 = true)
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ interface IWifiManager

    boolean disableNetwork(int netId);

    void startScan(in ScanSettings requested, in WorkSource ws);
    void startScan(in ScanSettings requested, in WorkSource ws, in String packageName);

    List<ScanResult> getScanResults(String callingPackage);

+3 −7
Original line number Diff line number Diff line
@@ -1428,19 +1428,15 @@ public class WifiManager {
     * @return {@code true} if the operation succeeded, i.e., the scan was initiated
     */
    public boolean startScan() {
        try {
            mService.startScan(null, null);
            return true;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        return startScan(null);
    }

    /** @hide */
    @SystemApi
    public boolean startScan(WorkSource workSource) {
        try {
            mService.startScan(null, workSource);
            String packageName = mContext.getOpPackageName();
            mService.startScan(null, workSource, packageName);
            return true;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();