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

Commit 87c9459f authored by Sindhu Kanathur's avatar Sindhu Kanathur Committed by Linux Build Service Account
Browse files

Dialer: Display 14 digit IMEI(Ignore Check Digit)

Show 14 digit IMEI instead of 15 digit based on the
config (ignore check digit)

Change-Id: I626d8e4c8b6bfae5ec75a303c1582d0b4ed107eb
CRs-Fixed: 808534
parent 86c952d0
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
@@ -32,7 +32,9 @@ import android.os.Looper;
import android.provider.Settings;
import android.provider.Settings;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.PhoneAccountHandle;
import android.telephony.CarrierConfigManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
@@ -76,6 +78,7 @@ public class SpecialCharSequenceMgr {


    private static final String PRL_VERSION_DISPLAY = "*#0000#";
    private static final String PRL_VERSION_DISPLAY = "*#0000#";


    private static final int IMEI_14_DIGIT = 14;
    /**
    /**
     * Remembers the previous {@link QueryHandler} and cancel the operation when needed, to
     * Remembers the previous {@link QueryHandler} and cancel the operation when needed, to
     * prevent possible crash.
     * prevent possible crash.
@@ -353,6 +356,26 @@ public class SpecialCharSequenceMgr {
                            "getDeviceId", Integer.TYPE)) {
                            "getDeviceId", Integer.TYPE)) {
                for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {
                for (int slot = 0; slot < telephonyManager.getPhoneCount(); slot++) {
                    String deviceId = telephonyManager.getDeviceId(slot);
                    String deviceId = telephonyManager.getDeviceId(slot);
                    boolean enable14DigitImei = false;
                    try {
                        CarrierConfigManager configManager =
                                (CarrierConfigManager) context.getSystemService(
                                 Context.CARRIER_CONFIG_SERVICE);
                        int[] subIds = SubscriptionManager.getSubId(slot);
                        if (configManager != null &&
                                configManager.getConfigForSubId(subIds[0]) != null) {
                            enable14DigitImei =
                                    configManager.getConfigForSubId(subIds[0]).getBoolean(
                                    "config_enable_display_14digit_imei");
                        }
                    } catch(RuntimeException ex) {
                        //do Nothing
                        Log.e(TAG, "Config for 14 digit IMEI not found: " + ex);
                    }
                    if (enable14DigitImei && !TextUtils.isEmpty(deviceId)
                           && deviceId.length() > IMEI_14_DIGIT) {
                        deviceId = deviceId.substring(0, IMEI_14_DIGIT);
                    }
                    if (!TextUtils.isEmpty(deviceId)) {
                    if (!TextUtils.isEmpty(deviceId)) {
                        deviceIds.add(deviceId);
                        deviceIds.add(deviceId);
                    }
                    }