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

Commit 8051a0a3 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

fix last modified time

For cluster packages [i.e. packages that are split among multiple APKs]
the codePath is the directory containing the APKs. This normally works
well since the directory is created newly on update. However, it breaks
down during OTA when the directory modification time may or may not
change.

Specifically for cluster packages, we determine the packages "last
modified time" as the date of the newwest APK added to the package.

Bug: 29575840
Bug: 29610181

Change-Id: Ia0a40cf6aaf4102f35e9319ebdb95074b1740c90
parent 5719a7f4
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -6763,11 +6763,26 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
    }
    private long getLastModifiedTime(PackageParser.Package pkg, File srcFile) {
        if (srcFile.isDirectory()) {
            final File baseFile = new File(pkg.baseCodePath);
            long maxModifiedTime = baseFile.lastModified();
            if (pkg.splitCodePaths != null) {
                for (int i = pkg.splitCodePaths.length - 1; i >=0; --i) {
                    final File splitFile = new File(pkg.splitCodePaths[i]);
                    maxModifiedTime = Math.max(maxModifiedTime, splitFile.lastModified());
                }
            }
            return maxModifiedTime;
        }
        return srcFile.lastModified();
    }
    private void collectCertificatesLI(PackageSetting ps, PackageParser.Package pkg, File srcFile,
            final int policyFlags) throws PackageManagerException {
        if (ps != null
                && ps.codePath.equals(srcFile)
                && ps.timeStamp == srcFile.lastModified()
                && ps.timeStamp == getLastModifiedTime(pkg, srcFile)
                && !isCompatSignatureUpdateNeeded(pkg)
                && !isRecoverSignatureUpdateNeeded(pkg)) {
            long mSigningKeySetId = ps.keySetData.getProperSigningKeySet();
@@ -8403,7 +8418,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        final String pkgName = pkg.packageName;
        final long scanFileTime = scanFile.lastModified();
        final long scanFileTime = getLastModifiedTime(pkg, scanFile);
        final boolean forceDex = (scanFlags & SCAN_FORCE_DEX) != 0;
        pkg.applicationInfo.processName = fixProcessName(
                pkg.applicationInfo.packageName,