Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aafe0a33 authored by Harshit Mahajan's avatar Harshit Mahajan
Browse files

Check only for apk inside updatable apexes

Bug: 289203818
Test: TH
Flag: android.crashrecovery.flags.refactor_crashrecovery
Change-Id: I79924857480a660bb9ba4ff110fa955c9935aeb0
parent d9a2743f
Loading
Loading
Loading
Loading
+9 −13
Original line number Diff line number Diff line
@@ -492,23 +492,19 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve
        PackageManager pm = mContext.getPackageManager();

        if (Flags.refactorCrashrecovery() && provideInfoOfApkInApex()) {
            // Check if the package is listed among the system modules.
            boolean isApex = false;
            // Check if the package is listed among the system modules or is an
            // APK inside an updatable APEX.
            try {
                isApex = (pm.getModuleInfo(packageName, 0 /* flags */) != null);
            } catch (PackageManager.NameNotFoundException e) {
                //pass
                final PackageInfo pkg = pm.getPackageInfo(packageName, 0 /* flags */);
                String apexPackageName = pkg.getApexPackageName();
                if (apexPackageName != null) {
                    packageName = apexPackageName;
                }

            // Check if the package is an APK inside an APEX.
            boolean isApkInApex = false;
            try {
                final PackageInfo pkg = pm.getPackageInfo(packageName, 0 /* flags */);
                isApkInApex = (pkg.getApexPackageName() != null);
                return pm.getModuleInfo(packageName, 0 /* flags */) != null;
            } catch (PackageManager.NameNotFoundException e) {
                // pass
                return false;
            }
            return isApex || isApkInApex;
        } else {
            // Check if the package is an APK inside an APEX. If it is, use the parent APEX package
            // when querying PackageManager.