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

Commit e189547d authored by Winson's avatar Winson
Browse files

Split ParsedProviderImpl

Bug: 178218967

Change-Id: I5ce7cec075f5d596972c9f67f276bfd576635c5a
parent 90b53e1a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.content.pm.parsing.component.ParsedPermission;
import android.content.pm.parsing.component.ParsedPermissionGroup;
import android.content.pm.parsing.component.ParsedProcess;
import android.content.pm.parsing.component.ParsedProvider;
import android.content.pm.parsing.component.ParsedProviderImpl;
import android.content.pm.parsing.component.ParsedService;
import android.content.pm.parsing.component.ParsedUsesPermission;
import android.content.res.TypedArray;
@@ -1287,7 +1288,7 @@ public class ParsingPackageImpl implements ParsingPackage, ParsingPackageHidden,
        this.activities = ParsingUtils.createTypedInterfaceList(in, ParsedActivityImpl.CREATOR);
        this.receivers = ParsingUtils.createTypedInterfaceList(in, ParsedActivityImpl.CREATOR);
        this.services = in.createTypedArrayList(ParsedService.CREATOR);
        this.providers = in.createTypedArrayList(ParsedProvider.CREATOR);
        this.providers = ParsingUtils.createTypedInterfaceList(in, ParsedProviderImpl.CREATOR);
        this.attributions = in.createTypedArrayList(ParsedAttribution.CREATOR);
        this.permissions = in.createTypedArrayList(ParsedPermission.CREATOR);
        this.permissionGroups = in.createTypedArrayList(ParsedPermissionGroup.CREATOR);
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.pm.parsing.component;

import android.annotation.NonNull;
import android.annotation.Nullable;

/**
 * Contains mutation methods so that code doesn't have to cast to the Impl. Meant to eventually
@@ -66,4 +67,12 @@ public class ComponentMutateUtils {
    public static void setExported(@NonNull ParsedMainComponent component, boolean exported) {
        ((ParsedMainComponentImpl) component).setExported(exported);
    }

    public static void setAuthority(@NonNull ParsedProvider provider, @Nullable String authority) {
        ((ParsedProviderImpl) provider).setAuthority(authority);
    }

    public static void setSyncable(@NonNull ParsedProvider provider, boolean syncable) {
        ((ParsedProviderImpl) provider).setSyncable(syncable);
    }
}
+6 −6
Original line number Diff line number Diff line
@@ -86,9 +86,9 @@ public abstract class ParsedComponentImpl implements ParsedComponent {

    }

    protected ParsedComponentImpl(ParsedComponentImpl other) {
        this.metaData = other.metaData;
        this.name = other.name;
    protected ParsedComponentImpl(ParsedComponent other) {
        this.metaData = other.getMetaData();
        this.name = other.getName();
        this.icon = other.getIcon();
        this.labelRes = other.getLabelRes();
        this.nonLocalizedLabel = other.getNonLocalizedLabel();
@@ -96,11 +96,11 @@ public abstract class ParsedComponentImpl implements ParsedComponent {
        this.banner = other.getBanner();
        this.descriptionRes = other.getDescriptionRes();
        this.flags = other.getFlags();
        this.packageName = other.packageName;
        this.componentName = other.componentName;
        this.packageName = other.getPackageName();
        this.componentName = other.getComponentName();
        this.intents = new ArrayList<>(other.getIntents());
        this.mProperties = new ArrayMap<>();
        this.mProperties.putAll(other.mProperties);
        this.mProperties.putAll(other.getProperties());
    }

    public void addIntent(ParsedIntentInfo intent) {
+8 −8
Original line number Diff line number Diff line
@@ -48,15 +48,15 @@ public class ParsedMainComponentImpl extends ParsedComponentImpl implements Pars
    public ParsedMainComponentImpl() {
    }

    public ParsedMainComponentImpl(ParsedMainComponentImpl other) {
    public ParsedMainComponentImpl(ParsedMainComponent other) {
        super(other);
        this.processName = other.processName;
        this.directBootAware = other.directBootAware;
        this.enabled = other.enabled;
        this.exported = other.exported;
        this.order = other.order;
        this.splitName = other.splitName;
        this.attributionTags = other.attributionTags;
        this.processName = other.getProcessName();
        this.directBootAware = other.isDirectBootAware();
        this.enabled = other.isEnabled();
        this.exported = other.isExported();
        this.order = other.getOrder();
        this.splitName = other.getSplitName();
        this.attributionTags = other.getAttributionTags();
    }

    public ParsedMainComponentImpl setProcessName(String processName) {
+11 −194
Original line number Diff line number Diff line
@@ -16,214 +16,31 @@

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.content.pm.PathPermission;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PatternMatcher;
import android.text.TextUtils;

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

/** @hide **/
public class ParsedProvider extends ParsedMainComponentImpl {
public interface ParsedProvider extends ParsedMainComponent {

