Use SystemApi to broadcast to background receivers

Bug: 144108192
Test: manually verify that new API call succeeds
Change-Id: I4bcac6e635bd2303bc4f9f82425984fefc85a793
Merged-In: I4bcac6e635bd2303bc4f9f82425984fefc85a793
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index 200b4bb..11b0965 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -45,6 +45,7 @@
 import android.provider.Telephony.CellBroadcasts;
 import android.telephony.CbGeoUtils.Geometry;
 import android.telephony.CbGeoUtils.LatLng;
+import android.telephony.CellBroadcastIntents;
 import android.telephony.Rlog;
 import android.telephony.SmsCbMessage;
 import android.telephony.SubscriptionManager;
@@ -515,10 +516,9 @@
             msg = "Dispatching SMS CB, SmsCbMessage is: " + message;
             log(msg);
             mLocalLog.log(msg);
-            intent = new Intent(Telephony.Sms.Intents.SMS_CB_RECEIVED_ACTION);
             // Send implicit intent since there are various 3rd party carrier apps listen to
             // this intent.
-            intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+            intent = new Intent(Telephony.Sms.Intents.SMS_CB_RECEIVED_ACTION);
             receiverPermission = Manifest.permission.RECEIVE_SMS;
             appOp = AppOpsManager.OPSTR_RECEIVE_SMS;
 
@@ -526,9 +526,10 @@
             putPhoneIdAndSubIdExtra(mContext, intent, slotIndex);
 
             mReceiverCount.incrementAndGet();
-            mContext.createContextAsUser(UserHandle.ALL, 0).sendOrderedBroadcast(
-                    intent, receiverPermission, appOp, mReceiver, getHandler(),
-                    Activity.RESULT_OK, null, null);
+            CellBroadcastIntents.sendOrderedBroadcastForBackgroundReceivers(
+                    mContext, UserHandle.ALL, intent,
+                    receiverPermission, appOp, mReceiver, getHandler(), Activity.RESULT_OK,
+                    null, null);
         }
 
         if (messageUri != null) {