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

Commit 88704f0b authored by Jordan Liu's avatar Jordan Liu Committed by Android (Google) Code Review
Browse files

Merge "Do not modify passed in intent"

parents 6508e843 e1b7ab1a
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
import android.util.Log;

/**
 * A static helper class used to send Intents with prepopulated flags.
@@ -75,20 +74,20 @@ public class CellBroadcastIntents {
            @Nullable String receiverAppOp, @Nullable BroadcastReceiver resultReceiver,
            @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
            @Nullable Bundle initialExtras) {
        Log.d(LOG_TAG, "sendOrderedBroadcastForBackgroundReceivers intent=" + intent.getAction());
        int status = context.checkCallingOrSelfPermission(
                "android.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS");
        if (status == PackageManager.PERMISSION_DENIED) {
            throw new SecurityException(
                    "Caller does not have permission to send broadcast for background receivers");
        }
        intent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        Intent backgroundIntent = new Intent(intent);
        backgroundIntent.setFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
        if (user != null) {
            context.createContextAsUser(user, 0).sendOrderedBroadcast(intent, receiverPermission,
                    receiverAppOp, resultReceiver, scheduler, initialCode, initialData,
                    initialExtras);
            context.createContextAsUser(user, 0).sendOrderedBroadcast(backgroundIntent,
                    receiverPermission, receiverAppOp, resultReceiver, scheduler, initialCode,
                    initialData, initialExtras);
        } else {
            context.sendOrderedBroadcast(intent, receiverPermission,
            context.sendOrderedBroadcast(backgroundIntent, receiverPermission,
                    receiverAppOp, resultReceiver, scheduler, initialCode, initialData,
                    initialExtras);
        }