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

Commit 31974f84 authored by Li Wei's avatar Li Wei Committed by Lalit Kansara
Browse files

InCallUI: Add sim name for call notification

There isn't sim name in call notification.

Append sim name to the content of notification.

(cherry-picked from commit 79885948d97009f805d2503788a16ba76dce77ea)

Change-Id: Ic3cb5f690391f35c789e75bf12a1de36badd90ba
CRs-Fixed: 729954
parent 72e8ce8b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -62,7 +62,8 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
    guava \
    libphonenumber \
    ims-ext-common \
    phonebook_wrapper
    phonebook_wrapper \
    telephony-common

LOCAL_PACKAGE_NAME := Dialer
LOCAL_CERTIFICATE := shared
@@ -70,7 +71,7 @@ LOCAL_PRIVILEGED_MODULE := true

LOCAL_PROGUARD_FLAG_FILES := proguard.flags $(incallui_dir)/proguard.flags

LOCAL_SDK_VERSION := current
# LOCAL_SDK_VERSION := current

include $(BUILD_PACKAGE)

+18 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.hardware.camera2.CameraCharacteristics;
import android.net.Uri;
import android.os.Bundle;
import android.os.Trace;
import android.os.RemoteException;
import android.telecom.Call.Details;
import android.telecom.Connection;
import android.telecom.DisconnectCause;
@@ -29,6 +30,7 @@ import android.telecom.InCallService.VideoCall;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.SubscriptionManager;
import android.telecom.VideoProfile;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;
@@ -793,6 +795,22 @@ public class Call {
        return mTelecomCall == null ? null : mTelecomCall.getDetails().getAccountHandle();
    }

    public int getSubId() {
        PhoneAccountHandle ph = getAccountHandle();
        if (ph != null) {
            try {
                if (ph.getId() != null) {
                    return Integer.parseInt(getAccountHandle().getId());
                }
            } catch (NumberFormatException e) {
                Log.w(this, "sub id is not a number" + e);
            }
            return SubscriptionManager.getDefaultVoiceSubscriptionId();
        } else {
            return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        }
    }

    /**
     * @return The {@link VideoCall} instance associated with the {@link android.telecom.Call}.
     *      Will return {@code null} until {@link #updateFromTelecomCall()} has registered a valid
+17 −1
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ import android.os.SystemClock;
import android.telecom.Call.Details;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
@@ -87,6 +90,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener,
    @Nullable private ContactsPreferences mContactsPreferences;
    private final ContactInfoCache mContactInfoCache;
    private final NotificationManager mNotificationManager;
    private final TelephonyManager mTelephonyManager;
    private final DialerRingtoneManager mDialerRingtoneManager;
    private int mCurrentNotification = NOTIFICATION_NONE;
    private int mCallState = Call.State.INVALID;
@@ -108,6 +112,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener,
        mContext = context;
        mContactsPreferences = ContactsPreferencesFactory.newContactsPreferences(mContext);
        mContactInfoCache = contactInfoCache;
        mTelephonyManager =
                (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
        mNotificationManager =
                (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        mDialerRingtoneManager = new DialerRingtoneManager(
@@ -318,7 +324,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener,
        // Check if data has changed; if nothing is different, don't issue another notification.
        final int iconResId;
        Bitmap largeIcon = getLargeIconToDisplay(contactInfo, call);
        final String content =
        String content =
                getContentString(call, contactInfo.userType);
        int wifiQualityValue = call.getWifiQuality();
        if (wifiQualityValue != QtiCallConstants.VOWIFI_QUALITY_NONE) {
@@ -348,6 +354,16 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener,
            largeIcon = getRoundedIcon(largeIcon);
        }

        //set the content
        boolean isMultiSimDevice = mTelephonyManager.isMultiSimEnabled();
        if (isMultiSimDevice) {
            SubscriptionInfo info =
                    SubscriptionManager.from(mContext).getActiveSubscriptionInfo(call.getSubId());
            if (info != null) {
                content += " (" + info.getDisplayName() + ")";
            }
        }

        /*
         * This builder is used for the notification shown when the device is locked and the user
         * has set their notification settings to 'hide sensitive content'