Merge changes from topic "cellbroadcastintents"

am: 6bcc4db8c0

Change-Id: Idd0a6a63731f996573f51e3343c3165d692d1adc
This commit is contained in:
Jordan Liu
2019-12-12 16:02:56 -08:00
committed by android-build-merger

View File

@@ -26,7 +26,6 @@ import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.UserHandle; import android.os.UserHandle;
import android.util.Log;
/** /**
* A static helper class used to send Intents with prepopulated flags. * 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 String receiverAppOp, @Nullable BroadcastReceiver resultReceiver,
@Nullable Handler scheduler, int initialCode, @Nullable String initialData, @Nullable Handler scheduler, int initialCode, @Nullable String initialData,
@Nullable Bundle initialExtras) { @Nullable Bundle initialExtras) {
Log.d(LOG_TAG, "sendOrderedBroadcastForBackgroundReceivers intent=" + intent.getAction());
int status = context.checkCallingOrSelfPermission( int status = context.checkCallingOrSelfPermission(
"android.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS"); "android.permission.GRANT_RUNTIME_PERMISSIONS_TO_TELEPHONY_DEFAULTS");
if (status == PackageManager.PERMISSION_DENIED) { if (status == PackageManager.PERMISSION_DENIED) {
throw new SecurityException( throw new SecurityException(
"Caller does not have permission to send broadcast for background receivers"); "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) { if (user != null) {
context.createContextAsUser(user, 0).sendOrderedBroadcast(intent, receiverPermission, context.createContextAsUser(user, 0).sendOrderedBroadcast(backgroundIntent,
receiverAppOp, resultReceiver, scheduler, initialCode, initialData, receiverPermission, receiverAppOp, resultReceiver, scheduler, initialCode,
initialExtras); initialData, initialExtras);
} else { } else {
context.sendOrderedBroadcast(intent, receiverPermission, context.sendOrderedBroadcast(backgroundIntent, receiverPermission,
receiverAppOp, resultReceiver, scheduler, initialCode, initialData, receiverAppOp, resultReceiver, scheduler, initialCode, initialData,
initialExtras); initialExtras);
} }