diff options
Diffstat (limited to 'service')
3 files changed, 26 insertions, 9 deletions
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java index 5210adcaa..0576ba566 100644 --- a/service/java/com/android/server/wifi/WifiConnectivityManager.java +++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java @@ -465,19 +465,19 @@ public class WifiConnectivityManager { */ WifiConnectivityManager(Context context, WifiStateMachine stateMachine, WifiScanner scanner, WifiConfigManager configManager, WifiInfo wifiInfo, - WifiNetworkSelector networkSelector, WifiInjector wifiInjector, Looper looper, - boolean enable) { + WifiNetworkSelector networkSelector, WifiLastResortWatchdog wifiLastResortWatchdog, + WifiMetrics wifiMetrics, Looper looper, Clock clock, boolean enable) { mStateMachine = stateMachine; mScanner = scanner; mConfigManager = configManager; mWifiInfo = wifiInfo; mNetworkSelector = networkSelector; mLocalLog = networkSelector.getLocalLog(); - mWifiLastResortWatchdog = wifiInjector.getWifiLastResortWatchdog(); - mWifiMetrics = wifiInjector.getWifiMetrics(); + mWifiLastResortWatchdog = wifiLastResortWatchdog; + mWifiMetrics = wifiMetrics; mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mEventHandler = new Handler(looper); - mClock = wifiInjector.getClock(); + mClock = clock; mConnectionAttemptTimeStamps = new LinkedList<>(); mMin5GHzRssi = context.getResources().getInteger( diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index bfe6446af..63787dfb0 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -21,6 +21,7 @@ import android.net.wifi.IApInterface; import android.net.wifi.IWifiScanner; import android.net.wifi.IWificond; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiInfo; import android.net.wifi.WifiScanner; import android.os.HandlerThread; import android.os.IBinder; @@ -358,6 +359,23 @@ public class WifiInjector { return mWifiNetworkSelector; } + /** + * Obtain a new instance of WifiConnectivityManager. + * + * Create and return a new WifiConnectivityManager. + * @param wifiInfo WifiInfo object for updating wifi state. + * @param hasConnectionRequests boolean indicating if WifiConnectivityManager to start + * immediately based on connection requests. + */ + public WifiConnectivityManager makeWifiConnectivityManager(WifiInfo wifiInfo, + boolean hasConnectionRequests) { + return new WifiConnectivityManager(mContext, mWifiStateMachine, getWifiScanner(), + mWifiConfigManager, wifiInfo, mWifiNetworkSelector, + mWifiLastResortWatchdog, mWifiMetrics, + mWifiStateMachineHandlerThread.getLooper(), mClock, + hasConnectionRequests); + } + public WifiPermissionsUtil getWifiPermissionsUtil() { return mWifiPermissionsUtil; } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 42ab9d1f2..612a4aa2e 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4137,10 +4137,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mWifiScanner = mWifiInjector.getWifiScanner(); synchronized (mWifiReqCountLock) { - mWifiConnectivityManager = new WifiConnectivityManager(mContext, - WifiStateMachine.this, mWifiScanner, mWifiConfigManager, mWifiInfo, - mWifiNetworkSelector, mWifiInjector, - getHandler().getLooper(), hasConnectionRequests()); + mWifiConnectivityManager = + mWifiInjector.makeWifiConnectivityManager(mWifiInfo, + hasConnectionRequests()); mWifiConnectivityManager.setUntrustedConnectionAllowed(mUntrustedReqCount > 0); mWifiConnectivityManager.handleScreenStateChanged(mScreenOn); } |