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

Commit 948f7bf3 authored by Winson's avatar Winson
Browse files

Split ParsedInstrumentationImpl

Bug: 178218967

Change-Id: I8aae52a92c879367e0c74d13dc452d8b8f081c95
parent 51649289
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.content.pm.parsing.component.ParsedAttribution;
import android.content.pm.parsing.component.ParsedAttributionImpl;
import android.content.pm.parsing.component.ParsedComponent;
import android.content.pm.parsing.component.ParsedInstrumentation;
import android.content.pm.parsing.component.ParsedInstrumentationImpl;
import android.content.pm.parsing.component.ParsedIntentInfo;
import android.content.pm.parsing.component.ParsedMainComponent;
import android.content.pm.parsing.component.ParsedPermission;
@@ -1295,7 +1296,8 @@ public class ParsingPackageImpl implements ParsingPackage, ParsingPackageHidden,
                ParsedAttributionImpl.CREATOR);
        this.permissions = in.createTypedArrayList(ParsedPermission.CREATOR);
        this.permissionGroups = in.createTypedArrayList(ParsedPermissionGroup.CREATOR);
        this.instrumentations = in.createTypedArrayList(ParsedInstrumentation.CREATOR);
        this.instrumentations = ParsingUtils.createTypedInterfaceList(in,
                ParsedInstrumentationImpl.CREATOR);
        this.preferredActivityFilters = sForIntentInfoPairs.unparcel(in);
        this.processes = in.readHashMap(boot);
        this.metaData = in.readBundle(boot);
+5 −101
Original line number Diff line number Diff line
@@ -16,114 +16,18 @@

package android.content.pm.parsing.component;

import static android.content.pm.parsing.ParsingPackageImpl.sForInternedString;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ComponentName;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.android.internal.util.DataClass;
import com.android.internal.util.Parcelling.BuiltIn.ForInternedString;

/** @hide */
public class ParsedInstrumentation extends ParsedComponentImpl {
public interface ParsedInstrumentation extends ParsedComponent {

    @Nullable
    @DataClass.ParcelWith(ForInternedString.class)
    private String targetPackage;
    @Nullable
    @DataClass.ParcelWith(ForInternedString.class)
    private String targetProcesses;
    private boolean handleProfiling;
    private boolean functionalTest;

    public ParsedInstrumentation() {
    }

    public ParsedInstrumentation setFunctionalTest(boolean functionalTest) {
        this.functionalTest = functionalTest;
        return this;
    }

    public ParsedInstrumentation setHandleProfiling(boolean handleProfiling) {
        this.handleProfiling = handleProfiling;
        return this;
    }

    public ParsedInstrumentation setTargetPackage(@Nullable String targetPackage) {
        this.targetPackage = TextUtils.safeIntern(targetPackage);
        return this;
    }

