Fix system server crash during sendMyPackageSuspendedOrUnsuspended()

IllegalArgumentException could be thrown when the package doesn't exist
from getSuspendedPackageAppExtrasInternal(), which causes system server
crash

This fix replaces throwing IllegalStateException with returning null,
instead of handling the exception. Returning null when the package
doesn't exist still operates according to the public contact since
an uninstalled application would not be considered 'suspended'.

Bug: 171906179
Test: compile & verify basic functions working
Change-Id: I9b23c17530393a0f51e283d0bc2c44966ddf6298
This commit is contained in:
Jeongsik Mun
2020-11-14 14:06:44 +09:00
committed by Todd Kennedy
parent 1d2102b503
commit dea7086695

View File

@@ -13937,7 +13937,7 @@ public class PackageManagerService extends IPackageManager.Stub
synchronized (mLock) {
final PackageSetting ps = mSettings.mPackages.get(packageName);
if (ps == null) {
throw new IllegalArgumentException("Unknown target package: " + packageName);
return null;
}
final PackageUserState pus = ps.readUserState(userId);
final Bundle allExtras = new Bundle();