From 9f30d97a8e1833a757938197cb07de297925d25d Mon Sep 17 00:00:00 2001 From: Song Chun Fan Date: Fri, 24 May 2024 16:41:16 +0000 Subject: [pm] Catch ParcelableException in PackageManager.isAppArchivable Catches the ParcelableException exception type and rethrows it as a NameNotFoundException. Also improves a few existing APIs to rethrow the ParcelableException as a RuntimeException if it is not one of the expected exception type. Change-Id: I76f6cc246fca1fe0624429c500015b0cce5ffd40 BUG: 341212469 FIXES: 341212469 Test: builds --- core/java/android/app/ApplicationPackageManager.java | 3 +++ core/java/android/content/pm/PackageInstaller.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 287d2bd9e6a7..b38f76ed699f 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -2593,6 +2593,9 @@ public class ApplicationPackageManager extends PackageManager { try { Objects.requireNonNull(packageName); return mPM.isAppArchivable(packageName, new UserHandle(getUserId())); + } catch (ParcelableException e) { + e.maybeRethrow(NameNotFoundException.class); + throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 640422359f95..b18c7bef422d 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -2360,6 +2360,7 @@ public class PackageInstaller { new UserHandle(mUserId), flags); } catch (ParcelableException e) { e.maybeRethrow(PackageManager.NameNotFoundException.class); + throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2396,6 +2397,7 @@ public class PackageInstaller { } catch (ParcelableException e) { e.maybeRethrow(IOException.class); e.maybeRethrow(PackageManager.NameNotFoundException.class); + throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -2427,6 +2429,7 @@ public class PackageInstaller { userActionIntent, new UserHandle(mUserId)); } catch (ParcelableException e) { e.maybeRethrow(PackageManager.NameNotFoundException.class); + throw new RuntimeException(e); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } -- cgit v1.2.3-59-g8ed1b