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

Commit ecd4c4a6 authored by Jakob Schneider's avatar Jakob Schneider
Browse files

Move isArchived into the PackageItemInfo class.

I'm making this change to enable us to load the archived icon instead of
the standard icon when loadIcon is called on the ApplicationInfo of an
archived app.

Icon related logic is in the PackageItemInfo class and we might want
to set isArchived for the archived activities we construct in
LauncherApps later on as well. So this class seems like the best fit.

Test: PackageInstallerArchiveTest.java
Bug: 298375566

Change-Id: I0a130d5ff862af733b4f3dbe3a515b94d82ec7ce
parent 90806496
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -3798,10 +3798,6 @@ package android.content.pm {
    field @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS) public static final int FLAG_GET_PERSONS_DATA = 2048; // 0x800
  }
  public class PackageInfo implements android.os.Parcelable {
    field public boolean isArchived;
  }
  public class PackageInstaller {
    method @NonNull public android.content.pm.PackageInstaller.InstallInfo readInstallInfo(@NonNull java.io.File, int) throws android.content.pm.PackageInstaller.PackageParsingException;
    method @NonNull public android.content.pm.PackageInstaller.InstallInfo readInstallInfo(@NonNull android.os.ParcelFileDescriptor, @Nullable String, int) throws android.content.pm.PackageInstaller.PackageParsingException;
@@ -3879,6 +3875,7 @@ package android.content.pm {
    method public static void forceSafeLabels();
    method @Deprecated @NonNull public CharSequence loadSafeLabel(@NonNull android.content.pm.PackageManager);
    method @NonNull public CharSequence loadSafeLabel(@NonNull android.content.pm.PackageManager, @FloatRange(from=0) float, int);
    field @FlaggedApi(Flags.FLAG_ARCHIVING) public boolean isArchived;
  }
  public abstract class PackageManager {
+0 −16
Original line number Diff line number Diff line
@@ -18,9 +18,7 @@ package android.content.pm;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.IntentSender;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
@@ -490,18 +488,6 @@ public class PackageInfo implements Parcelable {
     */
    public boolean isActiveApex;

    /**
     * Whether the package is currently in an archived state.
     *
     * <p>Packages can be archived through
     * {@link PackageInstaller#requestArchive(String, IntentSender)} and do not have any APKs stored
     * on the device, but do keep the data directory.
     * @hide
     */
    // TODO(b/278553670) Unhide and update @links before launch.
    @SystemApi
    public boolean isArchived;

    public PackageInfo() {
    }

@@ -589,7 +575,6 @@ public class PackageInfo implements Parcelable {
        }
        dest.writeBoolean(isApex);
        dest.writeBoolean(isActiveApex);
        dest.writeBoolean(isArchived);
        dest.restoreAllowSquashing(prevAllowSquashing);
    }

@@ -655,6 +640,5 @@ public class PackageInfo implements Parcelable {
        }
        isApex = source.readBoolean();
        isActiveApex = source.readBoolean();
        isArchived = source.readBoolean();
    }
}
+17 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.text.TextUtils.SAFE_STRING_FLAG_SINGLE_LINE;
import static android.text.TextUtils.SAFE_STRING_FLAG_TRIM;
import static android.text.TextUtils.makeSafeForPresentation;

import android.annotation.FlaggedApi;
import android.annotation.FloatRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
@@ -173,6 +174,18 @@ public class PackageItemInfo {
     */
    public int showUserIcon;

    /**
     * Whether the package is currently in an archived state.
     *
     * <p>Packages can be archived through {@link PackageArchiver} and do not have any APKs stored
     * on the device, but do keep the data directory.
     * @hide
     */
    // TODO(b/278553670) Unhide and update @links before launch.
    @SystemApi
    @FlaggedApi(Flags.FLAG_ARCHIVING)
    public boolean isArchived;

    public PackageItemInfo() {
        showUserIcon = UserHandle.USER_NULL;
    }
@@ -189,6 +202,7 @@ public class PackageItemInfo {
        logo = orig.logo;
        metaData = orig.metaData;
        showUserIcon = orig.showUserIcon;
        isArchived = orig.isArchived;
    }

    /**
@@ -442,6 +456,7 @@ public class PackageItemInfo {
        dest.writeBundle(metaData);
        dest.writeInt(banner);
        dest.writeInt(showUserIcon);
        dest.writeBoolean(isArchived);
    }

    /**
@@ -459,6 +474,7 @@ public class PackageItemInfo {
        }
        proto.write(PackageItemInfoProto.ICON, icon);
        proto.write(PackageItemInfoProto.BANNER, banner);
        proto.write(PackageItemInfoProto.IS_ARCHIVED, isArchived);
        proto.end(token);
    }

@@ -473,6 +489,7 @@ public class PackageItemInfo {
        metaData = source.readBundle();
        banner = source.readInt();
        showUserIcon = source.readInt();
        isArchived = source.readBoolean();
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ message PackageItemInfoProto {
    optional string non_localized_label = 4;
    optional int32 icon = 5;
    optional int32 banner = 6;
    optional bool is_archived = 7;
}

// Proto of android.content.pm.ApplicationInfo which extends PackageItemInfo
+1 −2
Original line number Diff line number Diff line
@@ -1024,7 +1024,7 @@ public class ComputerEngine implements Computer {
        if ("android".equals(packageName) || "system".equals(packageName)) {
            return androidApplication();
        }
        if ((flags & MATCH_KNOWN_PACKAGES) != 0) {
        if ((flags & (MATCH_KNOWN_PACKAGES | MATCH_ARCHIVED_PACKAGES)) != 0) {
            // Already generates the external package name
            return generateApplicationInfoFromSettings(packageName,
                    flags, filterCallingUid, userId);
@@ -1518,7 +1518,6 @@ public class ComputerEngine implements Computer {
            pi.sharedUserId = (sharedUser != null) ? sharedUser.getName() : null;
            pi.firstInstallTime = state.getFirstInstallTimeMillis();
            pi.lastUpdateTime = ps.getLastUpdateTime();
            pi.isArchived = isArchived(state);

            ApplicationInfo ai = new ApplicationInfo();
            ai.packageName = ps.getPackageName();
Loading