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

Commit b7158bbe authored by Nancy Chen's avatar Nancy Chen Committed by Android (Google) Code Review
Browse files

Merge "Add TelephonyManager N APIs for voicemail notifications." into ub-contactsdialer-b-dev

parents 4a459181 49344d82
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);
    }
}