summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Tan <samueltan@google.com>2016-04-11 17:06:42 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-11 17:06:43 +0000
commita88d1b207c401c4510e635156442973a8e30ac95 (patch)
tree8fd6e5624e7d8b69ce6f8d61268e42de24403063
parente78a18cf874b4d9bb5db2ef7804b8ac576e56489 (diff)
parentac69b83c9cafb9a839b578c3b5b71eb3439244ad (diff)
Merge changes I468f7425,I649dca1b,Ic7f97157,I06a8be88 into nyc-dev
* changes: WifiConfigManager: remove WifiStateMachine field Move wnmFrameReceived() from WifiConfigManager to WifiStateMachine Move mActiveScanDetail from WifiStateMachine to WifiConfigManager Remove getCurrentUserId() and getCurrentUserProfiles() from ...WifiStateMachine
-rw-r--r--service/java/com/android/server/wifi/FrameworkFacade.java7
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java74
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java94
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java15
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java16
5 files changed, 104 insertions, 102 deletions
diff --git a/service/java/com/android/server/wifi/FrameworkFacade.java b/service/java/com/android/server/wifi/FrameworkFacade.java
index 13d2965c0..e60732651 100644
--- a/service/java/com/android/server/wifi/FrameworkFacade.java
+++ b/service/java/com/android/server/wifi/FrameworkFacade.java
@@ -120,11 +120,10 @@ public class FrameworkFacade {
return AppGlobals.getPackageManager().checkUidPermission(permName, uid);
}
- public WifiConfigManager makeWifiConfigManager(Context context,
- WifiStateMachine wifiStateMachine, WifiNative wifiNative,
+ public WifiConfigManager makeWifiConfigManager(Context context, WifiNative wifiNative,
FrameworkFacade frameworkFacade, Clock clock, UserManager userManager,
KeyStore keyStore) {
- return new WifiConfigManager(context, wifiStateMachine, wifiNative, frameworkFacade, clock,
- userManager, keyStore);
+ return new WifiConfigManager(context, wifiNative, frameworkFacade, clock, userManager,
+ keyStore);
}
}
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 27180b848..0df099fb5 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -25,6 +25,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
import android.net.IpConfiguration;
import android.net.IpConfiguration.IpAssignment;
import android.net.IpConfiguration.ProxySettings;
@@ -300,13 +301,14 @@ public class WifiConfigManager {
private final PasspointManagementObjectManager mMOManager;
private final boolean mEnableOsuQueries;
private final SIMAccessor mSIMAccessor;
+ private final UserManager mUserManager;
- private WifiStateMachine mWifiStateMachine;
private FrameworkFacade mFacade;
private Clock mClock;
private boolean mOnlyLinkSameCredentialConfigurations;
private IpConfigStore mIpconfigStore;
private DelayedDiskWrite mWriter;
+ private int mCurrentUserId = UserHandle.USER_SYSTEM;
/* A network id is a unique identifier for a network configured in the
* supplicant. Network ids are generated when the supplicant reads
@@ -348,6 +350,8 @@ public class WifiConfigManager {
*/
private HashSet<String> mLostConfigsDbg = new HashSet<String>();
+ private ScanDetail mActiveScanDetail; // ScanDetail associated with active network
+ private final Object mActiveScanDetailLock = new Object();
private class SupplicantBridgeCallbacks implements SupplicantBridge.SupplicantBridgeCallbacks {
@Override
@@ -375,13 +379,13 @@ public class WifiConfigManager {
}
- WifiConfigManager(Context context, WifiStateMachine wifiStateMachine, WifiNative wifiNative,
- FrameworkFacade facade, Clock clock, UserManager userManager, KeyStore keyStore) {
+ WifiConfigManager(Context context, WifiNative wifiNative, FrameworkFacade facade, Clock clock,
+ UserManager userManager, KeyStore keyStore) {
mContext = context;
mFacade = facade;
mClock = clock;
- mWifiStateMachine = wifiStateMachine;
mKeyStore = keyStore;
+ mUserManager = userManager;
if (mShowNetworks) {
mLocalLog = wifiNative.getLocalLog();
@@ -777,7 +781,7 @@ public class WifiConfigManager {
if (sVDBG) localLogNetwork("selectNetwork", config.networkId);
if (config.networkId == INVALID_NETWORK_ID) return false;
if (!WifiConfigurationUtil.isVisibleToAnyProfile(config,
- mWifiStateMachine.getCurrentUserProfiles())) {
+ mUserManager.getProfiles(mCurrentUserId))) {
loge("selectNetwork " + Integer.toString(config.networkId) + ": Network config is not "
+ "visible to current user.");
return false;
@@ -849,7 +853,7 @@ public class WifiConfigManager {
}
if (!WifiConfigurationUtil.isVisibleToAnyProfile(config,
- mWifiStateMachine.getCurrentUserProfiles())) {
+ mUserManager.getProfiles(mCurrentUserId))) {
return new NetworkUpdateResult(INVALID_NETWORK_ID);
}
@@ -1000,7 +1004,7 @@ public class WifiConfigManager {
*/
int addOrUpdateNetwork(WifiConfiguration config, int uid) {
if (config == null || !WifiConfigurationUtil.isVisibleToAnyProfile(config,
- mWifiStateMachine.getCurrentUserProfiles())) {
+ mUserManager.getProfiles(mCurrentUserId))) {
return WifiConfiguration.INVALID_NETWORK_ID;
}
@@ -1049,7 +1053,10 @@ public class WifiConfigManager {
}
public int matchProviderWithCurrentNetwork(String fqdn) {
- ScanDetail scanDetail = mWifiStateMachine.getActiveScanDetail();
+ ScanDetail scanDetail = null;
+ synchronized (mActiveScanDetailLock) {
+ scanDetail = mActiveScanDetail;
+ }
if (scanDetail == null) {
return PasspointMatch.None.ordinal();
}
@@ -2271,7 +2278,7 @@ public class WifiConfigManager {
*/
public void linkConfiguration(WifiConfiguration config) {
if (!WifiConfigurationUtil.isVisibleToAnyProfile(config,
- mWifiStateMachine.getCurrentUserProfiles())) {
+ mUserManager.getProfiles(mCurrentUserId))) {
loge("linkConfiguration: Attempting to link config " + config.configKey()
+ " that is not visible to the current user.");
return;
@@ -2566,30 +2573,6 @@ public class WifiConfigManager {
}
- public void wnmFrameReceived(WnmData event) {
- // %012x HS20-SUBSCRIPTION-REMEDIATION "%u %s", osu_method, url
- // %012x HS20-DEAUTH-IMMINENT-NOTICE "%u %u %s", code, reauth_delay, url
-
- Intent intent = new Intent(WifiManager.PASSPOINT_WNM_FRAME_RECEIVED_ACTION);
- intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
-
- intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_BSSID, event.getBssid());
- intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_URL, event.getUrl());
-
- if (event.isDeauthEvent()) {
- intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_ESS, event.isEss());
- intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_DELAY, event.getDelay());
- } else {
- intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_METHOD, event.getMethod());
- WifiConfiguration config = mWifiStateMachine.getCurrentWifiConfiguration();
- if (config != null && config.FQDN != null) {
- intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_PPOINT_MATCH,
- matchProviderWithCurrentNetwork(config.FQDN));
- }
- }
- mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
- }
-
private void updateAnqpCache(ScanDetail scanDetail,
Map<Constants.ANQPElementType, ANQPElement> anqpElements) {
NetworkDetail networkDetail = scanDetail.getNetworkDetail();
@@ -2795,10 +2778,13 @@ public class WifiConfigManager {
* - Disables private network configurations belonging to the previous foreground user
* - Enables private network configurations belonging to the new foreground user
*
+ * @param userId The identifier of the new foreground user, after the switch.
+ *
* TODO(b/26785736): Terminate background users if the new foreground user has one or more
* private network configurations.
*/
- public void handleUserSwitch() {
+ public void handleUserSwitch(int userId) {
+ mCurrentUserId = userId;
Set<WifiConfiguration> ephemeralConfigs = new HashSet<>();
for (WifiConfiguration config : mConfiguredNetworks.valuesForCurrentUser()) {
if (config.ephemeral) {
@@ -2814,7 +2800,7 @@ public class WifiConfigManager {
}
final List<WifiConfiguration> hiddenConfigurations =
- mConfiguredNetworks.handleUserSwitch(mWifiStateMachine.getCurrentUserId());
+ mConfiguredNetworks.handleUserSwitch(mCurrentUserId);
for (WifiConfiguration network : hiddenConfigurations) {
disableNetworkNative(network);
}
@@ -2827,6 +2813,18 @@ public class WifiConfigManager {
sendConfiguredNetworksChangedBroadcast();
}
+ public int getCurrentUserId() {
+ return mCurrentUserId;
+ }
+
+ public boolean isCurrentUserProfile(int userId) {
+ if (userId == mCurrentUserId) {
+ return true;
+ }
+ final UserInfo parent = mUserManager.getProfileParent(userId);
+ return parent != null && parent.id == mCurrentUserId;
+ }
+
/* Compare current and new configuration and write to file on change */
private NetworkUpdateResult writeIpAndProxyConfigurationsOnChange(
WifiConfiguration currentConfig,
@@ -3291,4 +3289,10 @@ public class WifiConfigManager {
public void enableAutoJoinWhenAssociated(boolean enabled) {
mEnableAutoJoinWhenAssociated.set(enabled);
}
+
+ public void setActiveScanDetail(ScanDetail activeScanDetail) {
+ synchronized (mActiveScanDetailLock) {
+ mActiveScanDetail = activeScanDetail;
+ }
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 26bb64fff..edaffd609 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -39,7 +39,6 @@ import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
-import android.content.pm.UserInfo;
import android.database.ContentObserver;
import android.net.ConnectivityManager;
import android.net.DhcpResults;
@@ -194,7 +193,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
private final AtomicBoolean mP2pConnected = new AtomicBoolean(false);
private boolean mTemporarilyDisconnectWifi = false;
private final String mPrimaryDeviceType;
- private final UserManager mUserManager;
private final Clock mClock = new Clock();
private final WifiCountryCode mCountryCode;
@@ -219,11 +217,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
private int mLastSignalLevel = -1;
private String mLastBssid;
private int mLastNetworkId; // The network Id we successfully joined
- private ScanDetail mActiveScanDetail; // ScanDetail associated with active network
private boolean linkDebouncing = false;
- private int mCurrentUserId = UserHandle.USER_SYSTEM;
-
@Override
public void onRssiThresholdBreached(byte curRssi) {
if (DBG) {
@@ -1022,7 +1017,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mWifiMetrics = wifiInjector.getWifiMetrics();
mContext = context;
mFacade = facade;
- mUserManager = userManager;
mWifiNative = WifiNative.getWlanNativeInterface();
mBackupManagerProxy = backupManagerProxy;
@@ -1039,7 +1033,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mP2pSupported = mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_WIFI_DIRECT);
- mWifiConfigManager = mFacade.makeWifiConfigManager(context, this, mWifiNative, facade,
+ mWifiConfigManager = mFacade.makeWifiConfigManager(context, mWifiNative, facade,
mClock, userManager, KeyStore.getInstance());
mWifiMonitor = WifiMonitor.getInstance();
@@ -3236,7 +3230,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
}
}
- mActiveScanDetail = activeScanDetail;
+ mWifiConfigManager.setActiveScanDetail(activeScanDetail);
}
if (linkDebouncing) {
@@ -3249,12 +3243,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
}
- public ScanDetail getActiveScanDetail() {
- synchronized (mScanResultsLock) {
- return mActiveScanDetail;
- }
- }
-
/*
* Fetch RSSI, linkspeed, and frequency on current connection
*/
@@ -4382,8 +4370,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
messageHandlingStatus = MESSAGE_HANDLING_STATUS_DISCARD;
break;
case CMD_USER_SWITCH:
- mCurrentUserId = message.arg1;
- mWifiConfigManager.handleUserSwitch();
+ mWifiConfigManager.handleUserSwitch(message.arg1);
break;
case CMD_ADD_PASSPOINT_MO:
case CMD_MODIFY_PASSPOINT_MO:
@@ -5031,7 +5018,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
mWifiConfigManager.notifyIconReceived((IconEvent) message.obj);
break;
case WifiMonitor.HS20_REMEDIATION_EVENT:
- mWifiConfigManager.wnmFrameReceived((WnmData) message.obj);
+ wnmFrameReceived((WnmData) message.obj);
break;
case CMD_CONFIG_ND_OFFLOAD:
final boolean enabled = (message.arg1 > 0);
@@ -5593,9 +5580,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
break;
case CMD_ADD_OR_UPDATE_NETWORK:
// Only the current foreground user can modify networks.
- if (!isCurrentUserProfile(UserHandle.getUserId(message.sendingUid))) {
+ if (!mWifiConfigManager.isCurrentUserProfile(
+ UserHandle.getUserId(message.sendingUid))) {
loge("Only the current foreground user can modify networks "
- + " currentUserId=" + mCurrentUserId
+ + " currentUserId=" + mWifiConfigManager.getCurrentUserId()
+ " sendingUserId=" + UserHandle.getUserId(message.sendingUid));
replyToMessage(message, message.what, FAILURE);
break;
@@ -5648,9 +5636,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
break;
case CMD_REMOVE_NETWORK:
// Only the current foreground user can modify networks.
- if (!isCurrentUserProfile(UserHandle.getUserId(message.sendingUid))) {
+ if (!mWifiConfigManager.isCurrentUserProfile(
+ UserHandle.getUserId(message.sendingUid))) {
loge("Only the current foreground user can modify networks "
- + " currentUserId=" + mCurrentUserId
+ + " currentUserId=" + mWifiConfigManager.getCurrentUserId()
+ " sendingUserId=" + UserHandle.getUserId(message.sendingUid));
replyToMessage(message, message.what, FAILURE);
break;
@@ -5674,9 +5663,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
break;
case CMD_ENABLE_NETWORK:
// Only the current foreground user can modify networks.
- if (!isCurrentUserProfile(UserHandle.getUserId(message.sendingUid))) {
+ if (!mWifiConfigManager.isCurrentUserProfile(
+ UserHandle.getUserId(message.sendingUid))) {
loge("Only the current foreground user can modify networks "
- + " currentUserId=" + mCurrentUserId
+ + " currentUserId=" + mWifiConfigManager.getCurrentUserId()
+ " sendingUserId=" + UserHandle.getUserId(message.sendingUid));
replyToMessage(message, message.what, FAILURE);
break;
@@ -5942,7 +5932,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
//Determine if this CONNECTION is for a user selection
if (mWifiConfigManager.isLastSelectedConfiguration(config)
- && isCurrentUserProfile(UserHandle.getUserId(config.lastConnectUid))) {
+ && mWifiConfigManager.isCurrentUserProfile(
+ UserHandle.getUserId(config.lastConnectUid))) {
lastConnectUid = config.lastConnectUid;
mWifiMetrics.setConnectionEventRoamType(
WifiMetricsProto.ConnectionEvent.ROAM_USER_SELECTED);
@@ -5994,9 +5985,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
break;
case WifiManager.CONNECT_NETWORK:
// Only the current foreground user can modify networks.
- if (!isCurrentUserProfile(UserHandle.getUserId(message.sendingUid))) {
+ if (!mWifiConfigManager.isCurrentUserProfile(
+ UserHandle.getUserId(message.sendingUid))) {
loge("Only the current foreground user can modify networks "
- + " currentUserId=" + mCurrentUserId
+ + " currentUserId=" + mWifiConfigManager.getCurrentUserId()
+ " sendingUserId=" + UserHandle.getUserId(message.sendingUid));
replyToMessage(message, WifiManager.CONNECT_NETWORK_FAILED,
WifiManager.NOT_AUTHORIZED);
@@ -6145,9 +6137,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
// Fall thru
case WifiStateMachine.CMD_AUTO_SAVE_NETWORK:
// Only the current foreground user can modify networks.
- if (!isCurrentUserProfile(UserHandle.getUserId(message.sendingUid))) {
+ if (!mWifiConfigManager.isCurrentUserProfile(
+ UserHandle.getUserId(message.sendingUid))) {
loge("Only the current foreground user can modify networks "
- + " currentUserId=" + mCurrentUserId
+ + " currentUserId=" + mWifiConfigManager.getCurrentUserId()
+ " sendingUserId=" + UserHandle.getUserId(message.sendingUid));
replyToMessage(message, WifiManager.SAVE_NETWORK_FAILED,
WifiManager.NOT_AUTHORIZED);
@@ -6242,9 +6235,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
break;
case WifiManager.FORGET_NETWORK:
// Only the current foreground user can modify networks.
- if (!isCurrentUserProfile(UserHandle.getUserId(message.sendingUid))) {
+ if (!mWifiConfigManager.isCurrentUserProfile(
+ UserHandle.getUserId(message.sendingUid))) {
loge("Only the current foreground user can modify networks "
- + " currentUserId=" + mCurrentUserId
+ + " currentUserId=" + mWifiConfigManager.getCurrentUserId()
+ " sendingUserId=" + UserHandle.getUserId(message.sendingUid));
replyToMessage(message, WifiManager.FORGET_NETWORK_FAILED,
WifiManager.NOT_AUTHORIZED);
@@ -8390,22 +8384,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
}
- public int getCurrentUserId() {
- return mCurrentUserId;
- }
-
- private boolean isCurrentUserProfile(int userId) {
- if (userId == mCurrentUserId) {
- return true;
- }
- final UserInfo parent = mUserManager.getProfileParent(userId);
- return parent != null && parent.id == mCurrentUserId;
- }
-
- public List<UserInfo> getCurrentUserProfiles() {
- return mUserManager.getProfiles(mCurrentUserId);
- }
-
/**
* Automatically connect to the network specified
*
@@ -8520,4 +8498,28 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
return TextUtils.join(" ", attributes);
}
+
+ private void wnmFrameReceived(WnmData event) {
+ // %012x HS20-SUBSCRIPTION-REMEDIATION "%u %s", osu_method, url
+ // %012x HS20-DEAUTH-IMMINENT-NOTICE "%u %u %s", code, reauth_delay, url
+
+ Intent intent = new Intent(WifiManager.PASSPOINT_WNM_FRAME_RECEIVED_ACTION);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+
+ intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_BSSID, event.getBssid());
+ intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_URL, event.getUrl());
+
+ if (event.isDeauthEvent()) {
+ intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_ESS, event.isEss());
+ intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_DELAY, event.getDelay());
+ } else {
+ intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_METHOD, event.getMethod());
+ WifiConfiguration config = getCurrentWifiConfiguration();
+ if (config != null && config.FQDN != null) {
+ intent.putExtra(WifiManager.EXTRA_PASSPOINT_WNM_PPOINT_MATCH,
+ mWifiConfigManager.matchProviderWithCurrentNetwork(config.FQDN));
+ }
+ }
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+ }
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index d551e7b94..fcc7c8764 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -132,7 +132,6 @@ public class WifiConfigManagerTest {
public static final String TAG = "WifiConfigManagerTest";
@Mock private Context mContext;
- @Mock private WifiStateMachine mWifiStateMachine;
@Mock private WifiNative mWifiNative;
@Mock private FrameworkFacade mFrameworkFacade;
@Mock private UserManager mUserManager;
@@ -156,8 +155,7 @@ public class WifiConfigManagerTest {
when(mContext.getResources()).thenReturn(realContext.getResources());
when(mContext.getPackageManager()).thenReturn(realContext.getPackageManager());
- when(mWifiStateMachine.getCurrentUserId()).thenReturn(UserHandle.USER_SYSTEM);
- when(mWifiStateMachine.getCurrentUserProfiles())
+ when(mUserManager.getProfiles(UserHandle.USER_SYSTEM))
.thenReturn(USER_PROFILES.get(UserHandle.USER_SYSTEM));
for (int userId : USER_IDS) {
@@ -166,8 +164,8 @@ public class WifiConfigManagerTest {
mMockKeyStore = new MockKeyStore();
- mWifiConfigManager = new WifiConfigManager(mContext, mWifiStateMachine, mWifiNative,
- mFrameworkFacade, mClock, mUserManager, mMockKeyStore.createMock());
+ mWifiConfigManager = new WifiConfigManager(mContext, mWifiNative, mFrameworkFacade, mClock,
+ mUserManager, mMockKeyStore.createMock());
final Field configuredNetworksField =
WifiConfigManager.class.getDeclaredField("mConfiguredNetworks");
@@ -203,10 +201,9 @@ public class WifiConfigManagerTest {
}
private void switchUser(int newUserId) {
- when(mWifiStateMachine.getCurrentUserId()).thenReturn(newUserId);
- when(mWifiStateMachine.getCurrentUserProfiles())
+ when(mUserManager.getProfiles(newUserId))
.thenReturn(USER_PROFILES.get(newUserId));
- mWifiConfigManager.handleUserSwitch();
+ mWifiConfigManager.handleUserSwitch(newUserId);
}
private void switchUserToCreatorOrParentOf(WifiConfiguration config) {
@@ -219,7 +216,7 @@ public class WifiConfigManagerTest {
}
private void addNetworks() throws Exception {
- final int originalUserId = mWifiStateMachine.getCurrentUserId();
+ final int originalUserId = mWifiConfigManager.getCurrentUserId();
when(mWifiNative.setNetworkVariable(anyInt(), anyString(), anyString())).thenReturn(true);
when(mWifiNative.setNetworkExtra(anyInt(), anyString(), (Map<String, String>) anyObject()))
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index df5de345c..73c1dfb40 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -200,14 +200,14 @@ public class WifiStateMachineTest {
when(facade.checkUidPermission(eq(android.Manifest.permission.OVERRIDE_WIFI_CONFIG),
anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
- when(facade.makeWifiConfigManager(any(Context.class), any(WifiStateMachine.class),
- any(WifiNative.class), any(FrameworkFacade.class), any(Clock.class),
+ when(facade.makeWifiConfigManager(any(Context.class), any(WifiNative.class),
+ any(FrameworkFacade.class), any(Clock.class),
any(UserManager.class), any(KeyStore.class))).then(new AnswerWithArguments() {
- public WifiConfigManager answer(Context context, WifiStateMachine wifiStateMachine,
- WifiNative wifiNative, FrameworkFacade frameworkFacade, Clock clock,
+ public WifiConfigManager answer(Context context, WifiNative wifiNative,
+ FrameworkFacade frameworkFacade, Clock clock,
UserManager userManager, KeyStore keyStore){
- mWifiConfigManager = new WifiConfigManager(context, wifiStateMachine, wifiNative,
- frameworkFacade, clock, userManager, keyStore);
+ mWifiConfigManager = new WifiConfigManager(context, wifiNative, frameworkFacade,
+ clock, userManager, keyStore);
return mWifiConfigManager;
}
});
@@ -920,12 +920,12 @@ public class WifiStateMachineTest {
@Test
public void handleUserSwitch() throws Exception {
- assertEquals(UserHandle.USER_SYSTEM, mWsm.getCurrentUserId());
+ assertEquals(UserHandle.USER_SYSTEM, mWifiConfigManager.getCurrentUserId());
mWsm.handleUserSwitch(10);
mLooper.dispatchAll();
- assertEquals(10, mWsm.getCurrentUserId());
+ assertEquals(10, mWifiConfigManager.getCurrentUserId());
}
@Test