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

Commit 4c5abc81 authored by Chad Brubaker's avatar Chad Brubaker
Browse files

Support subattribution for manifest receivers

This CL adds support for subattribution when sendBroadcast(Intent,
String) is used with an appop permission. This adds the new
android:attributionTag attribute to manifest receivers.

Fixes: 182313296
Test: atest AttributionTest
Change-Id: Ib315f95678204bc03e7ac354c54afbd64db403e8
parent 8529a9ba
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -329,6 +329,7 @@ package android {
    field public static final int apiKey = 16843281; // 0x1010211
    field public static final int appCategory = 16844101; // 0x1010545
    field public static final int appComponentFactory = 16844154; // 0x101057a
    field public static final int attributionTags = 16844353; // 0x1010641
    field public static final int author = 16843444; // 0x10102b4
    field public static final int authorities = 16842776; // 0x1010018
    field public static final int autoAdvanceViewId = 16843535; // 0x101030f
+19 −0
Original line number Diff line number Diff line
@@ -1086,6 +1086,13 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
     */
    public WindowLayout windowLayout;

    /**
     * Attribution tags for finer grained calls if a {@android.content.Context#sendBroadcast(Intent,
     * String)} is used with a permission.
     * @hide
     */
    public String[] attributionTags;

    public ActivityInfo() {
    }

@@ -1114,6 +1121,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        maxAspectRatio = orig.maxAspectRatio;
        minAspectRatio = orig.minAspectRatio;
        supportsSizeChanges = orig.supportsSizeChanges;
        attributionTags = orig.attributionTags;
    }

    /**
@@ -1361,6 +1369,15 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        if (supportsSizeChanges) {
            pw.println(prefix + "supportsSizeChanges=true");
        }
        if (attributionTags != null && attributionTags.length > 0) {
            StringBuilder tags = new StringBuilder();
            tags.append(attributionTags[0]);
            for (int i = 1; i < attributionTags.length; i++) {
                tags.append(", ");
                tags.append(attributionTags[i]);
            }
            pw.println(prefix + "attributionTags=[" + tags + "]");
        }
        super.dumpBack(pw, prefix, dumpFlags);
    }

@@ -1406,6 +1423,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        dest.writeFloat(maxAspectRatio);
        dest.writeFloat(minAspectRatio);
        dest.writeBoolean(supportsSizeChanges);
        dest.writeString8Array(attributionTags);
    }

    /**
@@ -1525,6 +1543,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
        maxAspectRatio = source.readFloat();
        minAspectRatio = source.readFloat();
        supportsSizeChanges = source.readBoolean();
        attributionTags = source.createString8Array();
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -482,6 +482,7 @@ public class PackageInfoWithoutStateUtils {
        ai.rotationAnimation = a.getRotationAnimation();
        ai.colorMode = a.getColorMode();
        ai.windowLayout = a.getWindowLayout();
        ai.attributionTags = a.getAttributionTags();
        if ((flags & PackageManager.GET_META_DATA) != 0) {
            ai.metaData = a.getMetaData();
        }
+12 −0
Original line number Diff line number Diff line
@@ -82,6 +82,9 @@ public class ParsedActivity extends ParsedMainComponent {
    @Nullable
    ActivityInfo.WindowLayout windowLayout;

    @Nullable
    String[] attributionTags;

    public ParsedActivity(ParsedActivity other) {
        super(other);
        this.theme = other.theme;
@@ -107,6 +110,7 @@ public class ParsedActivity extends ParsedMainComponent {
        this.rotationAnimation = other.rotationAnimation;
        this.colorMode = other.colorMode;
        this.windowLayout = other.windowLayout;
        this.attributionTags = other.attributionTags;
    }

    /**
@@ -172,6 +176,7 @@ public class ParsedActivity extends ParsedMainComponent {
        alias.requestedVrComponent = target.requestedVrComponent;
        alias.directBootAware = target.directBootAware;
        alias.setProcessName(target.getProcessName());
        alias.attributionTags = target.attributionTags;
        return alias;

        // Not all attributes from the target ParsedActivity are copied to the alias.
@@ -299,6 +304,7 @@ public class ParsedActivity extends ParsedMainComponent {
        } else {
            dest.writeBoolean(false);
        }
        dest.writeString8Array(this.attributionTags);
    }

    public ParsedActivity() {
@@ -332,6 +338,7 @@ public class ParsedActivity extends ParsedMainComponent {
        if (in.readBoolean()) {
            windowLayout = new ActivityInfo.WindowLayout(in);
        }
        this.attributionTags = in.createString8Array();
    }

    public static final Parcelable.Creator<ParsedActivity> CREATOR = new Creator<ParsedActivity>() {
@@ -445,4 +452,9 @@ public class ParsedActivity extends ParsedMainComponent {
    public ActivityInfo.WindowLayout getWindowLayout() {
        return windowLayout;
    }

    @Nullable
    public String[] getAttributionTags() {
        return attributionTags;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -210,6 +210,11 @@ public class ParsedActivityUtils {
                pkg.setVisibleToInstantApps(true);
            }

            String attributionTags = sa.getString(R.styleable.AndroidManifestActivity_attributionTags);
            if (attributionTags != null) {
                activity.attributionTags = attributionTags.split("\\|");
            }

            return parseActivityOrAlias(activity, pkg, tag, parser, res, sa, receiver,
                    false /*isAlias*/, visibleToEphemeral, input,
                    R.styleable.AndroidManifestActivity_parentActivityName,
Loading