Implement setVoicemailRingtoneUri and setVoicemailVibrationEnabled
Bug: 34626472
Fixes: 34626472
Test: CtsTelephonyTestCases TelephonyManagerTest
testVoicemailRingtoneSettings and testVoicemailVibrationSettings
Change-Id: Ie9827a2ef0b3ac25fe3c7c3b03a58fceee80daae
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 407d050..2aaa52a 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -3241,6 +3241,34 @@
}
/**
+ * 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.
+ */
+ @Override
+ public void setVoicemailRingtoneUri(String callingPackage,
+ PhoneAccountHandle phoneAccountHandle, Uri uri) {
+ mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
+ if (!TextUtils.equals(callingPackage,
+ TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage())) {
+ enforceModifyPermissionOrCarrierPrivilege(
+ PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle));
+ }
+ Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(phoneAccountHandle);
+ if (phone == null){
+ throw new IllegalArgumentException("The phoneAccountHandle does not correspond to an "
+ + "active phone account.");
+ }
+ VoicemailNotificationSettingsUtil.setRingtoneUri(phone, uri);
+ }
+
+ /**
* Returns whether vibration is set for voicemail notification in Phone settings.
*
* @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the
@@ -3258,6 +3286,35 @@
}
/**
+ * Sets the per-account voicemail vibration.
+ *
+ * <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.
+ */
+ @Override
+ public void setVoicemailVibrationEnabled(String callingPackage,
+ PhoneAccountHandle phoneAccountHandle, boolean enabled) {
+ mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
+ if (!TextUtils.equals(callingPackage,
+ TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage())) {
+ enforceModifyPermissionOrCarrierPrivilege(
+ PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle));
+ }
+
+ Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(phoneAccountHandle);
+ if (phone == null){
+ throw new IllegalArgumentException("The phoneAccountHandle does not correspond to an "
+ + "active phone account.");
+ }
+ VoicemailNotificationSettingsUtil.setVibrationEnabled(phone, enabled);
+ }
+
+ /**
* Make sure either called from same process as self (phone) or IPC caller has read privilege.
*
* @throws SecurityException if the caller does not have the required permission