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

Commit 550b03b3 authored by Nancy Chen's avatar Nancy Chen Committed by Natiq Ahmed
Browse files

Use Telecom API for checking if a number is voicemail (2/2)

Since we don't want to communicate directly with Telephony in dialer,
call
PhoneNumberUtils.isVoiceMailNumber (a Telephony method) through the
Telecom API. Add a method in TelecomManager to do this.

Bug: 17925501
Conflicts:
	src/com/android/server/telecom/TelecomServiceImpl.java

Change-Id: Id1e5824f27ef40f64b8a03ee912d82d1cc5324ac
parent cb71babf
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.telecom.ConnectionService;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.content.ComponentName;
import android.content.Context;
import android.net.Uri;
@@ -115,6 +116,36 @@ public final class PhoneAccountRegistrar {
        read();
    }

    /**
     * Retrieves the phone account id for a given subscription id if it exists. Subscription ids
     * apply only to PSTN/SIM card phone accounts so all other accounts should not have a
     * subscription id.
     * @param subscriptionId The subscription id for which to construct the phone account id
     * @return The string representing the phone account id for the subscription id.
     */
    public String getPhoneAccountIdForSubscriptionId(long subscriptionId) {
        return String.valueOf(subscriptionId);
    }

    /**
     * Retrieves the subscription id for a given phone account if it exists. Subscription ids
     * apply only to PSTN/SIM card phone accounts so all other accounts should not have a
     * subscription id.
     * @param accountHandle The handle for the phone account for which to retrieve the
     * subscription id.
     * @return The value of the subscription id (long) or -1 if it does not exist or is not valid.
     */
    public long getSubscriptionIdForPhoneAccount(PhoneAccountHandle accountHandle) {
        PhoneAccount account = getPhoneAccount(accountHandle);
        if (account == null || !account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) ||
                !TextUtils.isDigitsOnly(accountHandle.getId())) {
            // Since no decimals or negative numbers can be valid subscription ids, only a string of
            // numbers can be subscription id
            return -1;
        }
        return Long.parseLong(accountHandle.getId());
    }

    /**
     * Retrieves the default outgoing phone account supporting the specified uriScheme.
     * @param uriScheme The URI scheme for the outgoing call.
@@ -486,6 +517,11 @@ public final class PhoneAccountRegistrar {
        }
    }

    public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) {
        long subId = getSubscriptionIdForPhoneAccount(accountHandle);
        return PhoneNumberUtils.isVoiceMailNumber(subId, number);
    }

    public void addListener(Listener l) {
        mListeners.add(l);
    }
+2 −5
Original line number Diff line number Diff line
@@ -450,10 +450,7 @@ public class TelecomService extends Service {
        /**
         * @see android.telecom.TelecomManager#isVoiceMailNumber
         */
        /* FIXME_L-MR1_INTERNAL, uncomment below code, when relevant change
         * is merged
         */
        /* @Override
        @Override
        public boolean isVoiceMailNumber(PhoneAccountHandle accountHandle, String number) {
            enforceReadPermissionOrDefaultDialer();
            try {
@@ -466,7 +463,7 @@ public class TelecomService extends Service {
                Log.e(this, e, "getSubscriptionIdForPhoneAccount");
                throw e;
            }
        }*/
        }

        /**
         * @see android.telecom.TelecomManager#hasVoiceMailNumber