Loading core/java/android/content/Intent.java +34 −0 Original line number Diff line number Diff line Loading @@ -7629,6 +7629,13 @@ 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. */ Loading Loading @@ -7682,6 +7689,11 @@ 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. Loading Loading @@ -12625,6 +12637,28 @@ 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) { services/core/java/com/android/server/am/ActivityManagerService.java +4 −22 Original line number Diff line number Diff line Loading @@ -5550,9 +5550,7 @@ public class ActivityManagerService extends IActivityManager.Stub for (int i=0; i<intents.length; i++) { Intent intent = intents[i]; if (intent != null) { if (intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); } intent.prepareToEnterSystemServer(); if (type == ActivityManager.INTENT_SENDER_BROADCAST && (intent.getFlags()&Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0) { throw new IllegalArgumentException( Loading Loading @@ -5585,7 +5583,6 @@ 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) { Loading Loading @@ -13961,12 +13958,7 @@ public class ActivityManagerService extends IActivityManager.Stub enforceNotIsolatedCaller("startService"); enforceAllowedToStartOrBindServiceIfSdkSandbox(service); if (service != null) { // 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); service.prepareToEnterSystemServer(); } if (callingPackage == null) { Loading Loading @@ -14203,12 +14195,7 @@ public class ActivityManagerService extends IActivityManager.Stub enforceAllowedToStartOrBindServiceIfSdkSandbox(service); if (service != null) { // 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); service.prepareToEnterSystemServer(); } if (callingPackage == null) { Loading Loading @@ -16242,12 +16229,7 @@ public class ActivityManagerService extends IActivityManager.Stub final Intent verifyBroadcastLocked(Intent intent) { if (intent != null) { // 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); intent.prepareToEnterSystemServer(); } int flags = intent.getFlags(); services/core/java/com/android/server/wm/ActivityStartController.java +1 −7 Original line number Diff line number Diff line Loading @@ -424,19 +424,13 @@ public class ActivityStartController { Intent intent = intents[i]; NeededUriGrants intentGrants = null; // Refuse possible leaked file descriptors. if (intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); } intent.prepareToEnterSystemServer(); // 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, Loading services/core/java/com/android/server/wm/ActivityStarter.java +1 −7 Original line number Diff line number Diff line Loading @@ -718,13 +718,7 @@ class ActivityStarter { onExecutionStarted(); if (mRequest.intent != null) { // 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); mRequest.intent.prepareToEnterSystemServer(); } final LaunchingState launchingState; Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −11 Original line number Diff line number Diff line Loading @@ -1318,12 +1318,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle bOptions) { enforceNotIsolatedCaller("startActivityIntentSender"); if (fillInIntent != null) { // Refuse possible leaked file descriptors if (fillInIntent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); } // Remove existing mismatch flag so it can be properly updated later fillInIntent.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH); fillInIntent.prepareToEnterSystemServer(); } if (!(target instanceof PendingIntentRecord)) { Loading @@ -1349,10 +1344,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public boolean startNextMatchingActivity(IBinder callingActivity, Intent intent, Bundle bOptions) { // Refuse possible leaked file descriptors if (intent != null && intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); if (intent != null) { intent.prepareToEnterSystemServer(); } SafeActivityOptions options = SafeActivityOptions.fromBundle(bOptions); synchronized (mGlobalLock) { Loading @@ -1367,8 +1362,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return false; } intent = new Intent(intent); // Remove existing mismatch flag so it can be properly updated later intent.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH); // The caller is not allowed to change the data. intent.setDataAndType(r.intent.getData(), r.intent.getType()); // And we are resetting to find the next component... Loading Loading
core/java/android/content/Intent.java +34 −0 Original line number Diff line number Diff line Loading @@ -7629,6 +7629,13 @@ 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. */ Loading Loading @@ -7682,6 +7689,11 @@ 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. Loading Loading @@ -12625,6 +12637,28 @@ 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) {
services/core/java/com/android/server/am/ActivityManagerService.java +4 −22 Original line number Diff line number Diff line Loading @@ -5550,9 +5550,7 @@ public class ActivityManagerService extends IActivityManager.Stub for (int i=0; i<intents.length; i++) { Intent intent = intents[i]; if (intent != null) { if (intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); } intent.prepareToEnterSystemServer(); if (type == ActivityManager.INTENT_SENDER_BROADCAST && (intent.getFlags()&Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0) { throw new IllegalArgumentException( Loading Loading @@ -5585,7 +5583,6 @@ 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) { Loading Loading @@ -13961,12 +13958,7 @@ public class ActivityManagerService extends IActivityManager.Stub enforceNotIsolatedCaller("startService"); enforceAllowedToStartOrBindServiceIfSdkSandbox(service); if (service != null) { // 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); service.prepareToEnterSystemServer(); } if (callingPackage == null) { Loading Loading @@ -14203,12 +14195,7 @@ public class ActivityManagerService extends IActivityManager.Stub enforceAllowedToStartOrBindServiceIfSdkSandbox(service); if (service != null) { // 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); service.prepareToEnterSystemServer(); } if (callingPackage == null) { Loading Loading @@ -16242,12 +16229,7 @@ public class ActivityManagerService extends IActivityManager.Stub final Intent verifyBroadcastLocked(Intent intent) { if (intent != null) { // 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); intent.prepareToEnterSystemServer(); } int flags = intent.getFlags();
services/core/java/com/android/server/wm/ActivityStartController.java +1 −7 Original line number Diff line number Diff line Loading @@ -424,19 +424,13 @@ public class ActivityStartController { Intent intent = intents[i]; NeededUriGrants intentGrants = null; // Refuse possible leaked file descriptors. if (intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); } intent.prepareToEnterSystemServer(); // 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, Loading
services/core/java/com/android/server/wm/ActivityStarter.java +1 −7 Original line number Diff line number Diff line Loading @@ -718,13 +718,7 @@ class ActivityStarter { onExecutionStarted(); if (mRequest.intent != null) { // 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); mRequest.intent.prepareToEnterSystemServer(); } final LaunchingState launchingState; Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −11 Original line number Diff line number Diff line Loading @@ -1318,12 +1318,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle bOptions) { enforceNotIsolatedCaller("startActivityIntentSender"); if (fillInIntent != null) { // Refuse possible leaked file descriptors if (fillInIntent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); } // Remove existing mismatch flag so it can be properly updated later fillInIntent.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH); fillInIntent.prepareToEnterSystemServer(); } if (!(target instanceof PendingIntentRecord)) { Loading @@ -1349,10 +1344,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public boolean startNextMatchingActivity(IBinder callingActivity, Intent intent, Bundle bOptions) { // Refuse possible leaked file descriptors if (intent != null && intent.hasFileDescriptors()) { throw new IllegalArgumentException("File descriptors passed in Intent"); if (intent != null) { intent.prepareToEnterSystemServer(); } SafeActivityOptions options = SafeActivityOptions.fromBundle(bOptions); synchronized (mGlobalLock) { Loading @@ -1367,8 +1362,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return false; } intent = new Intent(intent); // Remove existing mismatch flag so it can be properly updated later intent.removeExtendedFlags(Intent.EXTENDED_FLAG_FILTER_MISMATCH); // The caller is not allowed to change the data. intent.setDataAndType(r.intent.getData(), r.intent.getType()); // And we are resetting to find the next component... Loading