diff --git a/api/current.txt b/api/current.txt index bcc3fb35fc669..e803efc8caa5e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -39312,6 +39312,8 @@ package android.telephony { method public boolean setOperatorBrandOverride(java.lang.String); method public boolean setPreferredNetworkTypeToGlobal(); method public boolean setVoiceMailNumber(java.lang.String, java.lang.String); + method public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri); + method public void setVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle, boolean); field public static final java.lang.String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL"; field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; diff --git a/api/system-current.txt b/api/system-current.txt index 5ac97c1b062c1..9ab8674a4698e 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -42711,6 +42711,8 @@ package android.telephony { method public boolean setRadioPower(boolean); method public void setVisualVoicemailEnabled(android.telecom.PhoneAccountHandle, boolean); method public boolean setVoiceMailNumber(java.lang.String, java.lang.String); + method public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri); + method public void setVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle, boolean); method public void silenceRinger(); method public boolean supplyPin(java.lang.String); method public int[] supplyPinReportResult(java.lang.String); diff --git a/api/test-current.txt b/api/test-current.txt index a5265b03e08bb..67579ff98993a 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -39448,6 +39448,8 @@ package android.telephony { method public boolean setOperatorBrandOverride(java.lang.String); method public boolean setPreferredNetworkTypeToGlobal(); method public boolean setVoiceMailNumber(java.lang.String, java.lang.String); + method public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri); + method public void setVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle, boolean); field public static final java.lang.String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL"; field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE"; field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE"; diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 4ff4d80f88dc9..c2c724fa0fdb4 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -5906,6 +5906,29 @@ public class TelephonyManager { return null; } + /** + * Sets the per-account voicemail ringtone. + * + *

Requires that the calling app is the default dialer, or has carrier privileges, or has + * permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + * + * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the + * voicemail ringtone. + * @param uri The URI for the ringtone to play when receiving a voicemail from a specific + * PhoneAccount. + * @see #hasCarrierPrivileges + */ + public void setVoicemailRingtoneUri(PhoneAccountHandle phoneAccountHandle, Uri uri) { + try { + ITelephony service = getITelephony(); + if (service != null) { + service.setVoicemailRingtoneUri(getOpPackageName(), phoneAccountHandle, uri); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#setVoicemailRingtoneUri", e); + } + } + /** * Returns whether vibration is set for voicemail notification in Phone settings. * @@ -5925,6 +5948,31 @@ public class TelephonyManager { return false; } + /** + * Sets the per-account preference whether vibration is enabled for voicemail notifications. + * + *

Requires that the calling app is the default dialer, or has carrier privileges, or has + * permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + * + * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the + * voicemail vibration setting. + * @param enabled Whether to enable or disable vibration for voicemail notifications from a + * specific PhoneAccount. + * @see #hasCarrierPrivileges + */ + public void setVoicemailVibrationEnabled(PhoneAccountHandle phoneAccountHandle, + boolean enabled) { + try { + ITelephony service = getITelephony(); + if (service != null) { + service.setVoicemailVibrationEnabled(getOpPackageName(), phoneAccountHandle, + enabled); + } + } catch (RemoteException e) { + Log.e(TAG, "Error calling ITelephony#isVoicemailVibrationEnabled", e); + } + } + /** * Return the application ID for the app type like {@link APPTYPE_CSIM}. * diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d90a33e1022d7..e6a6178dbba6d 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1145,6 +1145,20 @@ interface ITelephony { */ Uri getVoicemailRingtoneUri(in PhoneAccountHandle accountHandle); + /** + * Sets the per-account voicemail ringtone. + * + *

Requires that the calling app is the default dialer, or has carrier privileges, or + * has permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + * + * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the + * voicemail ringtone. + * @param uri The URI for the ringtone to play when receiving a voicemail from a specific + * PhoneAccount. + */ + void setVoicemailRingtoneUri(String callingPackage, + in PhoneAccountHandle phoneAccountHandle, in Uri uri); + /** * Returns whether vibration is set for voicemail notification in Phone settings. * @@ -1154,6 +1168,20 @@ interface ITelephony { */ boolean isVoicemailVibrationEnabled(in PhoneAccountHandle accountHandle); + /** + * Sets the per-account preference whether vibration is enabled for voicemail notifications. + * + *

Requires that the calling app is the default dialer, or has carrier privileges, or + * has permission {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}. + * + * @param phoneAccountHandle The handle for the {@link PhoneAccount} for which to set the + * voicemail vibration setting. + * @param enabled Whether to enable or disable vibration for voicemail notifications from a + * specific PhoneAccount. + */ + void setVoicemailVibrationEnabled(String callingPackage, + in PhoneAccountHandle phoneAccountHandle, boolean enabled); + /** * Returns a list of packages that have carrier privileges. */