diff options
author | Jong Wook Kim <jongwook@google.com> | 2018-03-13 12:55:16 -0700 |
---|---|---|
committer | Jong Wook Kim <jongwook@google.com> | 2018-03-21 11:47:08 -0700 |
commit | f927e3cdb59e8809991a5924c8ec82f15e0f52c9 (patch) | |
tree | 12df5f9cd5e24760a254c9d958acbcb42e7a8b2f /service | |
parent | b7d6d452cc79e33208aef9b26b2aee31a99c85f7 (diff) |
Send "02:00:00:00:00:00" as device MAC when not connected
When Connected MAC Randomization is on and the device is disconnected,
we don't have a valid MAC address to show since we don't know what the
next MAC address is going to be. So instead of showing the MAC address
used during the previous connection, WifiInfo should return the default
MAC address "02:00:00:00:00:00".
In this change, the device resets MAC address stored in WifiInfo to the
default MAC address whenever it gets disconnected with Connected MAC
Randomization on.
Bug: 74436251
Test: Unittest
Change-Id: Ibc1027559a9d5abead2a764b5e94672498d4f7b4
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/ExtendedWifiInfo.java | 12 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 29 |
2 files changed, 31 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/ExtendedWifiInfo.java b/service/java/com/android/server/wifi/ExtendedWifiInfo.java index 5edbd34e8..6b7ae5ab6 100644 --- a/service/java/com/android/server/wifi/ExtendedWifiInfo.java +++ b/service/java/com/android/server/wifi/ExtendedWifiInfo.java @@ -26,11 +26,15 @@ public class ExtendedWifiInfo extends WifiInfo { private static final double FILTER_TIME_CONSTANT = 3000.0; private long mLastPacketCountUpdateTimeStamp = RESET_TIME_STAMP; + private boolean mEnableConnectedMacRandomization = false; @Override public void reset() { super.reset(); mLastPacketCountUpdateTimeStamp = RESET_TIME_STAMP; + if (mEnableConnectedMacRandomization) { + setMacAddress(DEFAULT_MAC_ADDRESS); + } } /** @@ -119,5 +123,13 @@ public class ExtendedWifiInfo extends WifiInfo { rxSuccess = rxPackets; } + /** + * Updates whether Connected MAC Randomization is enabled. + * + * @hide + */ + public void setEnableConnectedMacRandomization(boolean enableConnectedMacRandomization) { + mEnableConnectedMacRandomization = enableConnectedMacRandomization; + } } diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index a60ea13c7..38c2cd428 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -902,12 +902,6 @@ public class WifiStateMachine extends StateMachine { mWifiScoreReport = new WifiScoreReport(mContext, mClock); - mUserWantsSuspendOpt.set(mFacade.getIntegerSetting(mContext, - Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1); - - mEnableConnectedMacRandomization.set(mFacade.getIntegerSetting(mContext, - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0) == 1); - mNetworkCapabilitiesFilter.addTransportType(NetworkCapabilities.TRANSPORT_WIFI); mNetworkCapabilitiesFilter.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); mNetworkCapabilitiesFilter.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); @@ -951,10 +945,7 @@ public class WifiStateMachine extends StateMachine { new ContentObserver(getHandler()) { @Override public void onChange(boolean selfChange) { - mEnableConnectedMacRandomization.set(mFacade.getIntegerSetting(mContext, - Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0) == 1); - Log.i(TAG, "EnableConnectedMacRandomization Setting changed to " - + mEnableConnectedMacRandomization); + updateConnectedMacRandomizationSetting(); } }); @@ -967,6 +958,11 @@ public class WifiStateMachine extends StateMachine { }, new IntentFilter(Intent.ACTION_LOCKED_BOOT_COMPLETED)); + mUserWantsSuspendOpt.set(mFacade.getIntegerSetting(mContext, + Settings.Global.WIFI_SUSPEND_OPTIMIZATIONS_ENABLED, 1) == 1); + + updateConnectedMacRandomizationSetting(); + PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getName()); @@ -3380,6 +3376,19 @@ public class WifiStateMachine extends StateMachine { } } + /** + * Update whether Connected MAC Randomization is enabled in WifiStateMachine + * and WifiInfo. + */ + private void updateConnectedMacRandomizationSetting() { + int macRandomizationFlag = mFacade.getIntegerSetting( + mContext, Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, 0); + boolean macRandomizationEnabled = (macRandomizationFlag == 1); + mEnableConnectedMacRandomization.set(macRandomizationEnabled); + mWifiInfo.setEnableConnectedMacRandomization(macRandomizationEnabled); + Log.d(TAG, "EnableConnectedMacRandomization Setting changed to " + + macRandomizationEnabled); + } /******************************************************** * HSM states |