summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArif Hussain <arifhussain@codeaurora.org>2018-01-16 18:16:32 -0800
committerMichael Bestas <mkbestas@lineageos.org>2021-10-18 14:35:33 +0200
commit0fd222632e10cfbfac8122a477db0139f80c3385 (patch)
tree5c33ff1e558037eaf76dc819999535467b8b7d5c
parent0084b657557fdeb5165afd78ebac6fc1eacb27b4 (diff)
WiFi: Ignore connectivity scans during WFD session
Any scans will impact WiFi performance including WFD performance. So during WFD session, ignore all connectivity scans initiated internally by wifi work source. This change will not impact any scan triggered due to user activity and will allow those scans. Change-Id: I6a855a8c4853a21fb0ff054c6a5155719ee12b3d CRs-Fixed: 2136506
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java4
-rw-r--r--service/java/com/android/server/wifi/WifiConnectivityManager.java22
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java5
3 files changed, 31 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index d6645dfd8..14866c87e 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -3515,6 +3515,10 @@ public class ClientModeImpl extends StateMachine {
mTemporarilyDisconnectWifi = (message.arg1 == 1);
replyToMessage(message, WifiP2pServiceImpl.DISCONNECT_WIFI_RESPONSE);
break;
+ case WifiP2pServiceImpl.SET_MIRACAST_MODE:
+ if (mVerboseLoggingEnabled) logd("SET_MIRACAST_MODE: " + (int)message.arg1);
+ mWifiConnectivityManager.saveMiracastMode((int)message.arg1);
+ break;
/* Link configuration (IP address, DNS, ...) changes notified via netlink */
case CMD_UPDATE_LINKPROPERTIES:
updateLinkProperties((LinkProperties) message.obj);
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java
index 12c64b542..6413f9711 100644
--- a/service/java/com/android/server/wifi/WifiConnectivityManager.java
+++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java
@@ -23,6 +23,7 @@ import android.annotation.NonNull;
import android.app.AlarmManager;
import android.content.Context;
import android.net.MacAddress;
+import android.net.wifi.p2p.WifiP2pManager;
import android.net.wifi.ScanResult;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiConfiguration;
@@ -160,6 +161,7 @@ public class WifiConnectivityManager {
private boolean mAutoJoinEnabled = false; // disabled by default, enabled by external triggers
private boolean mRunning = false;
private boolean mScreenOn = false;
+ private int mMiracastMode = WifiP2pManager.MIRACAST_DISABLED;
private int mWifiState = WIFI_STATE_UNKNOWN;
private int mInitialScanState = INITIAL_SCAN_STATE_COMPLETE;
private boolean mAutoJoinEnabledExternal = true; // enabled by default
@@ -1256,6 +1258,17 @@ public class WifiConnectivityManager {
// Start a single scan
private void startForcedSingleScan(boolean isFullBandScan, WorkSource workSource) {
+ // Any scans will impact wifi performance including WFD performance,
+ // So at least ignore scans triggered internally by ConnectivityManager
+ // when WFD session is active. We still allow connectivity scans initiated
+ // by other work source.
+ if (WIFI_WORK_SOURCE.equals(workSource) &&
+ (mMiracastMode == WifiP2pManager.MIRACAST_SOURCE ||
+ mMiracastMode == WifiP2pManager.MIRACAST_SINK)) {
+ localLog("Ignore connectivity scan, MiracastMode:" + mMiracastMode);
+ return;
+ }
+
mPnoScanListener.resetLowRssiNetworkRetryDelay();
ScanSettings settings = new ScanSettings();
@@ -1596,6 +1609,15 @@ public class WifiConnectivityManager {
}
/**
+ * Save current miracast mode, it will be used to ignore
+ * connectivity scan during the time when miracast is enabled.
+ */
+ public void saveMiracastMode(int mode) {
+ localLog("saveMiracastMode: mode=" + mode);
+ mMiracastMode = mode;
+ }
+
+ /**
* Helper function that converts the WIFI_STATE_XXX constants to string
*/
private static String stateToString(int state) {
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index eb2a89c4e..05b00f4d9 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -706,6 +706,11 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
public void setMiracastMode(int mode) {
checkConfigureWifiDisplayPermission();
mP2pStateMachine.sendMessage(SET_MIRACAST_MODE, mode);
+ if (mWifiChannel != null) {
+ mWifiChannel.sendMessage(WifiP2pServiceImpl.SET_MIRACAST_MODE, mode);
+ } else {
+ Log.e(TAG, "setMiracastMode(): WifiChannel is null");
+ }
}
@Override