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

Commit 85c6cf16 authored by Jeremy Meyer's avatar Jeremy Meyer Committed by Android (Google) Code Review
Browse files

Merge "Don't update cached ApplicationInfo with old information"

parents ac557565 99a2847a
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -38,10 +38,8 @@ import static android.window.ConfigurationHelper.shouldUpdateResources;

import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;

import android.annotation.ElapsedRealtimeLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UptimeMillisLong;
import android.app.RemoteServiceException.BadForegroundServiceNotificationException;
import android.app.RemoteServiceException.CannotDeliverBroadcastException;
import android.app.RemoteServiceException.CannotPostForegroundServiceNotificationException;
@@ -2548,10 +2546,19 @@ public final class ActivityThread extends ClientTransactionHandler

            if (packageInfo != null) {
                if (!isLoadedApkResourceDirsUpToDate(packageInfo, aInfo)) {
                    if (packageInfo.getApplicationInfo().createTimestamp > aInfo.createTimestamp) {
                        // The cached loaded apk is newer than the one passed in, we should not
                        // update the cached version
                        Slog.w(TAG, "getPackageInfo() called with an older ApplicationInfo "
                                + "than the cached version for package " + aInfo.packageName);
                    } else {
                        Slog.v(TAG, "getPackageInfo() caused update to cached ApplicationInfo "
                                + "for package " + aInfo.packageName);
                        List<String> oldPaths = new ArrayList<>();
                        LoadedApk.makePaths(this, aInfo, oldPaths);
                        packageInfo.updateApplicationInfo(aInfo, oldPaths);
                    }
                }

                return packageInfo;
            }
+11 −0
Original line number Diff line number Diff line
@@ -1147,6 +1147,12 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    @UnsupportedAppUsage
    public int versionCode;

    /**
     * The timestamp of when this ApplicationInfo was created.
     * @hide
     */
    public long createTimestamp;

    /**
     * The user-visible SDK version (ex. 26) of the framework against which the application claims
     * to have been compiled, or {@code 0} if not specified.
@@ -1639,6 +1645,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
                        + requestRawExternalStorageAccess);
            }
        }
        pw.println(prefix + "createTimestamp=" + createTimestamp);
        super.dumpBack(pw, prefix);
    }

@@ -1796,6 +1803,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    }

    public ApplicationInfo() {
        createTimestamp = System.currentTimeMillis();
    }
    
    public ApplicationInfo(ApplicationInfo orig) {
@@ -1867,6 +1875,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        memtagMode = orig.memtagMode;
        nativeHeapZeroInitialized = orig.nativeHeapZeroInitialized;
        requestRawExternalStorageAccess = orig.requestRawExternalStorageAccess;
        createTimestamp = System.currentTimeMillis();
    }

    public String toString() {
@@ -1957,6 +1966,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeInt(memtagMode);
        dest.writeInt(nativeHeapZeroInitialized);
        sForBoolean.parcel(requestRawExternalStorageAccess, dest, parcelableFlags);
        dest.writeLong(createTimestamp);
    }

    public static final @android.annotation.NonNull Parcelable.Creator<ApplicationInfo> CREATOR
@@ -2044,6 +2054,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        memtagMode = source.readInt();
        nativeHeapZeroInitialized = source.readInt();
        requestRawExternalStorageAccess = sForBoolean.unparcel(source);
        createTimestamp = source.readLong();
    }

    /**