diff --git a/api/current.txt b/api/current.txt index 23bcfa2712cfc..6d491cdac3f2b 100644 --- a/api/current.txt +++ b/api/current.txt @@ -38858,6 +38858,7 @@ package android.telephony { method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle); method public boolean isWorldPhone(); method public void listen(android.telephony.PhoneStateListener, int); + method public boolean sendDialerCode(java.lang.String); method public java.lang.String sendEnvelopeWithStatus(java.lang.String); method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler); method public void sendUssdRequest(java.lang.String, int, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler); diff --git a/api/system-current.txt b/api/system-current.txt index 0b98cac52abb8..7a08e8a7c977f 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -42211,6 +42211,7 @@ package android.telephony { method public boolean isWorldPhone(); method public void listen(android.telephony.PhoneStateListener, int); method public boolean needsOtaServiceProvisioning(); + method public boolean sendDialerCode(java.lang.String); method public java.lang.String sendEnvelopeWithStatus(java.lang.String); method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler); method public void sendUssdRequest(java.lang.String, int, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler); diff --git a/api/test-current.txt b/api/test-current.txt index 73f9ee4796ec5..cd335e771a097 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -38993,6 +38993,7 @@ package android.telephony { method public boolean isVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle); method public boolean isWorldPhone(); method public void listen(android.telephony.PhoneStateListener, int); + method public boolean sendDialerCode(java.lang.String); method public java.lang.String sendEnvelopeWithStatus(java.lang.String); method public void sendUssdRequest(java.lang.String, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler); method public void sendUssdRequest(java.lang.String, int, android.telephony.TelephonyManager.OnReceiveUssdResponseCallback, android.os.Handler); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5115edfcc9e8e..913da82cce772 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -2912,6 +2912,30 @@ public class TelephonyManager { } } + /** + * Send the special dialer code. The IPC caller must be the current default dialer. + *
+ * Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
+ *
+ * @param inputCode The special dialer code to send which follows the format of *#*##*#*
+ * @return true if sent sucessfully, false otherwise
+ *
+ */
+ public boolean sendDialerCode(String inputCode) {
+ try {
+ final ITelephony telephony = getITelephony();
+ if (telephony == null) {
+ Log.e(TAG, "Telephony service unavailable");
+ return false;
+ }
+ return telephony.sendDialerCode(mContext.getOpPackageName(), inputCode);
+ } catch (RemoteException | NullPointerException ex) {
+ // This could happen before phone restarts due to crashing
+ return false;
+ }
+ }
+
/**
* Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
* @return the IMPI, or null if not present or not loaded
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 8746f01928644..f2b8804e5e541 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -506,6 +506,9 @@ interface ITelephony {
oneway void sendVisualVoicemailSmsForSubscriber(in String callingPackage, in int subId,
in String number, in int port, in String text, in PendingIntent sentIntent);
+ // Send the special dialer code. The IPC caller must be the current default dialer.
+ boolean sendDialerCode(String callingPackageName, String inputCode);
+
/**
* Returns the network type for data transmission
* Legacy call, permission-free