diff options
author | Roshan Pius <rpius@google.com> | 2019-09-19 07:34:36 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-09-20 03:48:03 +0000 |
commit | a1bbebf25cb7b4e33a7b5abaa6ee6402de95ebc9 (patch) | |
tree | d95430bd7fe49c72e3142b4ec661b0a19fa19289 /tests | |
parent | f102e9e07b5913b2d234cfe3437c6fd5990f2751 (diff) |
Fix a bunch of multi-user API calls
To handle multi-user scenarios, pass in the corresponding app's user id
to fetch app info.
Bug: 140895783
Test: atest com.android.server.wifi
Test: Ran presubmit ACTS tests
Change-Id: I400bad75510b064ad405fae07f56671d2c211178
Diffstat (limited to 'tests')
3 files changed, 9 insertions, 5 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java index 96bf9055d..80aeb08d8 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java @@ -173,7 +173,8 @@ public class WifiNetworkFactoryTest extends WifiBaseTest { .thenReturn(mConnectivityManager); when(mPackageManager.getNameForUid(TEST_UID_1)).thenReturn(TEST_PACKAGE_NAME_1); when(mPackageManager.getNameForUid(TEST_UID_2)).thenReturn(TEST_PACKAGE_NAME_2); - when(mPackageManager.getApplicationInfo(any(), anyInt())).thenReturn(new ApplicationInfo()); + when(mPackageManager.getApplicationInfoAsUser(any(), anyInt(), anyInt())) + .thenReturn(new ApplicationInfo()); when(mPackageManager.getApplicationLabel(any())).thenReturn(TEST_APP_NAME); when(mActivityManager.getPackageImportance(TEST_PACKAGE_NAME_1)) .thenReturn(IMPORTANCE_FOREGROUND_SERVICE); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java index b06af4802..205e7f8fe 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -150,10 +150,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { when(mContext.getApplicationInfo()).thenReturn(ourAppInfo); // test app info ApplicationInfo appInfO1 = new ApplicationInfo(); - when(mPackageManager.getApplicationInfo(TEST_PACKAGE_1, 0)).thenReturn(appInfO1); + when(mPackageManager.getApplicationInfoAsUser(eq(TEST_PACKAGE_1), eq(0), anyInt())) + .thenReturn(appInfO1); when(mPackageManager.getApplicationLabel(appInfO1)).thenReturn(TEST_APP_NAME_1); ApplicationInfo appInfO2 = new ApplicationInfo(); - when(mPackageManager.getApplicationInfo(TEST_PACKAGE_2, 0)).thenReturn(appInfO2); + when(mPackageManager.getApplicationInfoAsUser(eq(TEST_PACKAGE_2), eq(0), anyInt())) + .thenReturn(appInfO2); when(mPackageManager.getApplicationLabel(appInfO2)).thenReturn(TEST_APP_NAME_2); mWifiNetworkSuggestionsManager = diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index e0140cf07..fad848bec 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -349,7 +349,8 @@ public class WifiServiceImplTest extends WifiBaseTest { when(mContext.getResources()).thenReturn(mResources); when(mContext.getContentResolver()).thenReturn(mContentResolver); when(mContext.getPackageManager()).thenReturn(mPackageManager); - when(mPackageManager.getApplicationInfo(any(), anyInt())).thenReturn(mApplicationInfo); + when(mPackageManager.getApplicationInfoAsUser(any(), anyInt(), anyInt())) + .thenReturn(mApplicationInfo); when(mWifiInjector.getWifiApConfigStore()).thenReturn(mWifiApConfigStore); doNothing().when(mFrameworkFacade).registerContentObserver(eq(mContext), any(), anyBoolean(), any()); @@ -2468,7 +2469,7 @@ public class WifiServiceImplTest extends WifiBaseTest { PackageManager pm = mock(PackageManager.class); when(mContext.getPackageManager()).thenReturn(pm); - when(pm.getApplicationInfo(any(), anyInt())).thenReturn(mApplicationInfo); + when(pm.getApplicationInfoAsUser(any(), anyInt(), anyInt())).thenReturn(mApplicationInfo); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); |