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

Commit a3cf17c7 authored by Jiju Kinattingal's avatar Jiju Kinattingal Committed by Linux Build Service Account
Browse files

Dialer(MSIM): Dialer app support for multisim

-Add support to handle the following commands/request on
 voice preferred subscription for multisim
 1) ADN entry MMI commands.
 2) Voicemail dial request.
 3) PIN/PUK MMI commands.

-Add voice mail subscription prompt for multisim:
 When prompt option is enabled in MultiSIM settings,
 check for the voicemail number on all subs and allow
 voice mail request if at least one sub has voice mail
 number associated with it.

CRs-Fixed: 718068

Conflicts:
src/com/android/dialer/SpecialCharSequenceMgr.java
Change-Id: I9a65978ec9d6b4deba94082e2892030aca620f25
parent 716d4add
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -27,9 +27,12 @@ import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Looper;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.WindowManager;
@@ -38,7 +41,7 @@ import android.widget.Toast;

import com.android.common.io.MoreCloseables;
import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler;

import com.android.internal.telephony.ITelephony;
/**
 * Helper class to listen for some magic character sequences
 * that are handled specially by the dialer.
@@ -208,7 +211,9 @@ public class SpecialCharSequenceMgr {
                sc.progressDialog.show();

                // run the query.
                handler.startQuery(ADN_QUERY_TOKEN, sc, Uri.parse("content://icc/adn"),
                long subId = SubscriptionManager.getDefaultVoiceSubId();
                Uri uri = Uri.parse("content://icc/adn/subId/" + subId);
                handler.startQuery(ADN_QUERY_TOKEN, sc, uri,
                        new String[]{ADN_PHONE_NUMBER_COLUMN_NAME}, null, null, null);

                if (sPreviousAdnQueryHandler != null) {
@@ -226,9 +231,14 @@ public class SpecialCharSequenceMgr {

    static boolean handlePinEntry(Context context, String input) {
        if ((input.startsWith("**04") || input.startsWith("**05")) && input.endsWith("#")) {
            TelecomManager telecomManager =
                    (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
            return telecomManager.handleMmi(input);
            long subId = SubscriptionManager.getDefaultVoiceSubId();
            try {
                return ITelephony.Stub.asInterface(ServiceManager.getService(
                        Context.TELEPHONY_SERVICE)).handlePinMmiForSubscriber(subId, input);
            } catch(RemoteException ex) {
                Log.e(TAG, "Remote Exception "+ex);
                return false;
            }
        }
        return false;
    }
@@ -237,7 +247,9 @@ public class SpecialCharSequenceMgr {
        TelephonyManager telephonyManager =
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (telephonyManager != null && input.equals(MMI_IMEI_DISPLAY)) {
            int phoneType = telephonyManager.getPhoneType();
            int phoneType;
            long subId = SubscriptionManager.getDefaultVoiceSubId();
            phoneType = telephonyManager.getCurrentPhoneType(subId);
            if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
                showIMEIPanel(context, useSystemWindow, telephonyManager);
                return true;
@@ -272,7 +284,10 @@ public class SpecialCharSequenceMgr {

    private static void showIMEIPanel(Context context, boolean useSystemWindow,
            TelephonyManager telephonyManager) {
        String imeiStr = telephonyManager.getDeviceId();
        String imeiStr = null;
        long subId = SubscriptionManager.getDefaultVoiceSubId();
        int slotId = SubscriptionManager.getSlotId(subId);
        imeiStr = telephonyManager.getDeviceId(slotId);

        AlertDialog alert = new AlertDialog.Builder(context)
                .setTitle(R.string.imei)
@@ -284,7 +299,10 @@ public class SpecialCharSequenceMgr {

    private static void showMEIDPanel(Context context, boolean useSystemWindow,
            TelephonyManager telephonyManager) {
        String meidStr = telephonyManager.getDeviceId();
        String meidStr = null;
        long subId = SubscriptionManager.getDefaultVoiceSubId();
        int slotId = SubscriptionManager.getSlotId(subId);
        meidStr = telephonyManager.getDeviceId(slotId);

        AlertDialog alert = new AlertDialog.Builder(context)
                .setTitle(R.string.meid)
+30 −5
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.SpannableString;
@@ -1640,15 +1641,39 @@ public class DialpadFragment extends AnalyticsFragment
     * @see TelephonyManager#getVoiceMailNumber()
     */
    private boolean isVoicemailAvailable() {
        boolean promptEnabled = SubscriptionManager.isVoicePromptEnabled();
        if (promptEnabled) {
            hasVMNumber();
        } else {
            long subId = SubscriptionManager.getDefaultVoiceSubId();
            try {
            return getTelephonyManager().getVoiceMailNumber() != null;
                return getTelephonyManager().getVoiceMailNumber(subId) != null;
            } catch (SecurityException se) {
                // Possibly no READ_PHONE_STATE privilege.
                Log.w(TAG, "SecurityException is thrown. Maybe privilege isn't sufficient.");
            }
        }
        return false;
    }

    private boolean hasVMNumber() {
        boolean hasVMNum = false;
        int phoneCount = getTelephonyManager().getPhoneCount();
        for (int i = 0; i < phoneCount; i++) {
            try {
                long[] subId = SubscriptionManager.getSubId(i);
                hasVMNum = getTelephonyManager().getVoiceMailNumber(subId[0]) != null;
            } catch (SecurityException se) {
                // Possibly no READ_PHONE_STATE privilege.
                Log.e(TAG, "hasVMNumber: SecurityException, Maybe privilege isn't sufficient.");
            }
            if (hasVMNum) {
                break;
            }
        }
        return hasVMNum;
    }

    /**
     * Returns true of the newDigit parameter can be added at the current selection
     * point, otherwise returns false.