diff --git a/api/current.txt b/api/current.txt index 745787a739359..4fd895946cb16 100644 --- a/api/current.txt +++ b/api/current.txt @@ -39333,6 +39333,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 d157bc19b2950..44d38472dca8b 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -42734,6 +42734,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 a83686f622b25..65cf84453f61c 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -39471,6 +39471,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. */