diff options
Diffstat (limited to 'src/com/android/incallui/StatusBarNotifier.java')
-rw-r--r-- | src/com/android/incallui/StatusBarNotifier.java | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/src/com/android/incallui/StatusBarNotifier.java b/src/com/android/incallui/StatusBarNotifier.java index ca76d235..8e0afcb3 100644 --- a/src/com/android/incallui/StatusBarNotifier.java +++ b/src/com/android/incallui/StatusBarNotifier.java @@ -17,6 +17,7 @@ package com.android.incallui; import android.net.Uri; + import com.google.common.base.Preconditions; import android.app.Notification; @@ -34,8 +35,11 @@ import android.telecom.PhoneCapabilities; import android.telephony.SubscriptionManager; import android.telephony.SubscriptionInfo; import android.telephony.TelephonyManager; +import android.text.BidiFormatter; +import android.text.TextDirectionHeuristics; import android.text.TextUtils; +import com.android.contacts.common.util.BitmapUtil; import com.android.incallui.ContactInfoCache.ContactCacheEntry; import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback; import com.android.incallui.InCallApp.NotificationBroadcastReceiver; @@ -150,8 +154,10 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { * @see #updateInCallNotification(InCallState,CallList) */ private void cancelInCall() { - Log.d(this, "cancelInCall()..."); - mNotificationManager.cancel(IN_CALL_NOTIFICATION); + if (mIsShowingNotification) { + Log.d(this, "cancelInCall()..."); + mNotificationManager.cancel(IN_CALL_NOTIFICATION); + } mIsShowingNotification = false; } @@ -270,15 +276,12 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { } final int state = call.getState(); - final boolean isConference = call.isConferenceCall(); - final boolean isVideoUpgradeRequest = call.getSessionModificationState() - == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST; // Check if data has changed; if nothing is different, don't issue another notification. final int iconResId = getIconToDisplay(call); - final Bitmap largeIcon = getLargeIconToDisplay(contactInfo, isConference); + final Bitmap largeIcon = getLargeIconToDisplay(contactInfo, call); final int contentResId = getContentString(call); - final String contentTitle = getContentTitle(contactInfo, isConference); + final String contentTitle = getContentTitle(contactInfo, call); if (!checkForChangeAndSaveData(iconResId, contentResId, largeIcon, contentTitle, state)) { return; @@ -297,6 +300,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { if ((state == Call.State.INCOMING || state == Call.State.CALL_WAITING) && !InCallPresenter.getInstance().isShowingInCallUi()) { configureFullScreenIntent(builder, inCallPendingIntent, call); + // Set the notification category for incoming calls + builder.setCategory(Notification.CATEGORY_CALL); } // Set the content @@ -306,14 +311,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { builder.setLargeIcon(largeIcon); builder.setColor(mContext.getResources().getColor(R.color.dialer_theme_color)); - if (TelephonyManager.getDefault().isMultiSimEnabled()) { - SubscriptionManager mgr = SubscriptionManager.from(mContext); - SubscriptionInfo subInfoRecord = mgr.getActiveSubscriptionInfo(call.getSubId()); - if (subInfoRecord != null) { - builder.setSubText(subInfoRecord.getDisplayName()); - } - } - + final boolean isVideoUpgradeRequest = call.getSessionModificationState() + == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST; if (isVideoUpgradeRequest) { builder.setUsesChronometer(false); addDismissUpgradeRequestAction(builder); @@ -400,15 +399,15 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { /** * Returns the main string to use in the notification. */ - private String getContentTitle(ContactCacheEntry contactInfo, boolean isConference) { - if (isConference) { + private String getContentTitle(ContactCacheEntry contactInfo, Call call) { + if (call.isConferenceCall() + && !call.can(android.telecom.Call.Details.CAPABILITY_GENERIC_CONFERENCE)) { return mContext.getResources().getString(R.string.card_title_conf_call); } if (TextUtils.isEmpty(contactInfo.name)) { - if (!TextUtils.isEmpty(contactInfo.location)){ - return contactInfo.number + " " + contactInfo.location; - } - return contactInfo.number; + return TextUtils.isEmpty(contactInfo.number) ? null + : BidiFormatter.getInstance().unicodeWrap( + contactInfo.number.toString(), TextDirectionHeuristics.LTR); } return contactInfo.name; } @@ -426,9 +425,10 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { /** * Gets a large icon from the contact info object to display in the notification. */ - private Bitmap getLargeIconToDisplay(ContactCacheEntry contactInfo, boolean isConference) { + private Bitmap getLargeIconToDisplay(ContactCacheEntry contactInfo, Call call) { Bitmap largeIcon = null; - if (isConference) { + if (call.isConferenceCall() + && !call.can(android.telecom.Call.Details.CAPABILITY_GENERIC_CONFERENCE)) { largeIcon = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.img_conference); } @@ -441,9 +441,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { android.R.dimen.notification_large_icon_height); final int width = (int) mContext.getResources().getDimension( android.R.dimen.notification_large_icon_width); - largeIcon = Bitmap.createScaledBitmap(largeIcon, width, height, false); + largeIcon = BitmapUtil.getRoundedBitmap(largeIcon, width, height); } - return largeIcon; } @@ -526,7 +525,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { PendingIntent answerVoicePendingIntent = createNotificationPendingIntent( mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL); builder.addAction(R.drawable.ic_call_white_24dp, - mContext.getText(R.string.description_target_answer), + mContext.getText(R.string.notification_action_answer), answerVoicePendingIntent); } @@ -657,7 +656,8 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { private PendingIntent createLaunchPendingIntent() { final Intent intent = InCallPresenter.getInstance().getInCallIntent( - false /* showDialpad */, false /* newOutgoingCall */); + false /* showDialpad */, false /* newOutgoingCall */, + false /* showCircularReveal */); // PendingIntent that can be used to launch the InCallActivity. The // system fires off this intent if the user pulls down the windowshade |