Loading core/java/android/content/Context.java +20 −28 Original line number Original line Diff line number Diff line Loading @@ -3054,13 +3054,11 @@ public abstract class Context { * * * @param receiver The BroadcastReceiver to handle the broadcast. * @param receiver The BroadcastReceiver to handle the broadcast. * @param filter Selects the Intent broadcasts to be received. * @param filter Selects the Intent broadcasts to be received. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading Loading @@ -3137,13 +3135,11 @@ public abstract class Context { * no permission is required. * no permission is required. * @param scheduler Handler identifying the thread that will receive * @param scheduler Handler identifying the thread that will receive * the Intent. If null, the main thread of the process will be used. * the Intent. If null, the main thread of the process will be used. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading Loading @@ -3207,13 +3203,11 @@ public abstract class Context { * no permission is required. * no permission is required. * @param scheduler Handler identifying the thread that will receive * @param scheduler Handler identifying the thread that will receive * the Intent. If {@code null}, the main thread of the process will be used. * the Intent. If {@code null}, the main thread of the process will be used. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading Loading @@ -3282,13 +3276,11 @@ public abstract class Context { * no permission is required. * no permission is required. * @param scheduler Handler identifying the thread that will receive * @param scheduler Handler identifying the thread that will receive * the Intent. If null, the main thread of the process will be used. * the Intent. If null, the main thread of the process will be used. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading services/core/java/com/android/server/am/ActivityManagerService.java +10 −29 Original line number Original line Diff line number Diff line Loading @@ -208,7 +208,7 @@ import android.app.usage.UsageStatsManagerInternal; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManagerInternal; import android.appwidget.AppWidgetManagerInternal; import android.compat.annotation.ChangeId; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.compat.annotation.Disabled; import android.content.AttributionSource; import android.content.AttributionSource; import android.content.AutofillOptions; import android.content.AutofillOptions; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; Loading Loading @@ -461,14 +461,6 @@ public class ActivityManagerService extends IActivityManager.Stub private static final String SYSTEM_PROPERTY_DEVICE_PROVISIONED = private static final String SYSTEM_PROPERTY_DEVICE_PROVISIONED = "persist.sys.device_provisioned"; "persist.sys.device_provisioned"; /** * Enabling this flag enforces the requirement for context registered receivers to use one of * {@link Context#RECEIVER_EXPORTED} or {@link Context#RECEIVER_NOT_EXPORTED} for unprotected * broadcasts */ private static final boolean ENFORCE_DYNAMIC_RECEIVER_EXPLICIT_EXPORT = SystemProperties.getBoolean("fw.enforce_dynamic_receiver_explicit_export", false); static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityManagerService" : TAG_AM; static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityManagerService" : TAG_AM; static final String TAG_BACKUP = TAG + POSTFIX_BACKUP; static final String TAG_BACKUP = TAG + POSTFIX_BACKUP; private static final String TAG_BROADCAST = TAG + POSTFIX_BROADCAST; private static final String TAG_BROADCAST = TAG + POSTFIX_BROADCAST; Loading Loading @@ -585,7 +577,7 @@ public class ActivityManagerService extends IActivityManager.Stub * unprotected broadcast in code. * unprotected broadcast in code. */ */ @ChangeId @ChangeId @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU) @Disabled private static final long DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED = 161145287L; private static final long DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED = 161145287L; /** /** Loading Loading @@ -13070,25 +13062,14 @@ public class ActivityManagerService extends IActivityManager.Stub // sticky broadcast, no flag specified (flag isn't required) // sticky broadcast, no flag specified (flag isn't required) flags |= Context.RECEIVER_EXPORTED; flags |= Context.RECEIVER_EXPORTED; } else if (requireExplicitFlagForDynamicReceivers && !explicitExportStateDefined) { } else if (requireExplicitFlagForDynamicReceivers && !explicitExportStateDefined) { if (ENFORCE_DYNAMIC_RECEIVER_EXPLICIT_EXPORT) { throw new SecurityException( throw new SecurityException( callerPackage + ": Targeting T+ (version " callerPackage + ": One of RECEIVER_EXPORTED or " + Build.VERSION_CODES.TIRAMISU + "RECEIVER_NOT_EXPORTED should be specified when a receiver " + " and above) requires that one of RECEIVER_EXPORTED or " + "isn't being registered exclusively for system broadcasts"); + "RECEIVER_NOT_EXPORTED be specified when registering a " + "receiver"); } else { Slog.wtf(TAG, callerPackage + ": Targeting T+ (version " + Build.VERSION_CODES.TIRAMISU + " and above) requires that one of RECEIVER_EXPORTED or " + "RECEIVER_NOT_EXPORTED be specified when registering a " + "receiver"); // Assume default behavior-- flag check is not enforced // Assume default behavior-- flag check is not enforced flags |= Context.RECEIVER_EXPORTED; } else if (!requireExplicitFlagForDynamicReceivers && ( } (flags & Context.RECEIVER_NOT_EXPORTED) == 0)) { } else if (!requireExplicitFlagForDynamicReceivers) { // Change is not enabled, assume exported unless otherwise specified. // Change is not enabled, thus not targeting T+. Assume exported. flags |= Context.RECEIVER_EXPORTED; flags |= Context.RECEIVER_EXPORTED; } } } else if ((flags & Context.RECEIVER_NOT_EXPORTED) == 0) { } else if ((flags & Context.RECEIVER_NOT_EXPORTED) == 0) { Loading
core/java/android/content/Context.java +20 −28 Original line number Original line Diff line number Diff line Loading @@ -3054,13 +3054,11 @@ public abstract class Context { * * * @param receiver The BroadcastReceiver to handle the broadcast. * @param receiver The BroadcastReceiver to handle the broadcast. * @param filter Selects the Intent broadcasts to be received. * @param filter Selects the Intent broadcasts to be received. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading Loading @@ -3137,13 +3135,11 @@ public abstract class Context { * no permission is required. * no permission is required. * @param scheduler Handler identifying the thread that will receive * @param scheduler Handler identifying the thread that will receive * the Intent. If null, the main thread of the process will be used. * the Intent. If null, the main thread of the process will be used. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading Loading @@ -3207,13 +3203,11 @@ public abstract class Context { * no permission is required. * no permission is required. * @param scheduler Handler identifying the thread that will receive * @param scheduler Handler identifying the thread that will receive * the Intent. If {@code null}, the main thread of the process will be used. * the Intent. If {@code null}, the main thread of the process will be used. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading Loading @@ -3282,13 +3276,11 @@ public abstract class Context { * no permission is required. * no permission is required. * @param scheduler Handler identifying the thread that will receive * @param scheduler Handler identifying the thread that will receive * the Intent. If null, the main thread of the process will be used. * the Intent. If null, the main thread of the process will be used. * @param flags Additional options for the receiver. For apps targeting * @param flags Additional options for the receiver. In a future release, either * {@link android.os.Build.VERSION_CODES#TIRAMISU}, * {@link #RECEIVER_EXPORTED} or {@link #RECEIVER_NOT_EXPORTED} must be specified if the * either {@link #RECEIVER_EXPORTED} or * receiver isn't being registered for <a href="{@docRoot}guide/components * {@link #RECEIVER_NOT_EXPORTED} must be specified if the receiver isn't being registered * /broadcasts#system-broadcasts">system broadcasts</a> or an exception will be * for <a href="{@docRoot}guide/components/broadcasts#system-broadcasts">system * thrown. If {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * broadcasts</a> or an exception will be thrown. If * {@link #RECEIVER_EXPORTED} is specified, a receiver may additionally * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * specify {@link #RECEIVER_VISIBLE_TO_INSTANT_APPS}. For a complete list of * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * system broadcast actions, see the BROADCAST_ACTIONS.TXT file in the * Android SDK. If both {@link #RECEIVER_EXPORTED} and * Android SDK. If both {@link #RECEIVER_EXPORTED} and Loading
services/core/java/com/android/server/am/ActivityManagerService.java +10 −29 Original line number Original line Diff line number Diff line Loading @@ -208,7 +208,7 @@ import android.app.usage.UsageStatsManagerInternal; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManagerInternal; import android.appwidget.AppWidgetManagerInternal; import android.compat.annotation.ChangeId; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.compat.annotation.Disabled; import android.content.AttributionSource; import android.content.AttributionSource; import android.content.AutofillOptions; import android.content.AutofillOptions; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; Loading Loading @@ -461,14 +461,6 @@ public class ActivityManagerService extends IActivityManager.Stub private static final String SYSTEM_PROPERTY_DEVICE_PROVISIONED = private static final String SYSTEM_PROPERTY_DEVICE_PROVISIONED = "persist.sys.device_provisioned"; "persist.sys.device_provisioned"; /** * Enabling this flag enforces the requirement for context registered receivers to use one of * {@link Context#RECEIVER_EXPORTED} or {@link Context#RECEIVER_NOT_EXPORTED} for unprotected * broadcasts */ private static final boolean ENFORCE_DYNAMIC_RECEIVER_EXPLICIT_EXPORT = SystemProperties.getBoolean("fw.enforce_dynamic_receiver_explicit_export", false); static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityManagerService" : TAG_AM; static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityManagerService" : TAG_AM; static final String TAG_BACKUP = TAG + POSTFIX_BACKUP; static final String TAG_BACKUP = TAG + POSTFIX_BACKUP; private static final String TAG_BROADCAST = TAG + POSTFIX_BROADCAST; private static final String TAG_BROADCAST = TAG + POSTFIX_BROADCAST; Loading Loading @@ -585,7 +577,7 @@ public class ActivityManagerService extends IActivityManager.Stub * unprotected broadcast in code. * unprotected broadcast in code. */ */ @ChangeId @ChangeId @EnabledSince(targetSdkVersion = Build.VERSION_CODES.TIRAMISU) @Disabled private static final long DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED = 161145287L; private static final long DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED = 161145287L; /** /** Loading Loading @@ -13070,25 +13062,14 @@ public class ActivityManagerService extends IActivityManager.Stub // sticky broadcast, no flag specified (flag isn't required) // sticky broadcast, no flag specified (flag isn't required) flags |= Context.RECEIVER_EXPORTED; flags |= Context.RECEIVER_EXPORTED; } else if (requireExplicitFlagForDynamicReceivers && !explicitExportStateDefined) { } else if (requireExplicitFlagForDynamicReceivers && !explicitExportStateDefined) { if (ENFORCE_DYNAMIC_RECEIVER_EXPLICIT_EXPORT) { throw new SecurityException( throw new SecurityException( callerPackage + ": Targeting T+ (version " callerPackage + ": One of RECEIVER_EXPORTED or " + Build.VERSION_CODES.TIRAMISU + "RECEIVER_NOT_EXPORTED should be specified when a receiver " + " and above) requires that one of RECEIVER_EXPORTED or " + "isn't being registered exclusively for system broadcasts"); + "RECEIVER_NOT_EXPORTED be specified when registering a " + "receiver"); } else { Slog.wtf(TAG, callerPackage + ": Targeting T+ (version " + Build.VERSION_CODES.TIRAMISU + " and above) requires that one of RECEIVER_EXPORTED or " + "RECEIVER_NOT_EXPORTED be specified when registering a " + "receiver"); // Assume default behavior-- flag check is not enforced // Assume default behavior-- flag check is not enforced flags |= Context.RECEIVER_EXPORTED; } else if (!requireExplicitFlagForDynamicReceivers && ( } (flags & Context.RECEIVER_NOT_EXPORTED) == 0)) { } else if (!requireExplicitFlagForDynamicReceivers) { // Change is not enabled, assume exported unless otherwise specified. // Change is not enabled, thus not targeting T+. Assume exported. flags |= Context.RECEIVER_EXPORTED; flags |= Context.RECEIVER_EXPORTED; } } } else if ((flags & Context.RECEIVER_NOT_EXPORTED) == 0) { } else if ((flags & Context.RECEIVER_NOT_EXPORTED) == 0) {