Allow broadcast receivers to receive DATA_SMS_RECEIVED_ACTION.
Amit Mahajan [Mon, 5 Jun 2017 12:16:17 +0000 (05:16 -0700)]
Allow apps in the background to receive DATA_SMS_RECEIVED_ACTION as
that behavior is consistent with other SMS related broadcast intents.

Test: Basic telephony sanity
Bug: 62106654
Change-Id: Ic9e8aad77a2a5705fcd1269a23fbcab7016d32b7

src/java/com/android/internal/telephony/InboundSmsHandler.java

index 6efd152..bb13648 100644 (file)
@@ -1121,6 +1121,9 @@ public abstract class InboundSmsHandler extends StateMachine {
             Uri uri = Uri.parse("sms://localhost:" + destPort);
             intent.setData(uri);
             intent.setComponent(null);
+            // Allow registered broadcast receivers to get this intent even
+            // when they are in the background.
+            intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
         }
 
         Bundle options = handleSmsWhitelisting(intent.getComponent());