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

Commit 2bc720fa authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] set firstInstallTime for system apps on createNewUser

(As a follow up on ag/25951290)

This field used to be 0 (effectively the beginning of unix time) so it's
not very useful. Set it to the actual timestamp when the system app is
marked as installed on the new user.

BUG: 322246299
Test: presubmit

Change-Id: I15a638c83032a086db5d413ada6289692d941490
parent b2f6ca34
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4537,6 +4537,8 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
        t.traceBegin("createNewUser-" + userHandle);
        Installer.Batch batch = new Installer.Batch();
        final boolean skipPackageAllowList = userTypeInstallablePackages == null;
        // Use the same timestamp for all system apps that are to be installed on the new user
        final long currentTimeMillis = System.currentTimeMillis();
        synchronized (mLock) {
            final int size = mPackages.size();
            for (int i = 0; i < size; i++) {
@@ -4552,6 +4554,9 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
                                ps.getPackageName()));
                // Only system apps are initially installed.
                ps.setInstalled(shouldReallyInstall, userHandle);
                if (Flags.fixSystemAppsFirstInstallTime() && shouldReallyInstall) {
                    ps.setFirstInstallTime(currentTimeMillis, userHandle);
                }

                // Non-Apex system apps, that are not included in the allowlist in
                // initialNonStoppedSystemPackages, should be marked as stopped by default.