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

Commit df8a8396 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[pm] retain old code paths for INSTALL_DONT_KILL_APP" into main

parents 39b3da6e 519f1e1f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -101,3 +101,10 @@ flag {
    description: "Feature flag to enable the refactored Package Installer app with updated UI."
    bug: "182205982"
}

flag {
    name: "improve_install_dont_kill"
    namespace: "package_manager_service"
    description: "Feature flag to reduce app crashes caused by split installs with INSTALL_DONT_KILL"
    bug: "291212866"
}
+5 −4
Original line number Diff line number Diff line
@@ -2861,10 +2861,11 @@ final class InstallPackageHelper {
                    ? request.getRemovedInfo().mArgs : null;
            if (args != null) {
                if (!killApp) {
                    // If we didn't kill the app, defer the deletion of code/resource files, since
                    // they may still be in use by the running application. This mitigates problems
                    // in cases where resources or code is loaded by a new Activity before
                    // ApplicationInfo changes have propagated to all application threads.
                    // If we didn't kill the app, defer the deletion of code/resource files,
                    // since the old code/resource files may still be in use by the running
                    // application. This mitigates problems and cases where resources or
                    // code is loaded by a new Activity before ApplicationInfo changes have
                    // propagated to all application threads.
                    mPm.scheduleDeferredNoKillPostDelete(args);
                } else {
                    mRemovePackageHelper.cleanUpResources(args.mCodeFile, args.mInstructionSets);
+21 −2
Original line number Diff line number Diff line
@@ -523,6 +523,9 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    private static final String PROPERTY_IS_UPDATE_OWNERSHIP_ENFORCEMENT_AVAILABLE =
            "is_update_ownership_enforcement_available";

    private static final String PROPERTY_DEFERRED_NO_KILL_POST_DELETE_DELAY_MS_EXTENDED =
            "deferred_no_kill_post_delete_delay_ms_extended";

    /**
     * The default response for package verification timeout.
     *
@@ -924,7 +927,11 @@ public class PackageManagerService implements PackageSender, TestUtilityService

    static final int WRITE_USER_PACKAGE_RESTRICTIONS = 30;

    static final int DEFERRED_NO_KILL_POST_DELETE_DELAY_MS = 3 * 1000;
    private static final int DEFERRED_NO_KILL_POST_DELETE_DELAY_MS = 3 * 1000;

    private static final long DEFERRED_NO_KILL_POST_DELETE_DELAY_MS_EXTENDED =
            TimeUnit.DAYS.toMillis(1);

    private static final int DEFERRED_NO_KILL_INSTALL_OBSERVER_DELAY_MS = 500;
    private static final int DEFERRED_PENDING_KILL_INSTALL_OBSERVER_DELAY_MS = 1000;

@@ -1288,7 +1295,19 @@ public class PackageManagerService implements PackageSender, TestUtilityService

    void scheduleDeferredNoKillPostDelete(InstallArgs args) {
        Message message = mHandler.obtainMessage(DEFERRED_NO_KILL_POST_DELETE, args);
        mHandler.sendMessageDelayed(message, DEFERRED_NO_KILL_POST_DELETE_DELAY_MS);
        // If the feature flag is on, retain the old files for a day. Otherwise, delete the old
        // files after a few seconds.
        long deleteDelayMillis = DEFERRED_NO_KILL_POST_DELETE_DELAY_MS;
        if (Flags.improveInstallDontKill()) {
            deleteDelayMillis = Binder.withCleanCallingIdentity(() -> {
                return DeviceConfig.getLong(NAMESPACE_PACKAGE_MANAGER_SERVICE,
                        /* name= */ PROPERTY_DEFERRED_NO_KILL_POST_DELETE_DELAY_MS_EXTENDED,
                        /* defaultValue= */ DEFERRED_NO_KILL_POST_DELETE_DELAY_MS_EXTENDED);
            });
            Slog.w(TAG, "Delaying the deletion of <" + args.getCodePath() + "> by "
                    + deleteDelayMillis + "ms or till the next reboot");
        }
        mHandler.sendMessageDelayed(message, deleteDelayMillis);
    }

    void schedulePruneUnusedStaticSharedLibraries(boolean delay) {