summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-10-18 07:11:39 -0700
committerRoshan Pius <rpius@google.com>2019-10-18 07:25:57 -0700
commit19f0d2bd8105d6f7179223c23289ec44b61b68de (patch)
tree8d01c7b17a09d55e021c8af81fb9c680729de29e
parentb8e4bd0741f6ddeded0f4b4d18270b9f9c50f127 (diff)
WifiStack: Use @SystemApi for PackageManager.getApplicationInfoAsUser
Bug: 142935310 Test: atest com.android.server.wifi Change-Id: I4a8adf3a45cf0fa008aa46c09089178540e2cd60
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkFactory.java2
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java2
-rw-r--r--service/java/com/android/server/wifi/util/WifiPermissionsUtil.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java4
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java2
8 files changed, 10 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkFactory.java b/service/java/com/android/server/wifi/WifiNetworkFactory.java
index b1f1ba43b..bea181ce3 100644
--- a/service/java/com/android/server/wifi/WifiNetworkFactory.java
+++ b/service/java/com/android/server/wifi/WifiNetworkFactory.java
@@ -1160,7 +1160,7 @@ public class WifiNetworkFactory extends NetworkFactory {
ApplicationInfo applicationInfo = null;
try {
applicationInfo = mContext.getPackageManager().getApplicationInfoAsUser(
- packageName, 0, UserHandle.getUserHandleForUid(uid).getIdentifier());
+ packageName, 0, UserHandle.getUserHandleForUid(uid));
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to find app name for " + packageName);
return "";
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index 2a264b37d..d530cdbfc 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -835,7 +835,7 @@ public class WifiNetworkSuggestionsManager {
ApplicationInfo applicationInfo = null;
try {
applicationInfo = mContext.getPackageManager().getApplicationInfoAsUser(
- packageName, 0, UserHandle.getUserHandleForUid(uid).getIdentifier());
+ packageName, 0, UserHandle.getUserHandleForUid(uid));
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Failed to find app name for " + packageName);
return "";
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 08866bdf1..9527c0045 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -543,7 +543,7 @@ public class WifiServiceImpl extends BaseWifiService {
long ident = Binder.clearCallingIdentity();
try {
ApplicationInfo info = mContext.getPackageManager().getApplicationInfoAsUser(
- packageName, 0, UserHandle.getUserHandleForUid(uid).getIdentifier());
+ packageName, 0, UserHandle.getUserHandleForUid(uid));
return (info.flags & APP_INFO_FLAGS_SYSTEM_APP) != 0;
} catch (PackageManager.NameNotFoundException e) {
// In case of exception, assume unknown app (more strict checking)
diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
index 5207bbbc4..50595b972 100644
--- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
+++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
@@ -92,7 +92,7 @@ public class WifiPermissionsUtil {
try {
if (mContext.getPackageManager().getApplicationInfoAsUser(
packageName, 0,
- UserHandle.getUserHandleForUid(callingUid).getIdentifier()).targetSdkVersion
+ UserHandle.getUserHandleForUid(callingUid)).targetSdkVersion
< versionCode) {
return true;
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index ad6394c99..c9e7db2f9 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -179,7 +179,7 @@ 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.getApplicationInfoAsUser(any(), anyInt(), anyInt()))
+ when(mPackageManager.getApplicationInfoAsUser(any(), anyInt(), any()))
.thenReturn(new ApplicationInfo());
when(mPackageManager.getApplicationLabel(any())).thenReturn(TEST_APP_NAME);
when(mActivityManager.getPackageImportance(TEST_PACKAGE_NAME_1))
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 3c9b0bc12..0726514bb 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -153,11 +153,11 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
when(mContext.getApplicationInfo()).thenReturn(ourAppInfo);
// test app info
ApplicationInfo appInfO1 = new ApplicationInfo();
- when(mPackageManager.getApplicationInfoAsUser(eq(TEST_PACKAGE_1), eq(0), anyInt()))
+ when(mPackageManager.getApplicationInfoAsUser(eq(TEST_PACKAGE_1), eq(0), any()))
.thenReturn(appInfO1);
when(mPackageManager.getApplicationLabel(appInfO1)).thenReturn(TEST_APP_NAME_1);
ApplicationInfo appInfO2 = new ApplicationInfo();
- when(mPackageManager.getApplicationInfoAsUser(eq(TEST_PACKAGE_2), eq(0), anyInt()))
+ when(mPackageManager.getApplicationInfoAsUser(eq(TEST_PACKAGE_2), eq(0), any()))
.thenReturn(appInfO2);
when(mPackageManager.getApplicationLabel(appInfO2)).thenReturn(TEST_APP_NAME_2);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index 7b5def334..8c70b090c 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -290,7 +290,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
when(mContext.getResources()).thenReturn(mResources);
when(mContext.getContentResolver()).thenReturn(mContentResolver);
when(mContext.getPackageManager()).thenReturn(mPackageManager);
- when(mPackageManager.getApplicationInfoAsUser(any(), anyInt(), anyInt()))
+ when(mPackageManager.getApplicationInfoAsUser(any(), anyInt(), any()))
.thenReturn(mApplicationInfo);
when(mWifiInjector.getWifiApConfigStore()).thenReturn(mWifiApConfigStore);
doNothing().when(mFrameworkFacade).registerContentObserver(eq(mContext), any(),
@@ -2374,7 +2374,7 @@ public class WifiServiceImplTest extends WifiBaseTest {
PackageManager pm = mock(PackageManager.class);
when(mContext.getPackageManager()).thenReturn(pm);
- when(pm.getApplicationInfoAsUser(any(), anyInt(), anyInt())).thenReturn(mApplicationInfo);
+ when(pm.getApplicationInfoAsUser(any(), anyInt(), any())).thenReturn(mApplicationInfo);
when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(),
eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true);
diff --git a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
index 222c70621..6c675af79 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java
@@ -1214,7 +1214,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest {
}
private void setupMocks() throws Exception {
- when(mMockPkgMgr.getApplicationInfoAsUser(eq(TEST_PACKAGE_NAME), eq(0), anyInt()))
+ when(mMockPkgMgr.getApplicationInfoAsUser(eq(TEST_PACKAGE_NAME), eq(0), any()))
.thenReturn(mMockApplInfo);
when(mMockContext.getPackageManager()).thenReturn(mMockPkgMgr);
when(mMockAppOps.noteOp(AppOpsManager.OPSTR_WIFI_SCAN, mUid, TEST_PACKAGE_NAME, null, null))