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

Commit 09fa87a1 authored by Your Name's avatar Your Name
Browse files

Prevent incorrect flag pairing.

Receivers should not be able to specify RECEIVER_VISIBLE_TO_INSTANT_APPS
while also specifying RECEIVER_NOT_EXPORTED. Receivers need to be
exported to be visible to Instant Apps.

Bug: 231146599
Test: Just throws an error
Change-Id: I3993087738e3e1c68833454e0c4999c5628bb8dd
parent b00aa4a7
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -13589,6 +13589,17 @@ public class ActivityManagerService extends IActivityManager.Stub
            // not be used generally, so we will be marking them as exported by default
            boolean requireExplicitFlagForDynamicReceivers = CompatChanges.isChangeEnabled(
                    DYNAMIC_RECEIVER_EXPLICIT_EXPORT_REQUIRED, callingUid);
            // A receiver that is visible to instant apps must also be exported.
            final boolean unexportedReceiverVisibleToInstantApps =
                    ((flags & Context.RECEIVER_VISIBLE_TO_INSTANT_APPS) != 0) && (
                            (flags & Context.RECEIVER_NOT_EXPORTED) != 0);
            if (unexportedReceiverVisibleToInstantApps && requireExplicitFlagForDynamicReceivers) {
                throw new IllegalArgumentException(
                        "Receiver can't specify both RECEIVER_VISIBLE_TO_INSTANT_APPS and "
                                + "RECEIVER_NOT_EXPORTED flag");
            }
            // STOPSHIP(b/259139792): Allow apps that are currently targeting U and in process of
            // updating their receivers to be exempt from this requirement until their receivers
            // are flagged.