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

Commit 3e3f4964 authored by Alex Kershaw's avatar Alex Kershaw
Browse files

Enforce the cross-profile intent check.

DocumentsUI currently hard-codes the IntentForwarderActivity class name.
It uses this to determine whether to show a 'switch to personal profile'
button. Essentially, it wants to know if the intent it received is a
cross-profile intent, so it asks package manager which intents can
resolve it and checks whether one of them is IntentForwarderActivity.

This is not CTS-enforced, so this CL ensures that it is. OEMs can remove
or rename IntentForwarderActivity as long as they update this API and
keep the corresponding CTS test passing.

Bug: 149568382
Bug: 136249261
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.ManagedProfileCrossProfileTest#testCrossProfileIntentFilters
Change-Id: I51916c13320420068987925ac979e59bef3b660d
parent d0f257eb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12327,6 +12327,7 @@ package android.content.pm {
    method public int describeContents();
    method public void dump(android.util.Printer, String);
    method public final int getIconResource();
    method public boolean isCrossProfileIntentForwarderActivity();
    method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
    method public CharSequence loadLabel(android.content.pm.PackageManager);
    method public void writeToParcel(android.os.Parcel, int);
+12 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ import java.util.Comparator;
 */
public class ResolveInfo implements Parcelable {
    private static final String TAG = "ResolveInfo";
    private static final String INTENT_FORWARDER_ACTIVITY =
            "com.android.internal.app.IntentForwarderActivity";

    /**
     * The activity or broadcast receiver that corresponds to this resolution
@@ -351,6 +353,16 @@ public class ResolveInfo implements Parcelable {
        }
    }

    /**
     * Returns whether this resolution represents the intent forwarder activity.
     *
     * @return whether this resolution represents the intent forwarder activity
     */
    public boolean isCrossProfileIntentForwarderActivity() {
        return activityInfo != null
                && INTENT_FORWARDER_ACTIVITY.equals(activityInfo.targetActivity);
    }

    public ResolveInfo() {
        targetUserId = UserHandle.USER_CURRENT;
    }