Implement API methods to get voicemail notification settings.

Bug: 24164917
Change-Id: I1364a89a12f506a74d65ab86f445ff662a776381
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index b996f69..1997063 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -37,6 +37,7 @@
 import android.preference.PreferenceManager;
 import android.provider.Settings;
 import android.telecom.PhoneAccount;
+import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
 import android.telephony.CarrierConfigManager;
 import android.telephony.CellInfo;
@@ -75,6 +76,7 @@
 import com.android.internal.telephony.uicc.UiccCard;
 import com.android.internal.telephony.uicc.UiccController;
 import com.android.internal.util.HexDump;
+import com.android.phone.settings.VoicemailNotificationSettingsUtil;
 
 import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
 
@@ -2907,4 +2909,40 @@
 
         return phone.getServiceState();
     }
+
+    /**
+     * Returns the URI for the per-account voicemail ringtone set in Phone settings.
+     *
+     * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the
+     * voicemail ringtone.
+     * @return The URI for the ringtone to play when receiving a voicemail from a specific
+     * PhoneAccount.
+     */
+    @Override
+    public Uri getVoicemailRingtoneUri(PhoneAccountHandle accountHandle) {
+        final Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle);
+        if (phone == null) {
+            return null;
+        }
+
+        return VoicemailNotificationSettingsUtil.getRingtoneUri(phone);
+    }
+
+    /**
+     * Returns whether vibration is set for voicemail notification in Phone settings.
+     *
+     * @param accountHandle The handle for the {@link PhoneAccount} for which to retrieve the
+     * voicemail vibration setting.
+     * @return {@code true} if the vibration is set for this PhoneAccount, {@code false} otherwise.
+     */
+    @Override
+    public boolean isVoicemailVibrationEnabled(PhoneAccountHandle accountHandle) {
+        final Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle);
+        if (phone == null) {
+            return false;
+        }
+
+        return VoicemailNotificationSettingsUtil.isVibrationEnabled(phone);
+    }
+
 }
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 983967c..1749df2 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -2429,15 +2429,21 @@
     }
 
     public static int getSubIdForPhoneAccountHandle(PhoneAccountHandle handle) {
-        if (handle != null && handle.getComponentName().equals(getPstnConnectionServiceName())) {
-            Phone phone = getPhoneFromIccId(handle.getId());
-            if (phone != null) {
-                return phone.getSubId();
-            }
+        Phone phone = getPhoneForPhoneAccountHandle(handle);
+        if (phone != null) {
+            return phone.getSubId();
         }
         return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
     }
 
+    static Phone getPhoneForPhoneAccountHandle(PhoneAccountHandle handle) {
+        if (handle != null && handle.getComponentName().equals(getPstnConnectionServiceName())) {
+            return getPhoneFromIccId(handle.getId());
+        }
+        return null;
+    }
+
+
     /**
      * Determine if a given phone account corresponds to an active SIM
      *