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

Commit e52a6063 authored by John Wu's avatar John Wu Committed by Android (Google) Code Review
Browse files

Merge "Revert "Introduce Intent#prepareToEnterSystemServer()"" into main

parents 58b8a8fb 380a4b24
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -7649,13 +7649,6 @@ public class Intent implements Parcelable, Cloneable {
            | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
            | FLAG_GRANT_PREFIX_URI_PERMISSION;
    /**
     * Flags that are not normally set by application code, but set for you by the system.
     */
    private static final int SYSTEM_ONLY_FLAGS = FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
            | FLAG_ACTIVITY_BROUGHT_TO_FRONT
            | FLAG_RECEIVER_FROM_SHELL;
    /**
     * Local flag indicating this instance was created by copy constructor.
     */
@@ -7709,11 +7702,6 @@ public class Intent implements Parcelable, Cloneable {
    @TestApi
    public static final int EXTENDED_FLAG_FILTER_MISMATCH = 1 << 0;
    /**
     * Extended flags that are not normally set by application code, but set for you by the system.
     */
    private static final int SYSTEM_ONLY_EXTENDED_FLAGS = EXTENDED_FLAG_FILTER_MISMATCH;
    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
    // toUri() and parseUri() options.
@@ -12657,28 +12645,6 @@ public class Intent implements Parcelable, Cloneable {
        }
    }
    /**
     * Prepare this {@link Intent} to enter system_server.
     *
     * @hide
     */
    public void prepareToEnterSystemServer() {
        // Refuse possible leaked file descriptors
        if (hasFileDescriptors()) {
            throw new IllegalArgumentException("File descriptors passed in Intent");
        }
        // These flags are set only by the system, and should be stripped out as soon as the intent
        // is received by system_server from the caller so it can be properly updated later.
        removeFlags(SYSTEM_ONLY_FLAGS);
        removeExtendedFlags(SYSTEM_ONLY_EXTENDED_FLAGS);
        if (mOriginalIntent != null) {
            mOriginalIntent.prepareToEnterSystemServer();
        }
        if (mSelector != null) {
            mSelector.prepareToEnterSystemServer();
        }
    }
    /** @hide */
    public boolean hasWebURI() {
        if (getData() == null) {
+16 −3
Original line number Diff line number Diff line
@@ -5426,7 +5426,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            for (int i=0; i<intents.length; i++) {
                Intent intent = intents[i];
                if (intent != null) {
                    intent.prepareToEnterSystemServer();
                    if (intent.hasFileDescriptors()) {
                        throw new IllegalArgumentException("File descriptors passed in Intent");
                    }
                    if (type == ActivityManager.INTENT_SENDER_BROADCAST &&
                            (intent.getFlags()&Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0) {
                        throw new IllegalArgumentException(
@@ -5459,6 +5461,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        }
                    }
                    intents[i] = new Intent(intent);
                    intents[i].removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH);
                }
            }
            if (resolvedTypes != null && resolvedTypes.length != intents.length) {
@@ -13591,7 +13594,12 @@ public class ActivityManagerService extends IActivityManager.Stub
        enforceNotIsolatedCaller("startService");
        enforceAllowedToStartOrBindServiceIfSdkSandbox(service);
        if (service != null) {
            service.prepareToEnterSystemServer();
            // Refuse possible leaked file descriptors
            if (service.hasFileDescriptors()) {
                throw new IllegalArgumentException("File descriptors passed in Intent");
            }
            // Remove existing mismatch flag so it can be properly updated later
            service.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH);
        }
        if (callingPackage == null) {
@@ -13828,7 +13836,12 @@ public class ActivityManagerService extends IActivityManager.Stub
        enforceAllowedToStartOrBindServiceIfSdkSandbox(service);
        if (service != null) {
            service.prepareToEnterSystemServer();
            // Refuse possible leaked file descriptors
            if (service.hasFileDescriptors()) {
                throw new IllegalArgumentException("File descriptors passed in Intent");
            }
            // Remove existing mismatch flag so it can be properly updated later
            service.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH);
        }
        if (callingPackage == null) {
+6 −1
Original line number Diff line number Diff line
@@ -1808,7 +1808,12 @@ class BroadcastController {

    final Intent verifyBroadcastLocked(Intent intent) {
        if (intent != null) {
            intent.prepareToEnterSystemServer();
            // Refuse possible leaked file descriptors
            if (intent.hasFileDescriptors()) {
                throw new IllegalArgumentException("File descriptors passed in Intent");
            }
            // Remove existing mismatch flag so it can be properly updated later
            intent.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH);
        }

        int flags = intent.getFlags();
+7 −1
Original line number Diff line number Diff line
@@ -424,13 +424,19 @@ public class ActivityStartController {
                Intent intent = intents[i];
                NeededUriGrants intentGrants = null;

                intent.prepareToEnterSystemServer();
                // Refuse possible leaked file descriptors.
                if (intent.hasFileDescriptors()) {
                    throw new IllegalArgumentException("File descriptors passed in Intent");
                }

                // Get the flag earlier because the intent may be modified in resolveActivity below.
                final boolean componentSpecified = intent.getComponent() != null;
                // Don't modify the client's object!
                intent = new Intent(intent);

                // Remove existing mismatch flag so it can be properly updated later
                intent.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH);

                // Collect information about the target of the Intent.
                ActivityInfo aInfo = mSupervisor.resolveActivity(intent, resolvedTypes[i],
                        0 /* startFlags */, null /* profilerInfo */, userId, filterCallingUid,
+7 −1
Original line number Diff line number Diff line
@@ -721,7 +721,13 @@ class ActivityStarter {
            onExecutionStarted();

            if (mRequest.intent != null) {
                mRequest.intent.prepareToEnterSystemServer();
                // Refuse possible leaked file descriptors
                if (mRequest.intent.hasFileDescriptors()) {
                    throw new IllegalArgumentException("File descriptors passed in Intent");
                }

                // Remove existing mismatch flag so it can be properly updated later
                mRequest.intent.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH);
            }

            final LaunchingState launchingState;
Loading