From a4df84863d554f08abebf0c39748deded4121814 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 9 Mar 2020 14:53:23 -0700 Subject: WifiServiceImpl: Fix package removed handling When package is fully removed (unlike app disable), then getApplicationInfo will return NameNotFoundException exception. Bug: 151107194 Test: atest com.android.server.wifi Test: Manually verified that user approval for network request were cleared after uninstalling CTS verifier app. Change-Id: I50b8d4b67b6481c42b6157d6534f78bb08fb9d28 --- tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 8ecac08bc..935c52fb4 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -3648,7 +3648,8 @@ public class WifiServiceImplTest extends WifiBaseTest { && filter.hasAction(Intent.ACTION_PACKAGE_CHANGED))); int uid = TEST_UID; String packageName = TEST_PACKAGE_NAME; - when(mPackageManager.getApplicationInfo(TEST_PACKAGE_NAME, 0)).thenReturn(null); + doThrow(new PackageManager.NameNotFoundException()).when(mPackageManager) + .getApplicationInfo(TEST_PACKAGE_NAME, 0); // Send the broadcast Intent intent = new Intent(Intent.ACTION_PACKAGE_FULLY_REMOVED); intent.putExtra(Intent.EXTRA_UID, uid); -- cgit v1.2.3