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

Commit f62ecf02 authored by Santos Cordon's avatar Santos Cordon
Browse files

resolved conflicts for c8e528b8 to cw-e-dev

Change-Id: I80f7ceb91fca9187c550ac130aad62abda8ed941
parents 9ca8ef45 c8e528b8
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -52,12 +52,14 @@ import android.provider.CallLog.Calls;
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccount;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;

import java.lang.Override;
import java.lang.String;
import java.util.Locale;

// TODO: Needed for move to system service: import com.android.internal.R;

@@ -293,6 +295,18 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
        String handle = call.getHandle() == null ? null : call.getHandle().getSchemeSpecificPart();
        String name = call.getName();

        if (!TextUtils.isEmpty(handle)) {
            String formattedNumber = PhoneNumberUtils.formatNumber(handle,
                    getCurrentCountryIso(mContext));

            // The formatted number will be null if there was a problem formatting it, but we can
            // default to using the unformatted number instead (e.g. a SIP URI may not be able to
            // be formatted.
            if (!TextUtils.isEmpty(formattedNumber)) {
                handle = formattedNumber;
            }
        }

        if (!TextUtils.isEmpty(name) && TextUtils.isGraphic(name)) {
            return name;
        } else if (!TextUtils.isEmpty(handle)) {
@@ -307,6 +321,26 @@ public class MissedCallNotifierImpl extends CallsManagerListenerBase implements
        }
    }

    /**
     * @return The ISO 3166-1 two letters country code of the country the user is in based on the
     *      network location.  If the network location does not exist, fall back to the locale
     *      setting.
     */
    private String getCurrentCountryIso(Context context) {
        // Without framework function calls, this seems to be the most accurate location service
        // we can rely on.
        final TelephonyManager telephonyManager =
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        String countryIso = telephonyManager.getNetworkCountryIso().toUpperCase();

        if (countryIso == null) {
            countryIso = Locale.getDefault().getCountry();
            Log.w(this, "No CountryDetector; falling back to countryIso based on locale: "
                    + countryIso);
        }
        return countryIso;
    }

    /**
     * Creates a new pending intent that sends the user to the call log.
     *