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

Commit 42a0152d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add support for forwarding more special codes"

parents 3bee9a13 6b0a018b
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -131,23 +131,30 @@ public class SpecialCharSequenceMgr {
  }

  /**
   * Handles secret codes to launch arbitrary activities in the form of *#*#<code>#*#*.
   * Handles secret codes to launch arbitrary activities in the form of
   * *#*#<code>#*#* or *#<code_starting_with_number>#.
   *
   * @param context the context to use
   * @param input the text to check for a secret code in
   * @return true if a secret code was encountered and handled
   */
  static boolean handleSecretCode(Context context, String input) {
    // Secret codes are accessed by dialing *#*#<code>#*#*

    int len = input.length();
    if (len <= 8 || !input.startsWith("*#*#") || !input.endsWith("#*#*")) {
      return false;
    // Secret codes are accessed by dialing *#*#<code>#*#* or "*#<code_starting_with_number>#"
    if (input.length() > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
      String secretCode = input.substring(4, input.length() - 4);
      TelephonyManagerCompat.handleSecretCode(context, secretCode);
      return true;
    }
    String secretCode = input.substring(4, len - 4);
    if (input.length() >= 4
        && input.startsWith("*#")
        && input.endsWith("#")
        && Character.isDigit(input.charAt(2))) {
      String secretCode = input.substring(2, input.length() - 1);
      TelephonyManagerCompat.handleSecretCode(context, secretCode);
      return true;
    }
    return false;
  }

  /**
   * Handle ADN requests by filling in the SIM contact number into the requested EditText.