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

Commit 12c4e719 authored by roldenburg's avatar roldenburg Committed by Copybara-Service
Browse files

Limit new special codes

Bug: 72162360
Test: SpecialCharSequenceMgrTest
PiperOrigin-RevId: 183921310
Change-Id: I3a47106a42a6e7c3b903f595f690c7d125e72a04
parent d6b91d1f
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.Settings;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
@@ -77,6 +78,19 @@ public class SpecialCharSequenceMgr {

  private static final String ADN_NAME_COLUMN_NAME = "name";
  private static final int ADN_QUERY_TOKEN = -1;

  @VisibleForTesting
  static final List<String> TRANSSION_CODES =
      new ArrayList<String>() {
        {
          add("*#07#");
          add("*#87#");
          add("#43#");
          add("*#2727#");
          add("#88#");
        }
      };

  /**
   * Remembers the previous {@link QueryHandler} and cancel the operation when needed, to prevent
   * possible crash.
@@ -144,10 +158,7 @@ public class SpecialCharSequenceMgr {
      TelephonyManagerCompat.handleSecretCode(context, secretCode);
      return true;
    }
    if (input.length() >= 4
        && input.startsWith("*#")
        && input.endsWith("#")
        && Character.isDigit(input.charAt(2))) {
    if (TRANSSION_CODES.contains(input)) {
      String secretCode = input.substring(2, input.length() - 1);
      TelephonyManagerCompat.handleSecretCode(context, secretCode);
      return true;