    public ParsedInstrumentation setTargetProcesses(@Nullable String targetProcesses) {
        this.targetProcesses = TextUtils.safeIntern(targetProcesses);
        return this;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("Instrumentation{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(' ');
        ComponentName.appendShortString(sb, getPackageName(), getName());
        sb.append('}');
        return sb.toString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        sForInternedString.parcel(this.targetPackage, dest, flags);
        sForInternedString.parcel(this.targetProcesses, dest, flags);
        dest.writeBoolean(this.handleProfiling);
        dest.writeBoolean(this.functionalTest);
    }

    protected ParsedInstrumentation(Parcel in) {
        super(in);
        this.targetPackage = sForInternedString.unparcel(in);
        this.targetProcesses = sForInternedString.unparcel(in);
        this.handleProfiling = in.readByte() != 0;
        this.functionalTest = in.readByte() != 0;
    }

    @NonNull
    public static final Parcelable.Creator<ParsedInstrumentation> CREATOR =
            new Parcelable.Creator<ParsedInstrumentation>() {
                @Override
                public ParsedInstrumentation createFromParcel(Parcel source) {
                    return new ParsedInstrumentation(source);
                }

                @Override
                public ParsedInstrumentation[] newArray(int size) {
                    return new ParsedInstrumentation[size];
                }
            };
    String getTargetPackage();

    @Nullable
    public String getTargetPackage() {
        return targetPackage;
    }
    String getTargetProcesses();

    @Nullable
    public String getTargetProcesses() {
        return targetProcesses;
    }
    boolean isFunctionalTest();

    public boolean isHandleProfiling() {
        return handleProfiling;
    }

    public boolean isFunctionalTest() {
        return functionalTest;
    }
    boolean isHandleProfiling();
}
+179 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.content.pm.parsing.component;

import static android.content.pm.parsing.ParsingPackageImpl.sForInternedString;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ComponentName;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.DataClass;
import com.android.internal.util.Parcelling.BuiltIn.ForInternedString;

/** @hide */
@DataClass(genGetters = true, genSetters = true, genBuilder = false, genParcelable = false)
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
public class ParsedInstrumentationImpl extends ParsedComponentImpl implements
        ParsedInstrumentation {

    @Nullable
    @DataClass.ParcelWith(ForInternedString.class)
    private String targetPackage;
    @Nullable
    @DataClass.ParcelWith(ForInternedString.class)
    private String targetProcesses;
    private boolean handleProfiling;
    private boolean functionalTest;

    public ParsedInstrumentationImpl() {
    }

    public ParsedInstrumentationImpl setTargetPackage(@Nullable String targetPackage) {
        this.targetPackage = TextUtils.safeIntern(targetPackage);
        return this;
    }

    public ParsedInstrumentationImpl setTargetProcesses(@Nullable String targetProcesses) {
        this.targetProcesses = TextUtils.safeIntern(targetProcesses);
        return this;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("Instrumentation{");
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(' ');
        ComponentName.appendShortString(sb, getPackageName(), getName());
        sb.append('}');
        return sb.toString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        sForInternedString.parcel(this.targetPackage, dest, flags);
        sForInternedString.parcel(this.targetProcesses, dest, flags);
        dest.writeBoolean(this.handleProfiling);
        dest.writeBoolean(this.functionalTest);
    }

    protected ParsedInstrumentationImpl(Parcel in) {
        super(in);
        this.targetPackage = sForInternedString.unparcel(in);
        this.targetProcesses = sForInternedString.unparcel(in);
        this.handleProfiling = in.readByte() != 0;
        this.functionalTest = in.readByte() != 0;
    }

    @NonNull
    public static final Parcelable.Creator<ParsedInstrumentationImpl> CREATOR =
            new Parcelable.Creator<ParsedInstrumentationImpl>() {
                @Override
                public ParsedInstrumentationImpl createFromParcel(Parcel source) {
                    return new ParsedInstrumentationImpl(source);
                }

                @Override
                public ParsedInstrumentationImpl[] newArray(int size) {
                    return new ParsedInstrumentationImpl[size];
                }
            };



    // Code below generated by codegen v1.0.23.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/parsing/component/ParsedInstrumentationImpl.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
    //@formatter:off


    @DataClass.Generated.Member
    public ParsedInstrumentationImpl(
            @Nullable String targetPackage,
            @Nullable String targetProcesses,
            boolean handleProfiling,
            boolean functionalTest) {
        this.targetPackage = targetPackage;
        this.targetProcesses = targetProcesses;
        this.handleProfiling = handleProfiling;
        this.functionalTest = functionalTest;

        // onConstructed(); // You can define this method to get a callback
    }

    @DataClass.Generated.Member
    public @Nullable String getTargetPackage() {
        return targetPackage;
    }

    @DataClass.Generated.Member
    public @Nullable String getTargetProcesses() {
        return targetProcesses;
    }

    @DataClass.Generated.Member
    public boolean isHandleProfiling() {
        return handleProfiling;
    }

    @DataClass.Generated.Member
    public boolean isFunctionalTest() {
        return functionalTest;
    }

    @DataClass.Generated.Member
    public @NonNull ParsedInstrumentationImpl setHandleProfiling( boolean value) {
        handleProfiling = value;
        return this;
    }

    @DataClass.Generated.Member
    public @NonNull ParsedInstrumentationImpl setFunctionalTest( boolean value) {
        functionalTest = value;
        return this;
    }

    @DataClass.Generated(
            time = 1627595809880L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/content/pm/parsing/component/ParsedInstrumentationImpl.java",
            inputSignatures = "private @android.annotation.Nullable @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) java.lang.String targetPackage\nprivate @android.annotation.Nullable @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) java.lang.String targetProcesses\nprivate  boolean handleProfiling\nprivate  boolean functionalTest\npublic static final @android.annotation.NonNull android.os.Parcelable.Creator<android.content.pm.parsing.component.ParsedInstrumentationImpl> CREATOR\npublic  android.content.pm.parsing.component.ParsedInstrumentationImpl setTargetPackage(java.lang.String)\npublic  android.content.pm.parsing.component.ParsedInstrumentationImpl setTargetProcesses(java.lang.String)\npublic  java.lang.String toString()\npublic @java.lang.Override int describeContents()\npublic @java.lang.Override void writeToParcel(android.os.Parcel,int)\nclass ParsedInstrumentationImpl extends android.content.pm.parsing.component.ParsedComponentImpl implements [android.content.pm.parsing.component.ParsedInstrumentation]\n@com.android.internal.util.DataClass(genGetters=true, genSetters=true, genBuilder=false, genParcelable=false)")
    @Deprecated
    private void __metadata() {}


    //@formatter:on
    // End of generated code

}
+12 −6
Original line number Diff line number Diff line
@@ -39,13 +39,13 @@ public class ParsedInstrumentationUtils {
    public static ParseResult<ParsedInstrumentation> parseInstrumentation(ParsingPackage pkg,
            Resources res, XmlResourceParser parser, boolean useRoundIcon,
            ParseInput input) throws IOException, XmlPullParserException {
        ParsedInstrumentation
                instrumentation = new ParsedInstrumentation();
        ParsedInstrumentationImpl
                instrumentation = new ParsedInstrumentationImpl();
        String tag = "<" + parser.getName() + ">";

        TypedArray sa = res.obtainAttributes(parser, R.styleable.AndroidManifestInstrumentation);
        try {
            ParseResult<ParsedInstrumentation> result = ParsedComponentUtils.parseComponent(
            ParseResult<ParsedInstrumentationImpl> result = ParsedComponentUtils.parseComponent(
                    instrumentation, tag, pkg, sa, useRoundIcon, input,
                    R.styleable.AndroidManifestInstrumentation_banner,
                    NOT_SET /*descriptionAttr*/,
@@ -55,7 +55,7 @@ public class ParsedInstrumentationUtils {
                    R.styleable.AndroidManifestInstrumentation_name,
                    R.styleable.AndroidManifestInstrumentation_roundIcon);
            if (result.isError()) {
                return result;
                return input.error(result);
            }

            // @formatter:off
@@ -70,7 +70,13 @@ public class ParsedInstrumentationUtils {
            sa.recycle();
        }

        return ComponentParseUtils.parseAllMetaData(pkg, res, parser, tag, instrumentation,
                input);
        ParseResult<ParsedInstrumentationImpl> result =
                ComponentParseUtils.parseAllMetaData(pkg, res, parser, tag, instrumentation, input);

        if (result.isError()) {
            return input.error(result);
        }

        return input.success(result.getResult());
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.content.pm.SharedLibraryInfo;
import android.content.pm.Signature;
import android.content.pm.SigningDetails;
import android.content.pm.parsing.ParsingPackageUtils;
import android.content.pm.parsing.component.ComponentMutateUtils;
import android.content.pm.parsing.component.ParsedInstrumentation;
import android.content.pm.pkg.PackageUserState;
import android.os.Binder;
@@ -603,7 +604,7 @@ final class InstallPackageHelper {
            int i;
            for (i = 0; i < collectionSize; i++) {
                ParsedInstrumentation a = pkg.getInstrumentations().get(i);
                a.setPackageName(pkg.getPackageName());
                ComponentMutateUtils.setPackageName(a, pkg.getPackageName());
                mPm.addInstrumentation(a.getComponentName(), a);
                if (chatty) {
                    if (r == null) {
Loading