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

Commit 3a02bebb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes Ic8db00b6,I68a91e07,I860ad443

* changes:
  Remove package name from ROLLBACK_EXECUTED broadcast.
  Use VersionedPackage in PackageRollbackInfo.
  Assign a rollbackId to all rollbacks.
parents 438f6799 f8f1b38f
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -1672,22 +1672,17 @@ package android.content.pm.permission {
package android.content.rollback {
  public final class PackageRollbackInfo implements android.os.Parcelable {
    ctor public PackageRollbackInfo(String, android.content.rollback.PackageRollbackInfo.PackageVersion, android.content.rollback.PackageRollbackInfo.PackageVersion);
    method public int describeContents();
    method public String getPackageName();
    method public android.content.pm.VersionedPackage getVersionRolledBackFrom();
    method public android.content.pm.VersionedPackage getVersionRolledBackTo();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.content.rollback.PackageRollbackInfo> CREATOR;
    field public final android.content.rollback.PackageRollbackInfo.PackageVersion higherVersion;
    field public final android.content.rollback.PackageRollbackInfo.PackageVersion lowerVersion;
    field public final String packageName;
  }
  public static class PackageRollbackInfo.PackageVersion {
    ctor public PackageRollbackInfo.PackageVersion(long);
    field public final long versionCode;
  }
  public final class RollbackInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int getRollbackId();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.content.rollback.RollbackInfo> CREATOR;
    field public final android.content.rollback.PackageRollbackInfo targetPackage;
+0 −1
Original line number Diff line number Diff line
@@ -2377,7 +2377,6 @@ public class Intent implements Parcelable, Cloneable {
    /**
     * Broadcast Action: An existing version of an application package has been
     * rolled back to a previous version.
     * The data contains the name of the package.
     *
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
+24 −44
Original line number Diff line number Diff line
@@ -17,11 +17,10 @@
package android.content.rollback;

import android.annotation.SystemApi;
import android.content.pm.VersionedPackage;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * Information about a rollback available for a particular package.
 *
@@ -29,59 +28,41 @@ import java.util.Objects;
 */
@SystemApi
public final class PackageRollbackInfo implements Parcelable {
    /**
     * The name of a package being rolled back.
     */
    public final String packageName;

    /**
     * The version the package was rolled back from.
     */
    public final PackageVersion higherVersion;
    private final VersionedPackage mVersionRolledBackFrom;
    private final VersionedPackage mVersionRolledBackTo;

    /**
     * The version the package was rolled back to.
     * Returns the name of the package to roll back from.
     */
    public final PackageVersion lowerVersion;
    public String getPackageName() {
        return mVersionRolledBackFrom.getPackageName();
    }

    /**
     * Represents a version of a package.
     * Returns the version of the package rolled back from.
     */
    public static class PackageVersion {
        public final long versionCode;

        // TODO(b/120200473): Include apk sha or some other way to distinguish
        // between two different apks with the same version code.
        public PackageVersion(long versionCode) {
            this.versionCode = versionCode;
    public VersionedPackage getVersionRolledBackFrom() {
        return mVersionRolledBackFrom;
    }

        @Override
        public boolean equals(Object other) {
            if (other instanceof PackageVersion)  {
                PackageVersion otherVersion = (PackageVersion) other;
                return versionCode == otherVersion.versionCode;
            }
            return false;
        }

        @Override
        public int hashCode() {
            return Objects.hash(versionCode);
        }
    /**
     * Returns the version of the package rolled back to.
     */
    public VersionedPackage getVersionRolledBackTo() {
        return mVersionRolledBackTo;
    }

    public PackageRollbackInfo(String packageName,
            PackageVersion higherVersion, PackageVersion lowerVersion) {
        this.packageName = packageName;
        this.higherVersion = higherVersion;
        this.lowerVersion = lowerVersion;
    /** @hide */
    public PackageRollbackInfo(VersionedPackage packageRolledBackFrom,
            VersionedPackage packageRolledBackTo) {
        this.mVersionRolledBackFrom = packageRolledBackFrom;
        this.mVersionRolledBackTo = packageRolledBackTo;
    }

    private PackageRollbackInfo(Parcel in) {
        this.packageName = in.readString();
        this.higherVersion = new PackageVersion(in.readLong());
        this.lowerVersion = new PackageVersion(in.readLong());
        this.mVersionRolledBackFrom = VersionedPackage.CREATOR.createFromParcel(in);
        this.mVersionRolledBackTo = VersionedPackage.CREATOR.createFromParcel(in);
    }

    @Override
@@ -91,9 +72,8 @@ public final class PackageRollbackInfo implements Parcelable {

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeString(packageName);
        out.writeLong(higherVersion.versionCode);
        out.writeLong(lowerVersion.versionCode);
        mVersionRolledBackFrom.writeToParcel(out, flags);
        mVersionRolledBackTo.writeToParcel(out, flags);
    }

    public static final Parcelable.Creator<PackageRollbackInfo> CREATOR =
+17 −2
Original line number Diff line number Diff line
@@ -29,6 +29,11 @@ import android.os.Parcelable;
@SystemApi
public final class RollbackInfo implements Parcelable {

    /**
     * A unique identifier for the rollback.
     */
    private final int mRollbackId;

    /**
     * The package that needs to be rolled back.
     */
@@ -40,12 +45,21 @@ public final class RollbackInfo implements Parcelable {
    // staged installs is supported.

    /** @hide */
    public RollbackInfo(PackageRollbackInfo targetPackage) {
    public RollbackInfo(int rollbackId, PackageRollbackInfo targetPackage) {
        this.mRollbackId = rollbackId;
        this.targetPackage = targetPackage;
    }

    private RollbackInfo(Parcel in) {
        this.targetPackage = PackageRollbackInfo.CREATOR.createFromParcel(in);
        mRollbackId = in.readInt();
        targetPackage = PackageRollbackInfo.CREATOR.createFromParcel(in);
    }

    /**
     * Returns a unique identifier for this rollback.
     */
    public int getRollbackId() {
        return mRollbackId;
    }

    @Override
@@ -55,6 +69,7 @@ public final class RollbackInfo implements Parcelable {

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(mRollbackId);
        targetPackage.writeToParcel(out, flags);
    }

+7 −1
Original line number Diff line number Diff line
@@ -28,6 +28,11 @@ import java.util.List;
 * packages.
 */
class RollbackData {
    /**
     * A unique identifier for this rollback.
     */
    public final int rollbackId;

    /**
     * The per-package rollback information.
     */
@@ -44,7 +49,8 @@ class RollbackData {
     */
    public Instant timestamp;

    RollbackData(File backupDir) {
    RollbackData(int rollbackId, File backupDir) {
        this.rollbackId = rollbackId;
        this.backupDir = backupDir;
    }
}
Loading