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

Commit e0c19be3 authored by Jordan Liu's avatar Jordan Liu Committed by android-build-merger
Browse files

Merge changes from topic "cellbroadcastintents"

am: 6bcc4db8

Change-Id: Idd0a6a63731f996573f51e3343c3165d692d1adc
parents 10373f03 6bcc4db8
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);
        }