Don't throw a runtime exception in getPackageInfo.

If the input is invalid, we need to just return null, otherwise we'll
make PackageManager crash.

Bug: 123676932
Fix: 123878869
Test: used a small app to query the API, reproduce the bug and
verified that the new code fixes it.

Change-Id: Icefb108cc95ec01e36021a5259c59dabdc24c4d6
(cherry picked from commit 471817faf662b0a258409922bed0aca216e4f266)
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index a0a2f6c..87a8935 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -3941,13 +3941,13 @@
                 if (apex != null) {
                     try {
                         final ApexInfo activePkg = apex.getActivePackage(packageName);
-                        if (activePkg != null) {
+                        if (activePkg != null && !TextUtils.isEmpty(activePkg.packagePath)) {
                             try {
                                 return PackageParser.generatePackageInfoFromApex(
                                         new File(activePkg.packagePath), true /* collect certs */);
                             } catch (PackageParserException pe) {
-                                throw new IllegalStateException("Unable to parse: " + activePkg,
-                                        pe);
+                                Log.e(TAG, "Unable to parse package at "
+                                        + activePkg.packagePath, pe);
                             }
                         }
                     } catch (RemoteException e) {