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

Unverified Commit b104b6a6 authored by Varun Berry's avatar Varun Berry Committed by Kevin F. Haggerty
Browse files

Add a permission to guard receiving intents in StatusSmsFetcher.

Bug: 186405146
Test: manual.
Merged-In: I98e9c3ed64829d00ce3ce685108b076110741401
Change-Id: I8952243fd5aa093c97cf3a3923223b90c98f10e5
(cherry picked from commit f7944b6c)
Merged-In:I8952243fd5aa093c97cf3a3923223b90c98f10e5
parent 3250f375
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -70,6 +70,10 @@
   presses home. -->
  <uses-permission android:name="android.permission.STOP_APP_SWITCHES"/>

  <!-- Used for sending PendingIntents to dynamically registered receivers -->
  <uses-permission android:name="com.android.dialer.permission.DIALER_ORIGIN"
    android:protectionLevel="signature" />

  <!-- Permissions needed for badger count showing on launch icon. -->

  <!--for Samsung-->
+9 −2
Original line number Diff line number Diff line
@@ -54,8 +54,12 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable {

  private static final long STATUS_SMS_TIMEOUT_MILLIS = 60_000;

  private static final String PERMISSION_DIALER_ORIGIN =
    "com.android.dialer.permission.DIALER_ORIGIN";

  private static final String ACTION_REQUEST_SENT_INTENT =
      "com.android.voicemailomtp.sms.REQUEST_SENT";

  private static final int ACTION_REQUEST_SENT_REQUEST_CODE = 0;

  private CompletableFuture<Bundle> future = new CompletableFuture<>();
@@ -68,7 +72,7 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable {
    this.phoneAccountHandle = phoneAccountHandle;
    IntentFilter filter = new IntentFilter(ACTION_REQUEST_SENT_INTENT);
    filter.addAction(OmtpService.ACTION_SMS_RECEIVED);
    context.registerReceiver(this, filter);
    context.registerReceiver(this, filter, PERMISSION_DIALER_ORIGIN, /* scheduler= */ null);
  }

  @Override
@@ -90,7 +94,10 @@ public class StatusSmsFetcher extends BroadcastReceiver implements Closeable {
    // Because the receiver is registered dynamically, implicit intent must be used.
    // There should only be a single status SMS request at a time.
    return PendingIntent.getBroadcast(
        context, ACTION_REQUEST_SENT_REQUEST_CODE, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        context,
        ACTION_REQUEST_SENT_REQUEST_CODE,
        intent,
        PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
  }

  @Override