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

Commit 57225ce2 authored by Ivan Chiang's avatar Ivan Chiang
Browse files

[PM] Add new field mApexPackageName into PackageInfo

Bug: 306329516
Test: Let provide_info_of_apk_in_apex true on the device && atest
    PackageManagerTest PackageInfoTest
Change-Id: I80a9001e1b97b18417121d9fb4d6c8d279bd08c5
parent 53db794b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12379,6 +12379,7 @@ package android.content.pm {
  public class PackageInfo implements android.os.Parcelable {
    ctor public PackageInfo();
    method public int describeContents();
    method @FlaggedApi("android.content.pm.provide_info_of_apk_in_apex") @Nullable public String getApexPackageName();
    method @FlaggedApi("android.content.pm.archiving") public long getArchiveTimeMillis();
    method public long getLongVersionCode();
    method public void setLongVersionCode(long);
+40 −0
Original line number Diff line number Diff line
@@ -499,6 +499,16 @@ public class PackageInfo implements Parcelable {
     */
    public boolean isActiveApex;

    /**
     * If the package is an APEX package (i.e. the value of {@link #isApex}
     * is true), this field is the package name of the APEX. If the package
     * is one APK-in-APEX app, this field is the package name of the parent
     * APEX that contains the app. If the package is not one of the above
     * two cases, this field is {@code null}.
     */
    @Nullable
    private String mApexPackageName;

    public PackageInfo() {
    }

@@ -535,6 +545,26 @@ public class PackageInfo implements Parcelable {
        mArchiveTimeMillis = value;
    }

    /**
     * If the package is an APEX package (i.e. the value of {@link #isApex}
     * is true), returns the package name of the APEX. If the package
     * is one APK-in-APEX app, returns the package name of the parent
     * APEX that contains the app. If the package is not one of the above
     * two cases, returns {@code null}.
     */
    @Nullable
    @FlaggedApi(android.content.pm.Flags.FLAG_PROVIDE_INFO_OF_APK_IN_APEX)
    public String getApexPackageName() {
        return mApexPackageName;
    }

    /**
     * @hide
     */
    public void setApexPackageName(@Nullable String apexPackageName) {
        mApexPackageName = apexPackageName;
    }

    @Override
    public String toString() {
        return "PackageInfo{"
@@ -603,6 +633,12 @@ public class PackageInfo implements Parcelable {
        dest.writeBoolean(isApex);
        dest.writeBoolean(isActiveApex);
        dest.writeLong(mArchiveTimeMillis);
        if (mApexPackageName != null) {
            dest.writeInt(1);
            dest.writeString8(mApexPackageName);
        } else {
            dest.writeInt(0);
        }
        dest.restoreAllowSquashing(prevAllowSquashing);
    }

@@ -669,5 +705,9 @@ public class PackageInfo implements Parcelable {
        isApex = source.readBoolean();
        isActiveApex = source.readBoolean();
        mArchiveTimeMillis = source.readLong();
        int hasApexPackageName = source.readInt();
        if (hasApexPackageName != 0) {
            mApexPackageName = source.readString8();
        }
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.AuxiliaryResolveInfo;
import android.content.pm.ComponentInfo;
import android.content.pm.Flags;
import android.content.pm.InstallSourceInfo;
import android.content.pm.InstantAppRequest;
import android.content.pm.InstantAppResolveInfo;
@@ -1511,6 +1512,13 @@ public class ComputerEngine implements Computer {
            packageInfo.packageName = packageInfo.applicationInfo.packageName =
                    resolveExternalPackageName(p);

            if (Flags.provideInfoOfApkInApex()) {
                final String apexModuleName =  ps.getApexModuleName();
                if (apexModuleName != null) {
                    packageInfo.setApexPackageName(
                            mApexManager.getActivePackageNameForApexModuleName(apexModuleName));
                }
            }
            return packageInfo;
        } else if ((flags & (MATCH_UNINSTALLED_PACKAGES | MATCH_ARCHIVED_PACKAGES)) != 0
                && PackageUserStateUtils.isAvailable(state, flags)) {