From 06636d2de935ad5d2e8fb6483c406fe922c75ff2 Mon Sep 17 00:00:00 2001 From: Samuel Tan Date: Tue, 5 Apr 2016 13:33:49 -0700 Subject: Remove getCurrentUserId() and getCurrentUserProfiles() from ...WifiStateMachine Move getCurrentUserId() from WifiStateMachine to WifiConfigManager, and remove WifiStateMachine.getCurrentUserProfiles(), so that WifiConfigManager no longer makes calls to WifiStateMachine to perform these two tasks. Achieve this by moving the bookkeeping for the current user ID from WifiStateMachine to WifiConfigManager. BUG: 27405059 Change-Id: I06a8be88f24fd81cbfe785c4304883ddc44658f8 TEST: 'runtest frameworks-wifi' succeeds. --- .../src/com/android/server/wifi/WifiConfigManagerTest.java | 10 ++++------ .../src/com/android/server/wifi/WifiStateMachineTest.java | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index d551e7b94..31ed99f15 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java @@ -156,8 +156,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) { @@ -203,10 +202,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 +217,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) 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..402103621 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -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 -- cgit v1.2.3 From ac69b83c9cafb9a839b578c3b5b71eb3439244ad Mon Sep 17 00:00:00 2001 From: Samuel Tan Date: Thu, 7 Apr 2016 15:59:12 -0700 Subject: WifiConfigManager: remove WifiStateMachine field Remove the WifiStateMachine field from WifiConfigManager, since the latter no longer calls methods of the former. Also, change calls to the WifiConfigManager constructors to accomodate this change. BUG: 27405059 Change-Id: I468f74259d45d9a1a61e00b987533eaa66846024 TEST: 'runtest frameworks-wifi' succeeds. --- .../src/com/android/server/wifi/WifiConfigManagerTest.java | 5 ++--- .../src/com/android/server/wifi/WifiStateMachineTest.java | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 31ed99f15..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; @@ -165,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"); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 402103621..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; } }); -- cgit v1.2.3