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

Commit 49344d82 authored by Nancy Chen's avatar Nancy Chen
Browse files

Add TelephonyManager N APIs for voicemail notifications.

In N we can now get the voicemail notification settings from the system.
Make compat methods so they can be used in dialer.

Bug: 24164917
Change-Id: If940ae30fc989542e2cebb89cc6a1b630de66baf
parent e0eb3efb
Loading
Loading
Loading
Loading
+40 −1
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.contacts.common.compat;

import android.content.Context;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.telecom.PhoneAccountHandle;
import android.telephony.TelephonyManager;

import com.android.contacts.common.ContactsUtils;

public class TelephonyManagerCompat {
    public static final String TELEPHONY_MANAGER_CLASS = "android.telephony.TelephonyManager";

@@ -131,4 +134,40 @@ public class TelephonyManagerCompat {
        }
        return false;
    }

    /**
     * Returns the URI for the per-account voicemail ringtone set in Phone settings.
     *
     * @param telephonyManager The telephony manager instance to use for method calls.
     * @param accountHandle The handle for the {@link android.telecom.PhoneAccount} for which to
     * retrieve the voicemail ringtone.
     * @return The URI for the ringtone to play when receiving a voicemail from a specific
     * PhoneAccount.
     */
    @Nullable
    public static Uri getVoicemailRingtoneUri(TelephonyManager telephonyManager,
            PhoneAccountHandle accountHandle) {
        if (!CompatUtils.isNCompatible()) {
            return null;
        }
        return TelephonyManagerSdkCompat
                .getVoicemailRingtoneUri(telephonyManager, accountHandle);
    }

    /**
     * Returns whether vibration is set for voicemail notification in Phone settings.
     *
     * @param telephonyManager The telephony manager instance to use for method calls.
     * @param accountHandle The handle for the {@link android.telecom.PhoneAccount} for which to
     * retrieve the voicemail vibration setting.
     * @return {@code true} if the vibration is set for this PhoneAccount, {@code false} otherwise.
     */
    public static boolean isVoicemailVibrationEnabled(TelephonyManager telephonyManager,
            PhoneAccountHandle accountHandle) {
        if (!CompatUtils.isNCompatible()) {
            return true;
        }
        return TelephonyManagerSdkCompat
                .isVoicemailVibrationEnabled(telephonyManager, accountHandle);
    }
}