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

Commit ed9f9f25 authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android Git Automerger
Browse files

am caef59af: am 5bc09e26: Merge "Disable notification scans when p2p is connected" into jb-mr1-dev

* commit 'caef59af':
  Disable notification scans when p2p is connected
parents ff4dccbe caef59af
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -5613,6 +5613,13 @@ public final class Settings {
       public static final String WIFI_SUPPLICANT_SCAN_INTERVAL_MS =
               "wifi_supplicant_scan_interval_ms";

       /**
        * The interval in milliseconds to scan at supplicant when p2p is connected
        * @hide
        */
       public static final String WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS =
               "wifi_scan_interval_p2p_connected_ms";

       /**
        * Whether the Wi-Fi watchdog is enabled.
        */
+3 −0
Original line number Diff line number Diff line
@@ -292,6 +292,9 @@
    <!-- Integer indicating wpa_supplicant scan interval in milliseconds -->
    <integer translatable="false" name="config_wifi_supplicant_scan_interval">15000</integer>

    <!-- Integer indicating wpa_supplicant scan interval when p2p is connected in milliseconds -->
    <integer translatable="false" name="config_wifi_scan_interval_p2p_connected">60000</integer>

    <!-- Integer indicating the framework scan interval in milliseconds. This is used in the scenario
         where the chipset does not support background scanning (config_wifi_background_scan_suport
         is false) to set up a periodic wake up scan so that the device can connect to a new access
+1 −0
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@
  <java-symbol type="integer" name="config_ntpTimeout" />
  <java-symbol type="integer" name="config_wifi_framework_scan_interval" />
  <java-symbol type="integer" name="config_wifi_supplicant_scan_interval" />
  <java-symbol type="integer" name="config_wifi_scan_interval_p2p_connected" />
  <java-symbol type="integer" name="db_connection_pool_size" />
  <java-symbol type="integer" name="db_journal_size_limit" />
  <java-symbol type="integer" name="db_wal_autocheckpoint" />
+28 −6
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ import android.util.EventLog;
import android.util.Log;
import android.util.LruCache;

import com.android.internal.R;
import com.android.internal.app.IBatteryStats;
import com.android.internal.util.AsyncChannel;
import com.android.internal.util.Protocol;
@@ -112,6 +113,7 @@ public class WifiStateMachine extends StateMachine {
    private ConnectivityManager mCm;

    private final boolean mP2pSupported;
    private final AtomicBoolean mP2pConnected = new AtomicBoolean(false);
    private final String mPrimaryDeviceType;

    /* Scan results handling */
@@ -595,16 +597,16 @@ public class WifiStateMachine extends StateMachine {
        mScanIntent = PendingIntent.getBroadcast(mContext, SCAN_REQUEST, scanIntent, 0);

        mDefaultFrameworkScanIntervalMs = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_wifi_framework_scan_interval);
                R.integer.config_wifi_framework_scan_interval);

        mDriverStopDelayMs = mContext.getResources().getInteger(
                com.android.internal.R.integer.config_wifi_driver_stop_delay);
                R.integer.config_wifi_driver_stop_delay);

        mBackgroundScanSupported = mContext.getResources().getBoolean(
                com.android.internal.R.bool.config_wifi_background_scan_support);
                R.bool.config_wifi_background_scan_support);

        mPrimaryDeviceType = mContext.getResources().getString(
                com.android.internal.R.string.config_wifi_p2p_device_type);
                R.string.config_wifi_p2p_device_type);

        mUserWantsSuspendOpt.set(Settings.Secure.getInt(mContext.getContentResolver(),
                    Settings.Secure.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1);
@@ -2011,6 +2013,10 @@ public class WifiStateMachine extends StateMachine {
                    replyToMessage(message, WifiManager.RSSI_PKTCNT_FETCH_FAILED,
                            WifiManager.BUSY);
                    break;
                case WifiP2pService.P2P_CONNECTION_CHANGED:
                    NetworkInfo info = (NetworkInfo) message.obj;
                    mP2pConnected.set(info.isConnected());
                    break;
                default:
                    loge("Error! unhandled message" + message);
                    break;
@@ -2408,7 +2414,7 @@ public class WifiStateMachine extends StateMachine {
            mNetworkInfo.setIsAvailable(true);

            int defaultInterval = mContext.getResources().getInteger(
                    com.android.internal.R.integer.config_wifi_supplicant_scan_interval);
                    R.integer.config_wifi_supplicant_scan_interval);

            mSupplicantScanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
                    Settings.Global.WIFI_SUPPLICANT_SCAN_INTERVAL_MS,
@@ -3486,7 +3492,7 @@ public class WifiStateMachine extends StateMachine {
             * The scans are useful to notify the user of the presence of an open network.
             * Note that these are not wake up scans.
             */
            if (mWifiConfigStore.getConfiguredNetworks().size() == 0) {
            if (!mP2pConnected.get() && mWifiConfigStore.getConfiguredNetworks().size() == 0) {
                sendMessageDelayed(obtainMessage(CMD_NO_NETWORKS_PERIODIC_SCAN,
                            ++mPeriodicScanToken, 0), mSupplicantScanIntervalMs);
            }
@@ -3497,6 +3503,7 @@ public class WifiStateMachine extends StateMachine {
            boolean ret = HANDLED;
            switch (message.what) {
                case CMD_NO_NETWORKS_PERIODIC_SCAN:
                    if (mP2pConnected.get()) break;
                    if (message.arg1 == mPeriodicScanToken &&
                            mWifiConfigStore.getConfiguredNetworks().size() == 0) {
                        sendMessage(CMD_START_SCAN);
@@ -3557,6 +3564,21 @@ public class WifiStateMachine extends StateMachine {
                    /* Handled in parent state */
                    ret = NOT_HANDLED;
                    break;
                case WifiP2pService.P2P_CONNECTION_CHANGED:
                    NetworkInfo info = (NetworkInfo) message.obj;
                    mP2pConnected.set(info.isConnected());
                    if (mP2pConnected.get()) {
                        int defaultInterval = mContext.getResources().getInteger(
                                R.integer.config_wifi_scan_interval_p2p_connected);
                        long scanIntervalMs = Settings.Global.getLong(mContext.getContentResolver(),
                                Settings.Global.WIFI_SCAN_INTERVAL_WHEN_P2P_CONNECTED_MS,
                                defaultInterval);
                        mWifiNative.setScanInterval((int) scanIntervalMs/1000);
                    } else if (mWifiConfigStore.getConfiguredNetworks().size() == 0) {
                        if (DBG) log("Turn on scanning after p2p disconnected");
                        sendMessageDelayed(obtainMessage(CMD_NO_NETWORKS_PERIODIC_SCAN,
                                    ++mPeriodicScanToken, 0), mSupplicantScanIntervalMs);
                    }
                default:
                    ret = NOT_HANDLED;
            }
+5 −12
Original line number Diff line number Diff line
@@ -137,18 +137,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
    /* Idle time after a peer is gone when the group is torn down */
    private static final int GROUP_IDLE_TIME_S = 5;

    /**
     * Delay between restarts upon failure to setup connection with supplicant
     */
    private static final int P2P_RESTART_INTERVAL_MSECS = 5000;

    /**
     * Number of times we attempt to restart p2p
     */
    private static final int P2P_RESTART_TRIES = 5;

    private int mP2pRestartCount = 0;

    private static final int BASE = Protocol.BASE_WIFI_P2P_SERVICE;

    /* Delayed message to timeout group creation */
@@ -159,6 +147,9 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
    /* User rejected a peer request */
    private static final int PEER_CONNECTION_USER_REJECT    =   BASE + 3;

    /* Commands to the WifiStateMachine */
    public static final int P2P_CONNECTION_CHANGED         =   BASE + 11;

    private final boolean mP2pSupported;

    private WifiP2pDevice mThisDevice = new WifiP2pDevice();
@@ -1597,6 +1588,8 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
        intent.putExtra(WifiP2pManager.EXTRA_WIFI_P2P_INFO, new WifiP2pInfo(mWifiP2pInfo));
        intent.putExtra(WifiP2pManager.EXTRA_NETWORK_INFO, new NetworkInfo(mNetworkInfo));
        mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
        mWifiChannel.sendMessage(WifiP2pService.P2P_CONNECTION_CHANGED,
                new NetworkInfo(mNetworkInfo));
    }

    private void sendP2pPersistentGroupsChangedBroadcast() {