    @NonNull
    @DataClass.ParcelWith(ForInternedString.class)
    private String authority;
    private boolean syncable;
    @Nullable
    @DataClass.ParcelWith(ForInternedString.class)
    private String readPermission;
    @Nullable
    @DataClass.ParcelWith(ForInternedString.class)
    private String writePermission;
    private boolean grantUriPermissions;
    private boolean forceUriPermissions;
    private boolean multiProcess;
    private int initOrder;
    @Nullable
    private PatternMatcher[] uriPermissionPatterns;
    @Nullable
    private PathPermission[] pathPermissions;
    String getAuthority();

    public ParsedProvider(ParsedProvider other) {
        super(other);
    int getInitOrder();

        this.authority = other.authority;
        this.syncable = other.syncable;
        this.readPermission = other.readPermission;
        this.writePermission = other.writePermission;
        this.grantUriPermissions = other.grantUriPermissions;
        this.forceUriPermissions = other.forceUriPermissions;
        this.multiProcess = other.multiProcess;
        this.initOrder = other.initOrder;
        this.uriPermissionPatterns = other.uriPermissionPatterns;
        this.pathPermissions = other.pathPermissions;
    }
    boolean isMultiProcess();

    public ParsedProvider setAuthority(String authority) {
        this.authority = TextUtils.safeIntern(authority);
        return this;
    }
    @Nullable PathPermission[] getPathPermissions();

    public ParsedProvider setForceUriPermissions(boolean forceUriPermissions) {
        this.forceUriPermissions = forceUriPermissions;
        return this;
    }
    @Nullable String getReadPermission();

    public ParsedProvider setGrantUriPermissions(boolean grantUriPermissions) {
        this.grantUriPermissions = grantUriPermissions;
        return this;
    }
    @Nullable PatternMatcher[] getUriPermissionPatterns();

    public ParsedProvider setInitOrder(int initOrder) {
        this.initOrder = initOrder;
        return this;
    }
    @Nullable String getWritePermission();

    public ParsedProvider setMultiProcess(boolean multiProcess) {
        this.multiProcess = multiProcess;
        return this;
    }
    boolean isForceUriPermissions();

    public ParsedProvider setPathPermissions(PathPermission[] pathPermissions) {
        this.pathPermissions = pathPermissions;
        return this;
    }
    boolean isGrantUriPermissions();

    public ParsedProvider setSyncable(boolean syncable) {
        this.syncable = syncable;
        return this;
    }

    public ParsedProvider setReadPermission(String readPermission) {
        // Empty string must be converted to null
        this.readPermission = TextUtils.isEmpty(readPermission)
                ? null : readPermission.intern();
        return this;
    }

    public ParsedProvider setUriPermissionPatterns(PatternMatcher[] uriPermissionPatterns) {
        this.uriPermissionPatterns = uriPermissionPatterns;
        return this;
    }

    public ParsedProvider setWritePermission(String writePermission) {
        // Empty string must be converted to null
        this.writePermission = TextUtils.isEmpty(writePermission)
                ? null : writePermission.intern();
        return this;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(128);
        sb.append("Provider{");
        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);
        dest.writeString(this.authority);
        dest.writeBoolean(this.syncable);
        sForInternedString.parcel(this.readPermission, dest, flags);
        sForInternedString.parcel(this.writePermission, dest, flags);
        dest.writeBoolean(this.grantUriPermissions);
        dest.writeBoolean(this.forceUriPermissions);
        dest.writeBoolean(this.multiProcess);
        dest.writeInt(this.initOrder);
        dest.writeTypedArray(this.uriPermissionPatterns, flags);
        dest.writeTypedArray(this.pathPermissions, flags);
    }

    public ParsedProvider() {
    }

    protected ParsedProvider(Parcel in) {
        super(in);
        //noinspection ConstantConditions
        this.authority = in.readString();
        this.syncable = in.readBoolean();
        this.readPermission = sForInternedString.unparcel(in);
        this.writePermission = sForInternedString.unparcel(in);
        this.grantUriPermissions = in.readBoolean();
        this.forceUriPermissions = in.readBoolean();
        this.multiProcess = in.readBoolean();
        this.initOrder = in.readInt();
        this.uriPermissionPatterns = in.createTypedArray(PatternMatcher.CREATOR);
        this.pathPermissions = in.createTypedArray(PathPermission.CREATOR);
    }

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

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

    @NonNull
    public String getAuthority() {
        return authority;
    }

    public boolean isSyncable() {
        return syncable;
    }

    @Nullable
    public String getReadPermission() {
        return readPermission;
    }

    @Nullable
    public String getWritePermission() {
        return writePermission;
    }

    public boolean isGrantUriPermissions() {
        return grantUriPermissions;
    }

    public boolean isForceUriPermissions() {
        return forceUriPermissions;
    }

    public boolean isMultiProcess() {
        return multiProcess;
    }

    public int getInitOrder() {
        return initOrder;
    }

    @Nullable
    public PatternMatcher[] getUriPermissionPatterns() {
        return uriPermissionPatterns;
    }

    @Nullable
    public PathPermission[] getPathPermissions() {
        return pathPermissions;
    }
    boolean isSyncable();
}
Loading