Avoid NullPointerException in enableSystemApp if the app is absent.

In enableSystemApp: if the app is absent, throw a IllegalArgumentException
instead of failing with a NullPointerException.

BUG:19321306

Change-Id: I4ec09a0a77d29ca04e8d52f5546c1e4d0f8641e5
This commit is contained in:
Nicolas Prevot
2015-02-10 17:18:07 +00:00
parent 8f6afec2aa
commit 637baaf0db

View File

@@ -5072,6 +5072,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
throws RemoteException {
ApplicationInfo appInfo = pm.getApplicationInfo(packageName, GET_UNINSTALLED_PACKAGES,
userId);
if (appInfo == null) {
throw new IllegalArgumentException("The application " + packageName +
" is not present on this device");
}
return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
}