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

Commit 2d7212d8 authored by Ta-wei Yen's avatar Ta-wei Yen
Browse files

Add setVoicemailRingtoneUri() and setVoicemailVibrationEnabled()

This CL allows the default dialer to modify the voicemail ringtone.
All settings except the voicemail provider and voicemail nubmer can
be moved to the dialer after this CL.

Bug: 34626472
Fixes: 34626472
Test: CtsTelephonyTestCases TelephonyManagerTest
    testVoicemailRingtoneSettings and testVoicemailVibrationSettings

Change-Id: I5dd1e5ac8c358b09ff9a98051c429dba758c04a4
parent 4114a959
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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";
+2 −0
Original line number Diff line number Diff line
@@ -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);
+2 −0
Original line number Diff line number Diff line
@@ -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";
+48 −0
Original line number Diff line number Diff line
@@ -5906,6 +5906,29 @@ public class TelephonyManager {
        return null;
    }

    /**
     * Sets the per-account voicemail ringtone.
     *
     * <p>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.
     *
     * <p>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}.
     *
+28 −0
Original line number Diff line number Diff line
@@ -1145,6 +1145,20 @@ interface ITelephony {
     */
    Uri getVoicemailRingtoneUri(in PhoneAccountHandle accountHandle);

    /**
     * Sets the per-account voicemail ringtone.
     *
     * <p>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.
     *
     * <p>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.
     */