diff options
author | Randy Pan <zpan@google.com> | 2017-02-03 14:19:24 -0800 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2017-03-28 11:59:22 -0700 |
commit | 17c2a7b30e5680b11fc0073ce322ee7bc14ef2c5 (patch) | |
tree | 1d695f8ab3c33d5e6981ef19eb652e38281875f7 /service | |
parent | ab8c62a5c348702090aceee23de12945cc3fdb0d (diff) |
Local log buffer shared by connectivity modules
Move the creation of the local log buffer for connectivity modules to
WifiInjector. Then pass it over to all the connectivity modules.
Dump the log buffer via WifiConnectivityManager.
While there, removed the null check in localLog() for all the
connectivity modules.
Bug: 35642622
Test: runtest.sh and manual test
Change-Id: I31866c6fecdd9f50061f47e34e16c701ff230a6c
Diffstat (limited to 'service')
6 files changed, 32 insertions, 58 deletions
diff --git a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java index 98cecf170..ff880f510 100644 --- a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java @@ -98,9 +98,7 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat } private void localLog(String log) { - if (mLocalLog != null) { - mLocalLog.log(log); - } + mLocalLog.log(log); } /** diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java index 6e32f9b31..7c38e5def 100644 --- a/service/java/com/android/server/wifi/WifiConnectivityManager.java +++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java @@ -191,9 +191,7 @@ public class WifiConnectivityManager { // A helper to log debugging information in the local log buffer, which can // be retrieved in bugreport. private void localLog(String log) { - if (mLocalLog != null) { - mLocalLog.log(log); - } + mLocalLog.log(log); } // A periodic/PNO scan will be rescheduled up to MAX_SCAN_RESTART_ALLOWED times @@ -499,7 +497,8 @@ public class WifiConnectivityManager { WifiScanner scanner, WifiConfigManager configManager, WifiInfo wifiInfo, WifiNetworkSelector networkSelector, WifiConnectivityHelper connectivityHelper, WifiLastResortWatchdog wifiLastResortWatchdog, WifiMetrics wifiMetrics, - Looper looper, Clock clock, boolean enable, FrameworkFacade frameworkFacade, + Looper looper, Clock clock, LocalLog localLog, boolean enable, + FrameworkFacade frameworkFacade, SavedNetworkEvaluator savedNetworkEvaluator, RecommendedNetworkEvaluator recommendedNetworkEvaluator, PasspointNetworkEvaluator passpointNetworkEvaluator) { @@ -509,7 +508,7 @@ public class WifiConnectivityManager { mWifiInfo = wifiInfo; mNetworkSelector = networkSelector; mConnectivityHelper = connectivityHelper; - mLocalLog = networkSelector.getLocalLog(); + mLocalLog = localLog; mWifiLastResortWatchdog = wifiLastResortWatchdog; mWifiMetrics = wifiMetrics; mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); @@ -1290,11 +1289,11 @@ public class WifiConnectivityManager { /** * Dump the local logs. - * - * Note: this call temporarily calls in to NetworkSelector to dump the LocalLog. This should be - * refactored to dump from WifiConnectivityManager instead. */ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - mNetworkSelector.dump(fd, pw, args); + pw.println("Dump of WifiConnectivityManager"); + pw.println("WifiConnectivityManager - Log Begin ----"); + mLocalLog.dump(fd, pw, args); + pw.println("WifiConnectivityManager - Log End ----"); } } diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index ff5d6e8cd..5fa0ee9ac 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -16,6 +16,7 @@ package com.android.server.wifi; +import android.app.ActivityManager; import android.content.Context; import android.net.NetworkScoreManager; import android.net.wifi.IApInterface; @@ -101,6 +102,7 @@ public class WifiInjector { private final WifiConfigStoreLegacy mWifiConfigStoreLegacy; private final WifiConfigManager mWifiConfigManager; private final WifiConnectivityHelper mWifiConnectivityHelper; + private final LocalLog mConnectivityLocalLog; private final WifiNetworkSelector mWifiNetworkSelector; private final SavedNetworkEvaluator mSavedNetworkEvaluator; private final PasspointNetworkEvaluator mPasspointNetworkEvaluator; @@ -193,18 +195,20 @@ public class WifiInjector { mWifiPermissionsWrapper, new NetworkListStoreData(), new DeletedEphemeralSsidsStoreData()); mWifiConnectivityHelper = new WifiConnectivityHelper(mWifiNative); - mWifiNetworkSelector = new WifiNetworkSelector(mContext, mWifiConfigManager, mClock); - LocalLog localLog = mWifiNetworkSelector.getLocalLog(); + mConnectivityLocalLog = new LocalLog(ActivityManager.isLowRamDeviceStatic() ? 256 : 512); + mWifiNetworkSelector = new WifiNetworkSelector(mContext, mWifiConfigManager, mClock, + mConnectivityLocalLog); mSavedNetworkEvaluator = new SavedNetworkEvaluator(mContext, - mWifiConfigManager, mClock, localLog, wifiStateMachineLooper, mFrameworkFacade); + mWifiConfigManager, mClock, mConnectivityLocalLog, wifiStateMachineLooper, + mFrameworkFacade); mRecommendedNetworkEvaluator = new RecommendedNetworkEvaluator(context, context.getContentResolver(), wifiStateMachineLooper, mFrameworkFacade, - mNetworkScoreManager, mWifiConfigManager, localLog); + mNetworkScoreManager, mWifiConfigManager, mConnectivityLocalLog); mSimAccessor = new SIMAccessor(mContext); mPasspointManager = new PasspointManager(mContext, mWifiNative, mWifiKeyStore, mClock, mSimAccessor, new PasspointObjectFactory(), mWifiConfigManager, mWifiConfigStore); mPasspointNetworkEvaluator = new PasspointNetworkEvaluator( - mPasspointManager, mWifiConfigManager, localLog); + mPasspointManager, mWifiConfigManager, mConnectivityLocalLog); // mWifiStateMachine has an implicit dependency on mJavaRuntime due to WifiDiagnostics. mJavaRuntime = Runtime.getRuntime(); mWifiStateMachine = new WifiStateMachine(mContext, mFrameworkFacade, @@ -393,13 +397,6 @@ public class WifiInjector { } /** - * Obtain an instance of WifiNetworkSelector. - */ - public WifiNetworkSelector getWifiNetworkSelector() { - return mWifiNetworkSelector; - } - - /** * Obtain a new instance of WifiConnectivityManager. * * Create and return a new WifiConnectivityManager. @@ -412,8 +409,8 @@ public class WifiInjector { return new WifiConnectivityManager(mContext, mWifiStateMachine, getWifiScanner(), mWifiConfigManager, wifiInfo, mWifiNetworkSelector, mWifiConnectivityHelper, mWifiLastResortWatchdog, mWifiMetrics, mWifiStateMachineHandlerThread.getLooper(), - mClock, hasConnectionRequests, mFrameworkFacade, mSavedNetworkEvaluator, - mRecommendedNetworkEvaluator, mPasspointNetworkEvaluator); + mClock, mConnectivityLocalLog, hasConnectionRequests, mFrameworkFacade, + mSavedNetworkEvaluator, mRecommendedNetworkEvaluator, mPasspointNetworkEvaluator); } public WifiPermissionsUtil getWifiPermissionsUtil() { diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java index 5b3bc24ed..5b84537ae 100644 --- a/service/java/com/android/server/wifi/WifiNetworkSelector.java +++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java @@ -18,7 +18,6 @@ package com.android.server.wifi; import android.annotation.NonNull; import android.annotation.Nullable; -import android.app.ActivityManager; import android.content.Context; import android.net.NetworkKey; import android.net.wifi.ScanResult; @@ -31,8 +30,6 @@ import android.util.Pair; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; -import java.io.FileDescriptor; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -48,11 +45,9 @@ public class WifiNetworkSelector { @VisibleForTesting public static final int MINIMUM_NETWORK_SELECTION_INTERVAL_MS = 10 * 1000; - private WifiConfigManager mWifiConfigManager; - private Clock mClock; - - private final LocalLog mLocalLog = - new LocalLog(ActivityManager.isLowRamDeviceStatic() ? 256 : 512); + private final WifiConfigManager mWifiConfigManager; + private final Clock mClock; + private final LocalLog mLocalLog; private long mLastNetworkSelectionTimeStamp = INVALID_TIME_STAMP; // Buffer of filtered scan results (Scan results considered by network selection) & associated // WifiConfiguration (if any). @@ -508,9 +503,11 @@ public class WifiNetworkSelector { return true; } - WifiNetworkSelector(Context context, WifiConfigManager configManager, Clock clock) { + WifiNetworkSelector(Context context, WifiConfigManager configManager, Clock clock, + LocalLog localLog) { mWifiConfigManager = configManager; mClock = clock; + mLocalLog = localLog; mThresholdQualifiedRssi24 = context.getResources().getInteger( R.integer.config_wifi_framework_wifi_score_low_rssi_threshold_24GHz); @@ -523,21 +520,4 @@ public class WifiNetworkSelector { mEnableAutoJoinWhenAssociated = context.getResources().getBoolean( R.bool.config_wifi_framework_enable_associated_network_selection); } - - /** - * Retrieve the local log buffer created by WifiNetworkSelector. - */ - public LocalLog getLocalLog() { - return mLocalLog; - } - - /** - * Dump the local logs. - */ - public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - pw.println("Dump of WifiNetworkSelector"); - pw.println("WifiNetworkSelector - Log Begin ----"); - mLocalLog.dump(fd, pw, args); - pw.println("WifiNetworkSelector - Log End ----"); - } } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 1e94f8e47..d6ef5e870 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -205,7 +205,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private WifiPermissionsUtil mWifiPermissionsUtil; private WifiConfigManager mWifiConfigManager; private WifiConnectivityManager mWifiConnectivityManager; - private WifiNetworkSelector mWifiNetworkSelector; private INetworkManagementService mNwService; private IClientInterface mClientInterface; private ConnectivityManager mCm; @@ -903,7 +902,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mWifiDiagnostics = mWifiInjector.makeWifiDiagnostics(mWifiNative); mWifiInfo = new WifiInfo(); - mWifiNetworkSelector = mWifiInjector.getWifiNetworkSelector(); mSupplicantStateTracker = mFacade.makeSupplicantStateTracker(context, mWifiConfigManager, getHandler()); @@ -2159,7 +2157,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mWifiDiagnostics.captureBugReportData(WifiDiagnostics.REPORT_REASON_USER_ACTION); mWifiDiagnostics.dump(fd, pw, args); dumpIpManager(fd, pw, args); - mWifiNetworkSelector.dump(fd, pw, args); + if (mWifiConnectivityManager != null) { + mWifiConnectivityManager.dump(fd, pw, args); + } else { + pw.println("mWifiConnectivityManager is not initialized"); + } } public void handleUserSwitch(int userId) { diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java index 3baf5c6da..1bade6c52 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java @@ -172,8 +172,6 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva } private void localLog(String log) { - if (mLocalLog != null) { - mLocalLog.log(log); - } + mLocalLog.log(log); } } |