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

Commit b92073c5 authored by Winson's avatar Winson
Browse files

Fix up PackageSetting pkg and path documentation

Renames baseCodePath -> baseApkPath and codePath -> path to better
reflect their actual meanings. Their respective JavaDoc has also been
consolidated and updated.

Also explains why the pkg field can be null, as this has been the cause
of a significant number of bugs. Also hides it behind a getter to
preempt any mutation issues. Doesn't refactor existing usages. This can
be done inline with other changes that touch that code.

Bug: 164218844
Bug: 164488334

Test: atest com.android.server.pm

Change-Id: Ia254e7cebb0ab86165e5ec42e8f8bfcf8673884b
parent f52bdb9c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -184,11 +184,11 @@ class PackageParsingPerfTest {

                override fun startParsingPackage(
                    packageName: String,
                    baseCodePath: String,
                    codePath: String,
                    baseApkPath: String,
                    path: String,
                    manifestArray: TypedArray,
                    isCoreApp: Boolean
                ) = ParsingPackageImpl(packageName, baseCodePath, codePath, manifestArray)
                ) = ParsingPackageImpl(packageName, baseApkPath, path, manifestArray)
            })

        override fun parseImpl(file: File) =
+2 −2
Original line number Diff line number Diff line
@@ -579,8 +579,8 @@ public class PackageInfoWithoutStateUtils {
        ii.handleProfiling = i.isHandleProfiling();
        ii.functionalTest = i.isFunctionalTest();

        ii.sourceDir = pkg.getBaseCodePath();
        ii.publicSourceDir = pkg.getBaseCodePath();
        ii.sourceDir = pkg.getBaseApkPath();
        ii.publicSourceDir = pkg.getBaseApkPath();
        ii.splitNames = pkg.getSplitNames();
        ii.splitSourceDirs = pkg.getSplitCodePaths();
        ii.splitPublicSourceDirs = pkg.getSplitCodePaths();
+18 −18
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
    private String realPackage;

    @NonNull
    protected String baseCodePath;
    protected String mBaseApkPath;

    private boolean requiredForAllUsers;
    @Nullable
@@ -280,7 +280,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {

    @NonNull
    @DataClass.ParcelWith(ForInternedString.class)
    protected String codePath;
    protected String mPath;

    private boolean use32BitAbi;
    private boolean visibleToInstantApps;
@@ -429,11 +429,11 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
    private ArraySet<String> mimeGroups;

    @VisibleForTesting
    public ParsingPackageImpl(@NonNull String packageName, @NonNull String baseCodePath,
            @NonNull String codePath, @Nullable TypedArray manifestArray) {
    public ParsingPackageImpl(@NonNull String packageName, @NonNull String baseApkPath,
            @NonNull String path, @Nullable TypedArray manifestArray) {
        this.packageName = TextUtils.safeIntern(packageName);
        this.baseCodePath = baseCodePath;
        this.codePath = codePath;
        this.mBaseApkPath = baseApkPath;
        this.mPath = path;

        if (manifestArray != null) {
            versionCode = manifestArray.getInteger(R.styleable.AndroidManifest_versionCode, 0);
@@ -954,10 +954,10 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
        appInfo.zygotePreloadName = zygotePreloadName;
        appInfo.crossProfile = isCrossProfile();
        appInfo.setGwpAsanMode(gwpAsanMode);
        appInfo.setBaseCodePath(baseCodePath);
        appInfo.setBaseResourcePath(baseCodePath);
        appInfo.setCodePath(codePath);
        appInfo.setResourcePath(codePath);
        appInfo.setBaseCodePath(mBaseApkPath);
        appInfo.setBaseResourcePath(mBaseApkPath);
        appInfo.setCodePath(mPath);
        appInfo.setResourcePath(mPath);
        appInfo.setSplitCodePaths(splitCodePaths);
        appInfo.setSplitResourcePaths(splitCodePaths);
        appInfo.setVersionCode(PackageInfo.composeLongVersionCode(versionCodeMajor, versionCode));
@@ -995,7 +995,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
        dest.writeString(this.compileSdkVersionCodeName);
        sForInternedString.parcel(this.packageName, dest, flags);
        dest.writeString(this.realPackage);
        dest.writeString(this.baseCodePath);
        dest.writeString(this.mBaseApkPath);
        dest.writeBoolean(this.requiredForAllUsers);
        dest.writeString(this.restrictedAccountType);
        dest.writeString(this.requiredAccountType);
@@ -1050,7 +1050,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
        dest.writeBundle(this.metaData);
        sForInternedString.parcel(this.volumeUuid, dest, flags);
        dest.writeParcelable(this.signingDetails, flags);
        dest.writeString(this.codePath);
        dest.writeString(this.mPath);
        dest.writeBoolean(this.use32BitAbi);
        dest.writeBoolean(this.visibleToInstantApps);
        dest.writeBoolean(this.forceQueryable);
@@ -1159,7 +1159,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
        this.compileSdkVersionCodeName = in.readString();
        this.packageName = sForInternedString.unparcel(in);
        this.realPackage = in.readString();
        this.baseCodePath = in.readString();
        this.mBaseApkPath = in.readString();
        this.requiredForAllUsers = in.readBoolean();
        this.restrictedAccountType = in.readString();
        this.requiredAccountType = in.readString();
@@ -1214,7 +1214,7 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {
        this.metaData = in.readBundle(boot);
        this.volumeUuid = sForInternedString.unparcel(in);
        this.signingDetails = in.readParcelable(boot);
        this.codePath = in.readString();
        this.mPath = in.readString();
        this.use32BitAbi = in.readBoolean();
        this.visibleToInstantApps = in.readBoolean();
        this.forceQueryable = in.readBoolean();
@@ -1363,8 +1363,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {

    @NonNull
    @Override
    public String getBaseCodePath() {
        return baseCodePath;
    public String getBaseApkPath() {
        return mBaseApkPath;
    }

    @Override
@@ -1649,8 +1649,8 @@ public class ParsingPackageImpl implements ParsingPackage, Parcelable {

    @NonNull
    @Override
    public String getCodePath() {
        return codePath;
    public String getPath() {
        return mPath;
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -548,7 +548,7 @@ public interface ParsingPackageRead extends Parcelable {
    String getPackageName();

    /** Path of base APK */
    String getBaseCodePath();
    String getBaseApkPath();

    /**
     * Path where this package was found on disk. For monolithic packages
@@ -556,7 +556,7 @@ public interface ParsingPackageRead extends Parcelable {
     * path to the cluster directory.
     */
    @NonNull
    String getCodePath();
    String getPath();

    /**
     * @see ApplicationInfo#compatibleWidthLimitDp
+10 −10
Original line number Diff line number Diff line
@@ -163,10 +163,10 @@ public class ParsingPackageUtils {
            @Override
            public ParsingPackage startParsingPackage(
                    @NonNull String packageName,
                    @NonNull String baseCodePath,
                    @NonNull String codePath,
                    @NonNull String baseApkPath,
                    @NonNull String path,
                    @NonNull TypedArray manifestArray, boolean isCoreApp) {
                return new ParsingPackageImpl(packageName, baseCodePath, codePath, manifestArray);
                return new ParsingPackageImpl(packageName, baseApkPath, path, manifestArray);
            }
        });
        try {
@@ -1215,9 +1215,9 @@ public class ParsingPackageUtils {
                features = ArrayUtils.add(features, featureInfo);
            } else {
                Slog.w(TAG,
                        "Unknown element under <feature-group>: " + innerTagName +
                                " at " + pkg.getBaseCodePath() + " " +
                                parser.getPositionDescription());
                        "Unknown element under <feature-group>: " + innerTagName
                                + " at " + pkg.getBaseApkPath() + " "
                                + parser.getPositionDescription());
            }
        }

@@ -2438,7 +2438,7 @@ public class ParsingPackageUtils {
                    R.styleable.AndroidManifestResourceOverlay_requiredSystemPropertyValue);
            if (!PackageParser.checkRequiredSystemProperties(propName, propValue)) {
                String message = "Skipping target and overlay pair " + target + " and "
                        + pkg.getBaseCodePath()
                        + pkg.getBaseApkPath()
                        + ": overlay ignored due to required system property: "
                        + propName + " with value: " + propValue;
                Slog.i(TAG, message);
@@ -2693,7 +2693,7 @@ public class ParsingPackageUtils {
                                    "<meta-data> only supports string, integer, float, color, "
                                            + "boolean, and resource reference types: "
                                            + parser.getName() + " at "
                                            + pkg.getBaseCodePath() + " "
                                            + pkg.getBaseApkPath() + " "
                                            + parser.getPositionDescription());
                        } else {
                            return input.error("<meta-data> only supports string, integer, float, "
@@ -2730,7 +2730,7 @@ public class ParsingPackageUtils {
        try {
            ParseResult<SigningDetails> result = getSigningDetails(
                    input,
                    pkg.getBaseCodePath(),
                    pkg.getBaseApkPath(),
                    skipVerify,
                    pkg.isStaticSharedLibrary(),
                    signingDetails,
@@ -2876,7 +2876,7 @@ public class ParsingPackageUtils {
        boolean hasFeature(String feature);

        ParsingPackage startParsingPackage(@NonNull String packageName,
                @NonNull String baseCodePath, @NonNull String codePath,
                @NonNull String baseApkPath, @NonNull String path,
                @NonNull TypedArray manifestArray, boolean isCoreApp);
    }
}
Loading