From b6a3409500d3bc9d06196d4a2043b819ffb67639 Mon Sep 17 00:00:00 2001 From: Gavin Corkery Date: Thu, 24 Sep 2020 13:46:20 +0100 Subject: Fix Rescue Party observability criteria The previous behavior erroneously returned if the package was not found by PackageManager#getModuleInfo, which means the persistent process check would never be performed. This caused packages like com.android.systemui to not be handled by Rescue Party's mitigation logic. Instead, ensure that both cases are checked. Test: setprop persist.sys.enable_rescue true, adb shell setprop debug.crash_sysui 1, adb shell kill `pidof com.android.systemui`, ensure recovery mode is reached Bug: 169284310 Change-Id: Ifec19b8daba1dacc7f5efcfa47ed3c3a046612e3 Merged-In: Ifec19b8daba1dacc7f5efcfa47ed3c3a046612e3 (cherry picked from commit f2abc4e6fa6ed79462e0ddfc6ede526edc646378) --- services/core/java/com/android/server/RescueParty.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/RescueParty.java b/services/core/java/com/android/server/RescueParty.java index 829fca66ec0d..9fc8f0b5a3c3 100644 --- a/services/core/java/com/android/server/RescueParty.java +++ b/services/core/java/com/android/server/RescueParty.java @@ -454,10 +454,14 @@ public class RescueParty { public boolean mayObservePackage(String packageName) { PackageManager pm = mContext.getPackageManager(); try { - // A package is a Mainline module if this is non-null + // A package is a module if this is non-null if (pm.getModuleInfo(packageName, 0) != null) { return true; } + } catch (PackageManager.NameNotFoundException ignore) { + } + + try { ApplicationInfo info = pm.getApplicationInfo(packageName, 0); return (info.flags & PERSISTENT_MASK) == PERSISTENT_MASK; } catch (PackageManager.NameNotFoundException e) { -- cgit v1.2.3-59-g8ed1b