diff options
author | Roshan Pius <rpius@google.com> | 2020-04-17 06:09:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-04-17 06:09:49 +0000 |
commit | bba642c3276f19f5456b61aa8cf400b35f7f0d0f (patch) | |
tree | 2d96ef196ae3f4cbcbe597de793ae0144db59801 /service | |
parent | 2cdbd0860a83e252ea3b0da27cf4d5d0e86d50d7 (diff) | |
parent | a041df63c050ceb4b6abccd9971dc6e9555a1633 (diff) |
Merge changes Ieddb7057,Ibaa31858 into rvc-dev
* changes:
ClientModeImpl: Remove call to setScanningMacOui
WifiShellCommand: Add a command for score update/reset external scorer
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/ClientModeImpl.java | 16 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiNative.java | 13 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiShellCommand.java | 68 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiVendorHal.java | 27 | ||||
-rw-r--r-- | service/res/values/config.xml | 2 | ||||
-rw-r--r-- | service/res/values/overlayable.xml | 1 |
6 files changed, 68 insertions, 59 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java index 99fa7f585..9b2c0dc04 100644 --- a/service/java/com/android/server/wifi/ClientModeImpl.java +++ b/service/java/com/android/server/wifi/ClientModeImpl.java @@ -1197,21 +1197,6 @@ public class ClientModeImpl extends StateMachine { mWifiDataStall.enableVerboseLogging(mVerboseLoggingEnabled); } - private boolean setRandomMacOui() { - String oui = mContext.getResources().getString(R.string.config_wifi_random_mac_oui); - if (TextUtils.isEmpty(oui)) { - oui = GOOGLE_OUI; - } - String[] ouiParts = oui.split("-"); - byte[] ouiBytes = new byte[3]; - ouiBytes[0] = (byte) (Integer.parseInt(ouiParts[0], 16) & 0xFF); - ouiBytes[1] = (byte) (Integer.parseInt(ouiParts[1], 16) & 0xFF); - ouiBytes[2] = (byte) (Integer.parseInt(ouiParts[2], 16) & 0xFF); - - logd("Setting OUI to " + oui); - return mWifiNative.setScanningMacOui(mInterfaceName, ouiBytes); - } - /** * Initiates connection to a network specified by the user/app. This method checks if the * requesting app holds the NETWORK_SETTINGS permission. @@ -3561,7 +3546,6 @@ public class ClientModeImpl extends StateMachine { mWifiNative.setExternalSim(mInterfaceName, true); - setRandomMacOui(); mCountryCode.setReadyForChange(true); mWifiDiagnostics.startPktFateMonitoring(mInterfaceName); diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index fa1295dd2..20701ca6a 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -2911,19 +2911,6 @@ public class WifiNative { } /** - * Set the MAC OUI during scanning. - * An OUI {Organizationally Unique Identifier} is a 24-bit number that - * uniquely identifies a vendor or manufacturer. - * - * @param ifaceName Name of the interface. - * @param oui OUI to set. - * @return true for success - */ - public boolean setScanningMacOui(@NonNull String ifaceName, byte[] oui) { - return mWifiVendorHal.setScanningMacOui(ifaceName, oui); - } - - /** * Get the APF (Android Packet Filter) capabilities of the device * @param ifaceName Name of the interface. */ diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java index 6af4e8dd3..7706967a1 100644 --- a/service/java/com/android/server/wifi/WifiShellCommand.java +++ b/service/java/com/android/server/wifi/WifiShellCommand.java @@ -29,6 +29,8 @@ import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkRequest; import android.net.wifi.IActionListener; +import android.net.wifi.IScoreUpdateObserver; +import android.net.wifi.IWifiConnectedNetworkScorer; import android.net.wifi.ScanResult; import android.net.wifi.SoftApConfiguration; import android.net.wifi.SupplicantState; @@ -48,6 +50,7 @@ import android.util.Pair; import com.android.server.wifi.util.ApConfigUtil; import com.android.server.wifi.util.ArrayUtils; +import com.android.server.wifi.util.GeneralUtil; import com.android.server.wifi.util.ScanResultUtil; import java.io.PrintWriter; @@ -90,6 +93,8 @@ public class WifiShellCommand extends BasicShellCommandHandler { "list-suggestions", "remove-suggestion", "remove-all-suggestions", + "reset-connected-score", + "set-connected-score", "set-scan-always-available", "set-verbose-logging", "set-wifi-enabled", @@ -609,6 +614,58 @@ public class WifiShellCommand extends BasicShellCommandHandler { pw.println(hasUserApproved ? "yes" : "no"); return 0; } + case "set-connected-score": { + int score = Integer.parseInt(getNextArgRequired()); + CountDownLatch countDownLatch = new CountDownLatch(2); + GeneralUtil.Mutable<IScoreUpdateObserver> scoreUpdateObserverMutable = + new GeneralUtil.Mutable<>(); + GeneralUtil.Mutable<Integer> sessionIdMutable = new GeneralUtil.Mutable<>(); + IWifiConnectedNetworkScorer.Stub connectedScorer = + new IWifiConnectedNetworkScorer.Stub() { + @Override + public void onStart(int sessionId) { + sessionIdMutable.value = sessionId; + countDownLatch.countDown(); + } + @Override + public void onStop(int sessionId) { + // clear the external scorer on disconnect. + mWifiService.clearWifiConnectedNetworkScorer(); + } + @Override + public void onSetScoreUpdateObserver(IScoreUpdateObserver observerImpl) { + scoreUpdateObserverMutable.value = observerImpl; + countDownLatch.countDown(); + } + }; + mWifiService.clearWifiConnectedNetworkScorer(); // clear any previous scorer + if (mWifiService.setWifiConnectedNetworkScorer(new Binder(), connectedScorer)) { + // wait for retrieving the session id & score observer. + countDownLatch.await(1000, TimeUnit.MILLISECONDS); + } + if (scoreUpdateObserverMutable.value == null + || sessionIdMutable.value == null) { + pw.println("Did not receive session id and/or the score update observer. " + + "Is the device connected to a wifi network?"); + mWifiService.clearWifiConnectedNetworkScorer(); + return -1; + } + pw.println("Updating score: " + score + " for session id: " + + sessionIdMutable.value); + try { + scoreUpdateObserverMutable.value.notifyScoreUpdate( + sessionIdMutable.value, score); + } catch (RemoteException e) { + pw.println("Failed to send the score update"); + mWifiService.clearWifiConnectedNetworkScorer(); + return -1; + } + return 0; + } + case "reset-connected-score": { + mWifiService.clearWifiConnectedNetworkScorer(); // clear any previous scorer + return 0; + } default: return handleDefaultCommands(cmd); } @@ -873,6 +930,17 @@ public class WifiShellCommand extends BasicShellCommandHandler { pw.println(" Removes all suggestions added via shell"); pw.println(" list-suggestions"); pw.println(" Lists the suggested networks added via shell"); + pw.println(" set-connected-score <score>"); + pw.println(" Set connected wifi network score (to choose between LTE & Wifi for " + + "default route)."); + pw.println(" This turns off the active connected scorer (default or external)."); + pw.println(" Only works while connected to a wifi network. This score will stay in " + + "effect until you call reset-connected-score or the device disconnects from the " + + "current network."); + pw.println(" <score> - Integer score should be in the range of 0 - 60"); + pw.println(" reset-connected-score"); + pw.println(" Turns on the default connected scorer."); + pw.println(" Note: Will clear any external scorer set."); } private void onHelpPrivileged(PrintWriter pw) { diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index f01f9a94c..d85d535fa 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -1299,33 +1299,6 @@ public class WifiVendorHal { } /** - * Set the MAC OUI during scanning. - * <p> - * An OUI {Organizationally Unique Identifier} is a 24-bit number that - * uniquely identifies a vendor or manufacturer. - * - * @param ifaceName Name of the interface. - * @param oui - * @return true for success - */ - public boolean setScanningMacOui(@NonNull String ifaceName, byte[] oui) { - if (oui == null) return boolResult(false); - if (oui.length != 3) return boolResult(false); - synchronized (sLock) { - try { - IWifiStaIface iface = getStaIface(ifaceName); - if (iface == null) return boolResult(false); - WifiStatus status = iface.setScanningMacOui(oui); - if (!ok(status)) return false; - return true; - } catch (RemoteException e) { - handleRemoteException(e); - return false; - } - } - } - - /** * Set Mac address on the given interface * * @param ifaceName Name of the interface diff --git a/service/res/values/config.xml b/service/res/values/config.xml index 0c88a258b..c58ab196b 100644 --- a/service/res/values/config.xml +++ b/service/res/values/config.xml @@ -137,8 +137,6 @@ <!-- Integer indicating maximum hardware supported client number of soft ap --> <integer translatable="false" name="config_wifiHardwareSoftapMaxClientCount">16</integer> - <string translatable="false" name="config_wifi_random_mac_oui">DA-A1-19</string> - <!-- List of allowed channels in 2GHz band for softap. If the device doesn't want to restrict channels this should be empty. Values is a comma separated channel string and/or channel range string like '1-6,11'. --> diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml index 06ae35b8c..687b6b9e8 100644 --- a/service/res/values/overlayable.xml +++ b/service/res/values/overlayable.xml @@ -57,7 +57,6 @@ <item type="integer" name="config_wifiFrameworkScoreLowRssiThreshold6ghz" /> <item type="integer" name="config_wifiFrameworkScoreGoodRssiThreshold6ghz" /> <item type="integer" name="config_wifiFrameworkSoftApShutDownTimeoutMilliseconds" /> - <item type="string" name="config_wifi_random_mac_oui" /> <item type="string" name="config_wifiSoftap2gChannelList" /> <item type="string" name="config_wifiSoftap5gChannelList" /> <item type="string" name="config_wifiSoftap6gChannelList" /> |